【GPT入门】第31课 两行代码搞定模型debug调试
1. 两行代码搞定调试
from langchain.globals import set_debug,
set_debug(True)
from langchain_ollama import OllamaLLM
from langchain.globals import set_debug, set_verbose
set_debug(True)
#set_verbose(True)
llm = OllamaLLM(model="gpt-4")
print(llm.invoke("你是谁?"))
输出结果,就会带有详细信息 :
C:\ProgramData\anaconda3\envs\gptLearning\python.exe "E:\workspace\gptLearning\gptLearning\ls10\06 ollama\03.debug.py"
[llm/start] [llm:OllamaLLM] Entering LLM run with input:
{
"prompts": [
"你是谁?"
]
}
[llm/end] [llm:OllamaLLM] [10.98s] Exiting LLM run with output:
{
"generations": [
[
{
"text": "我是来自阿里云的大规模语言模型,我被命名为通义千问。我可以回答各种问题,包括但不限于科技、文化、生活、历史、地理等各个领域的问题。我还能够进行文本摘要、代码解析、图像生成、视频转码等各种任务。如果您有任何具体问题或需要某个特定任务的帮助,请随时告诉我,我会尽力为您提供最准确和最有用的答案和帮助。",
"generation_info": {
"model": "gpt-4",
"created_at": "2025-04-02T21:53:46.7502575Z",
"done": true,
"done_reason": "stop",
"total_duration": 10975642300,
"load_duration": 3865007300,
"prompt_eval_count": 11,
"prompt_eval_duration": 1252263100,
"eval_count": 83,
"eval_duration": 5857248900,
"response": "",
"context": [
151644,
872,
198,
105043,
100165,
11319,
151645,
198,
151644,
77091,
198,
104198,
101919,
102661,
99718,
104197,
100176,
102064,
104949,
3837,
35946,
99250,
116816,
31935,
64559,
99320,
56007,
1773,
109944,
102104,
100646,
86119,
3837,
100630,
116509,
99602,
5373,
99348,
5373,
99424,
5373,
100022,
5373,
102752,
49567,
101284,
100650,
103936,
1773,
107228,
100006,
71817,
108704,
106208,
5373,
46100,
106637,
5373,
107553,
43959,
5373,
87140,
46670,
16476,
113464,
88802,
1773,
106870,
110117,
100398,
86119,
57191,
85106,
106168,
105149,
88802,
116211,
3837,
14880,
102422,
106525,
3837,
105351,
110121,
113445,
31235,
102188,
33108,
108543,
11622,
111230,
33108,
100364,
1773
]
},
"type": "Generation"
}
]
],
"llm_output": null,
"run": null,
"type": "LLMResult"
}
我是来自阿里云的大规模语言模型,我被命名为通义千问。我可以回答各种问题,包括但不限于科技、文化、生活、历史、地理等各个领域的问题。我还能够进行文本摘要、代码解析、图像生成、视频转码等各种任务。如果您有任何具体问题或需要某个特定任务的帮助,请随时告诉我,我会尽力为您提供最准确和最有用的答案和帮助。
Process finished with exit code 0