AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

我如何通过修改chat.py文件来默认使autogpt在工作时要求openai api使用中文回复所有答案。

Open KzNight opened this issue 2 years ago • 15 comments
trafficstars

Duplicates

  • [X] I have searched the existing issues

Summary 💡

我阅读了chat.py代码,发现通过chat_with_ai()来建立聊天提问,但我尝试添加了一些代码例如 create_chat_completion( model=model, messages=[create_chat_message("system", "后续回复全部使用中文")], max_tokens=50, ) 都没法让autoGPT在后续的回复中默认要求openai api全程使用中文回答问题。 我应该如何修改这部分代码呢?

Examples 🌈

create_chat_completion( model=model, messages=[create_chat_message("system", "后续回复全部使用中文")], max_tokens=50, )

Motivation 🔦

对用使用中文的用户能更快理解autogpt的所有回答,尤其是在快速迭代的时候。

KzNight avatar Apr 15 '23 11:04 KzNight

我可以指导您。您也会说英语吗?如果不会,也没问题,只是需要更多时间。

nponeccop avatar Apr 15 '23 11:04 nponeccop

我可以指导您。您也会说英语吗?如果不会,也没问题,只是需要更多时间。

我可以,你全程使用英文指导就行,我只是写英语很差,但我可以很快读懂英语。

KzNight avatar Apr 15 '23 11:04 KzNight

有同样的需求,能公开指导方法吗

zheng10005 avatar Apr 15 '23 12:04 zheng10005

Duplicates

  • [x] I have searched the existing issues

Summary 💡

我阅读了chat.py代码,发现通过chat_with_ai()来建立聊天提问,但我尝试添加了一些代码例如 create_chat_completion( model=model, messages=[create_chat_message("system", "后续回复全部使用中文")], max_tokens=50, ) 都没法让autoGPT在后续的回复中默认要求openai api全程使用中文回答问题。 我应该如何修改这部分代码呢?

Examples 🌈

create_chat_completion( model=model, messages=[create_chat_message("system", "后续回复全部使用中文")], max_tokens=50, )

Motivation 🔦

对用使用中文的用户能更快理解autogpt的所有回答,尤其是在快速迭代的时候。

63fd0aa726652d81b45a8c8e9ec9e6a 9c37a4c22e4c7a971f0aa8e0314a726 哥们,我尝试在这个位置加用中文回复,亲测有效。gpt回复的时候暂未发现其他非常规错误

zheng10005 avatar Apr 15 '23 12:04 zheng10005

#1563

我刚刚创建了一个英文的问题,供核心团队参与。请注意,我们需要的不是黑客方法,而是一个良好的架构方法,使语言特定的部分不是硬编码的,而是可配置的。我们需要这个方法,因为通过对初始提示进行完全定制可以获得很大的灵活性。

nponeccop avatar Apr 15 '23 12:04 nponeccop

QaQ,我这里找到了另外一个项目,作为有同样需求的人的另外一个参考。 https://github.com/kaqijiang/Auto-GPT-ZH

KzNight avatar Apr 15 '23 13:04 KzNight

建议使用英语,因为GPT英文能力更强。但是对于用户的Prompt可以支持多语言。 I believe GPT model have better performance in English Task, But Prompt for User should support Multiple Language.

Imccccc avatar Apr 15 '23 15:04 Imccccc

@zheng10005 添加 中文回复 之后出现了json 无效的情况

 Warning: Failed to parse AI output, attempting to fix.
 If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly.
Failed to fix AI output, telling the AI.
Error: Invalid JSON

iT-Boyer avatar Apr 16 '23 04:04 iT-Boyer

我认为你应该在prompt.py中,def get_prompt函数下加入 prompt_generator.add_constraint("Answer me in Chinese"),这里建议开发者把语言做成可配置式,或者AI根据使用者问答语言应答的方式更好

likanghai avatar Apr 16 '23 16:04 likanghai

我认为你应该在prompt.py中,def get_prompt函数下加入 prompt_generator.add_constraint("Answer me in Chinese"),这里建议开发者把语言做成可配置式,或者AI根据使用者问答语言应答的方式更好

这样做是有效果的。

image

rich1e avatar Apr 18 '23 07:04 rich1e

@rich1e 可以说明一下具体怎么调整的吗?谢谢

liurat avatar Apr 20 '23 01:04 liurat

@liurat 找到这段代码,在后面添加一句 prompt_generator.add_constraint("Answer me in Chinese")

https://github.com/Significant-Gravitas/Auto-GPT/blob/bcda3c1a3241c35caa6bcc746ee9b0441ea77939/autogpt/prompts/prompt.py#L34-L38

参考:

image

rich1e avatar Apr 20 '23 05:04 rich1e

@rich1e 我已经这样调整了,但是好像并没有生效 image image

liurat avatar Apr 20 '23 05:04 liurat

@liurat 建议从以下 2 点排查。

  1. env 配置,缺少相关服务;

    • OPENAI_API_KEY
    • GOOGLE_API_KEY
  2. 运行 Auto-GPT 时,需要科学上网;

⚠️ 注意:

  1. Chat-GPT 支持中文。
  2. THOUGHTS,REASONING,PLAN,CRITICISM,这些内容是 Chat-GPT 输出。

rich1e avatar Apr 20 '23 06:04 rich1e

@rich1e 我已经这样调整了,但是好像并没有生效

遇到同样问题,解决了吗

iT-Boyer avatar May 12 '23 04:05 iT-Boyer