gladcolor / LLM-Geo

GNU General Public License v3.0
273 stars 49 forks source link

如何在 jupyter notebook 中设置代理呢?貌似在国内不能直接使用OpenAI API #8

Open LYCnight opened 2 weeks ago

LYCnight commented 2 weeks ago

文件

LLM_Geo_API4.ipynb

运行结果

response_for_graph = solution.get_LLM_response_for_graph() solution.graph_response = response_for_graph solution.save_solution()

clear_output(wait=True) display(Code(solution.code_for_graph, language='python'))


Error in get_LLM_reply(), will sleep 10 seconds, then retry 1/3: Request timed out. Error in get_LLM_reply(), will sleep 10 seconds, then retry 2/3: Request timed out. Error in get_LLM_reply(), will sleep 10 seconds, then retry 3/3: Request timed out.

UnboundLocalError Traceback (most recent call last) Cell In[6], line 1 ----> 1 response_for_graph = solution.get_LLM_response_for_graph() 2 solution.graph_response = response_for_graph 3 solution.save_solution()

File /data/AI4E/lzd/ToolCall/LLM-Geo/LLM_Geo_kernel.py:152, in Solution.get_LLM_response_for_graph(self, execuate) 150 def get_LLM_response_for_graph(self, execuate=True): 151 # self.chat_history.append() --> 152 response = self.get_LLM_reply( 153 prompt=self.graph_prompt, 154 system_role=self.role, 155 model=self.model, 156 ) 157 self.graph_response = response 158 try:

File /data/AI4E/lzd/ToolCall/LLM-Geo/LLM_Geo_kernel.py:129, in Solution.get_LLM_reply(self, prompt, verbose, temperature, stream, retry_cnt, sleep_sec, system_role, model) 127 response_chucks = [] 128 if stream: --> 129 for chunk in response: 130 response_chucks.append(chunk) 131 content = chunk.choices[0].delta.content

UnboundLocalError: local variable 'response' referenced before assignment

gladcolor commented 1 week ago

您可以试一下这里提到的方法: https://stackoverflow.com/questions/77606417/openai-api-request-with-proxy

LYCnight commented 6 days ago

您可以试一下这里提到的方法: https://stackoverflow.com/questions/77606417/openai-api-request-with-proxy

好的,谢谢,我试试