- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有最新版本的 OpenAi,但缺少某些属性。我试过重新安装它,没有解决它。 GPT 和 Chat 是我发现还不能用的。
切记,我是 python 的新手并且具有该语言的基本知识。代码取自GitHub
我的代码如果它告诉你一些事情:
import openai
import pyttsx3
import speech_recognition as sr
from api_key import API_KEY
openai.api_key = API_KEY
engine = pyttsx3.init()
r = sr.Recognizer()
mic = sr.Microphone(device_index=1)
conversation = ""
user_name = "You"
bot_name = "DAI"
while True:
with mic as source:
print("\nlistening...")
r.adjust_for_ambient_noise(source, duration=0.2)
audio = r.listen(source)
print("no longer listening.\n")
try:
user_input = r.recognize_google(audio)
except:
continue
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
conversation += prompt # allows for context
# fetch response from open AI api
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
conversation += response_str + "\n"
print(response_str)
engine.say(response_str)
engine.runAndWait()
我们将不胜感激
编辑:
最后的答案使错误消失了,但又出现了一个新的:
谢谢,成功了。但它仍然没有用,我仍然得到一个错误。如果可以的话,我会尝试解决它。非常感谢我得到的任何帮助和提示。这可能不是我遇到的最后一个错误。
This is the error: Traceback (most recent call last):
File "/Users/danieforsell22b/Desktop/GPT3VoiceBot/gpt3Bot.py", line 22, in <module>
r.adjust_for_ambient_noise(source, duration=0.2)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/speech_recognition/__init__.py", line 569, in adjust_for_ambient_noise
assert source.stream is not None, "Audio source must be entered before adjusting, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?"
^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Audio source must be entered before adjusting, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/danieforsell22b/Desktop/GPT3VoiceBot/gpt3Bot.py", line 20, in <module>
with mic as source:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/speech_recognition/__init__.py", line 201, in __exit__
self.stream.close()
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close'
最佳答案
您将变量 response_str
初始化了两次,这就是您得到 AttributeError: module 'openai' has no attribute 'GPT'
的原因。
从此更改您的代码...
# fetch response from open AI api
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
conversation += response_str + "\n"
print(response_str)
engine.say(response_str)
engine.runAndWait()
...为此。
# fetch response from open AI api
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str_split = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
conversation += response_str_split + "\n"
print(response_str_split)
engine.say(response_str_split)
engine.runAndWait()
关于python - OpenAI GPT-3 API 错误 : "AttributeError: module ' openai' has no attribute 'GPT' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74988365/
我已经为此奋斗了几个小时。显然,我不是专家,但我已经做到了这一点 - api 设置,在前端运行,当我输入聊天提示时,它会出现错误,并且gunicorn 返回大长错误。 这是我的 ai_chat.py
我已经为此奋斗了几个小时。显然,我不是专家,但我已经做到了这一点 - api 设置,在前端运行,当我输入聊天提示时,它会出现错误,并且gunicorn 返回大长错误。 这是我的 ai_chat.py
尝试调用刚刚为 ChatGPT 发布的 got-3.5-turbo API,但收到错误请求错误? var body = new {
尝试调用刚刚为 ChatGPT 发布的 got-3.5-turbo API,但收到错误请求错误? var body = new {
最近我必须找到一种方法来区分虚拟机使用的分区类型,从虚拟磁盘读取原始数据我能够通过检查偏移量 1C2(GPT 的 EE)找到它,以防万一MBR 磁盘如果磁盘是动态的,1C2 的偏移量有 42,如果是基
我有一个 Android 应用程序,目前正在使用 chat gpt 3.0 进行补全,并且工作正常。现在,在他们发布 chat gpt 3.5 Turbo 后,我根据他们的请求示例做了一些更改,但抛出
我有一个 Android 应用程序,目前正在使用 chat gpt 3.0 进行补全,并且工作正常。现在,在他们发布 chat gpt 3.5 Turbo 后,我根据他们的请求示例做了一些更改,但抛出
创建微调模型后,如何在/v1/chat/completions 中使用它?我们尝试了这个,但出现了错误 curl --location 'https://api.openai.com/v1/chat/
我收到以下错误: [3067] NetworkUtility.shouldRetryException: Unexpected response code400 for https://api.ope
我收到以下错误: [3067] NetworkUtility.shouldRetryException: Unexpected response code400 for https://api.ope
创建微调模型后,如何在/v1/chat/completions 中使用它?我们尝试了这个,但出现了错误 curl --location 'https://api.openai.com/v1/chat/
我正在围绕 GPT-3 构建一个应用程序,我想知道我发出的每个请求使用了多少 token 。这可能吗?如何实现? 最佳答案 OPEN-AI 通过代币对 GPT-3 的使用进行收费,这包括提示和答案。对
kapt 和有什么区别和 implementation在 Gradle 中声明依赖项时以及何时应该在另一个上使用一个? 例子: //Room Components implementation "an
所以我在我的 React 应用程序中实现了 chat gpt 3.5 Turbo API。所以我的应用程序基本上就像招聘人员的助手。因此,招聘人员向应用程序提供了一个示例职位帖子,并将该帖子发送到聊天
所以我在我的 React 应用程序中实现了 chat gpt 3.5 Turbo API。所以我的应用程序基本上就像招聘人员的助手。因此,招聘人员向应用程序提供了一个示例职位帖子,并将该帖子发送到聊天
我有最新版本的 OpenAi,但缺少某些属性。我试过重新安装它,没有解决它。 GPT 和 Chat 是我发现还不能用的。 切记,我是 python 的新手并且具有该语言的基本知识。代码取自GitHub
我有最新版本的 OpenAi,但缺少某些属性。我试过重新安装它,没有解决它。 GPT 和 Chat 是我发现还不能用的。 切记,我是 python 的新手并且具有该语言的基本知识。代码取自GitHub
我使用的是 gpt-4-0613 模型,具有单个函数,并在系统提示符中包含一些自定义数据。 如果该函数在聊天中很早就被触发,在前两个请求内,它的功能就很好,并且 API 会要求用户提供调用该函数所需的
我使用的是 gpt-4-0613 模型,具有单个函数,并在系统提示符中包含一些自定义数据。 如果该函数在聊天中很早就被触发,在前两个请求内,它的功能就很好,并且 API 会要求用户提供调用该函数所需的
OpenAI 现在允许我们微调 GPT-3.5 模型。我已经使用自己的数据集测试和微调了模型,但问题是微调模型随机生成答案,而不是根据我的自定义数据集正确生成答案。 有什么方法可以让模型仅根据我自己的
我是一名优秀的程序员,十分优秀!