求助 有关jupyter notebook运行超时的问题
github吧
全部回复
仅看楼主
level 5
2023年09月16日 12点09分 1
level 5
2023年09月16日 12点09分 2
你是在用什么SDK去连接大模型么?你与大模型API之间的网络连接有问题。
2023年09月17日 00点09分
大佬,能在说明白点吗,我应该怎么办[泪]
2023年09月17日 02点09分
@Dragon1573 大佬,能在说明白点吗,我应该怎么办[泪]
2023年09月17日 02点09分
@贴吧用户_58DG6Xb In [4] 里有一句 get_completion ,这个是在做什么?
2023年09月17日 02点09分
level 5
2023年09月17日 02点09分 3
level 5
import openai
import os
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())
openai.api_key = "这里填写你的api-key"
# 使用模型为gpt-3.5-turbo
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0,
)
return response.choices[0].message["content"]
text = f"""
You should express what you want a model to do by \
providing instructions that are as clear and \
specific as you can possibly make them. \
This will guide the model towards the desired output, \
and reduce the chances of receiving irrelevant \
or incorrect responses. Don't confuse writing a \
clear prompt with writing a short prompt. \
In many cases, longer prompts provide more clarity \
and context for the model, which can lead to \
more detailed and relevant outputs.
"""
#
prompt = f"""
Summarize the text delimited by triple backticks \
into a single sentence.
```{text}```
"""
response = get_completion(prompt)
print(response)
2023年09月17日 02点09分 4
吧务
level 12
试了一下,施法之后是没有问题的。
如果不施法,报错原因也正好是无法连接 OpenAI 的 API 接口。
2023年09月17日 16点09分 5
1