调用国外大模型测试出现的问题 #69
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#69
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
大模型学习思路:
讲义中关于国内大模型api-key申请准备已十分详细,这里对国外大模型api-key进行申请尝试。
这里尝试使用国外大模型GPT-4o
密钥申请

OpenAI API密钥可以从此处获得:https://platform.openai.com/api-keys
尝试调用模型

这里首先要进入call_openai.py处,对api_key进行设置。这里我尝试了直接在括号输入密钥、字符串形式输入密钥和api_key关键词方式输入,只有最后一种方式成功。
运行结果
使用
python3 call_openai.py
出现如下报错:openai.APIConnectionError: Connection error.
httpcore.ProxyError: 503 Service Unavailable
查阅原因,表示客户端无法与 OpenAI 的 API 服务建立连接。这通常是由于网络问题、代理配置错误或 API 服务暂时不可用引起的。
用
curl
进行连接测试:curl https://api.openai.com/v1
结果如下:
curl: (56) Received HTTP code 503 from proxy after CONNECT
表明请求通过代理服务器时,代理返回了 503 Service Unavailable。这通常意味着代理服务器无法处理请求或代理本身有问题。以下是可能的原因及解决方法:
这里我认为是网络连接的问题。应该只差这一步了,前面都能够跑通。
后续在课程中说了原来是平台上不能挂梯子,那没事了。
这里用国产api沿着相同思路进行尝试。
与上述使用密钥方式相同,如果没有使用
export OPENAI_API_KEY=***** export ZHIPUAI_API_KEY=*****
来进行api-key的设置,需要在代码中使用关键词的方式进行替换。
替换后使用
python3 call_glm4.py
的方式进行测试,得到结果root@w52b7a574407463db61ff4809d6eb6d0-task0-0:/code# python3 call_glm4.py To answer the question, you would need to write an SQL query that selects the
classfrom the
table_name_12where the
frequency_mhzis greater than 91.5 and the
city_of_license` is 'hyannis, nebraska'. Here is the SQL query for that:Note: Assuming the
frequency_mhz
field is stored as a string that can be compared with simple greater than (>
) operator. If it's stored as a numeric type, there would be no need to include quotes around the number in the query.`证明思路正确,完成了实验的复现。
调用国外大模型测试to 调用国外大模型测试出现的问题