Skip to content

Commit

Permalink
3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kaqijiang committed May 4, 2023
1 parent 1194bdb commit d171df1
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 45 deletions.
18 changes: 8 additions & 10 deletions autogpt/llm/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ def create_chat_completion(
f"{Fore.RED}Error: ", f"达到速率限制,通过...{Fore.RESET}"
)
if not warned_user:
logger.double_check(
f"请仔细检查您是否设置了 {Fore.CYAN + Style.BRIGHT}PAID{Style.RESET_ALL} OpenAI API 帐户. "
+ f"公众号《阿杰的人生路》回复AI加入群聊寻求帮助"
)
# logger.double_check(
# f"请仔细检查您是否设置了 {Fore.CYAN + Style.BRIGHT}PAID{Style.RESET_ALL} OpenAI API 帐户. "
# )
warned_user = True
except (APIError, Timeout) as e:
if e.http_status != 502:
Expand All @@ -191,12 +190,11 @@ def create_chat_completion(
)
time.sleep(backoff)
if response is None:
logger.typewriter_log(
"未能获得 OPENAI 的回应",
Fore.RED,
"Auto-GPT 未能从 OpenAI 的服务中得到响应。 "
+ f"公众号《阿杰的人生路》回复AI加入群聊寻求帮助",
)
# logger.typewriter_log(
# "未能获得 OPENAI 的回应",
# Fore.RED,
# "Auto-GPT 未能从 OpenAI 的服务中得到响应。 ",
# )
logger.double_check()
if cfg.debug_mode:
raise RuntimeError(f"Failed to get response after {num_retries} retries")
Expand Down
10 changes: 5 additions & 5 deletions autogpt/memory_management/summary_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ def update_running_summary(
if len(new_events) == 0:
new_events = "Nothing new happened."

prompt = f'''Your task is to create a concise running summary of actions and information results in the provided text, focusing on key and potentially important information to remember.
prompt = f'''你的任务是在提供的文本中创建一个简明的运行摘要,重点是关键和潜在重要的信息以供记忆.
You will receive the current summary and the your latest actions. Combine them, adding relevant key information from the latest development in 1st person past tense and keeping the summary concise.
您将会收到当前的摘要和您最新的操作。将它们结合起来,从最新的发展中加入相关的关键信息,使用第一人称过去时,并保持摘要简明。
Summary So Far:
到目前为止的摘要:
"""
{current_memory}
"""
Latest Development:
最新的进展:
"""
{new_events}
"""
Expand All @@ -115,7 +115,7 @@ def update_running_summary(

message_to_return = {
"role": "system",
"content": f"This reminds you of these events from your past: \n{current_memory}",
"content": f"这让你想起了过去的这些事件: \n{current_memory}",
}

return message_to_return
111 changes: 81 additions & 30 deletions autogpt/prompts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,113 @@ def build_default_prompt_generator() -> PromptGenerator:
str: The generated prompt string.
"""

# Initialize the PromptGenerator object
# # Initialize the PromptGenerator object
# prompt_generator = PromptGenerator()

# # Add constraints to the PromptGenerator object
# prompt_generator.add_constraint(
# "~4000 word limit for short term memory. Your short term memory is short, so"
# " immediately save important information to files."
# )
# prompt_generator.add_constraint(
# "If you are unsure how you previously did something or want to recall past"
# " events, thinking about similar events will help you remember."
# )
# prompt_generator.add_constraint("No user assistance")
# # prompt_generator.add_constraint("Please localize natural language strings in your reply to Chinese")

# prompt_generator.add_constraint("Reply must be in Chinese")
# prompt_generator.add_constraint("If the content of the reply is not in Chinese, you need to translate it into Chinese")
# prompt_generator.add_constraint(
# 'Exclusively use the commands listed in double quotes e.g. "command name"'
# )

# # Define the command list
# commands = [
# ("Task Complete (Shutdown)", "task_complete", {"reason": "<reason>"}),
# ]

# # Add commands to the PromptGenerator object
# for command_label, command_name, args in commands:
# prompt_generator.add_command(command_label, command_name, args)

# # Add resources to the PromptGenerator object
# prompt_generator.add_resource(
# "Internet access for searches and information gathering."
# )
# prompt_generator.add_resource("Long Term memory management.")
# prompt_generator.add_resource(
# "GPT-3.5 powered Agents for delegation of simple tasks."
# )
# prompt_generator.add_resource("File output.")

# # Add performance evaluations to the PromptGenerator object
# prompt_generator.add_performance_evaluation(
# "Continuously review and analyze your actions to ensure you are performing to"
# " the best of your abilities."
# )
# prompt_generator.add_performance_evaluation(
# "Constructively self-criticize your big-picture behavior constantly."
# )
# prompt_generator.add_performance_evaluation(
# "Reflect on past decisions and strategies to refine your approach."
# )
# prompt_generator.add_performance_evaluation(
# "Every command has a cost, so be smart and efficient. Aim to complete tasks in"
# " the least number of steps."
# )
# prompt_generator.add_performance_evaluation("Write all code to a file.")

prompt_generator = PromptGenerator()

# Add constraints to the PromptGenerator object
# 向PromptGenerator对象添加约束条件
prompt_generator.add_constraint(
"~4000 word limit for short term memory. Your short term memory is short, so"
" immediately save important information to files."
"~4000字的短期记忆限制。由于您的短期记忆较短,因此请立即将重要信息保存到文件中。"
)
prompt_generator.add_constraint(
"If you are unsure how you previously did something or want to recall past"
" events, thinking about similar events will help you remember."
"如果您不确定以前如何做某事或想回忆过去的事件,思考类似的事件将有助于您记忆。"
)
prompt_generator.add_constraint("No user assistance")
# prompt_generator.add_constraint("Please localize natural language strings in your reply to Chinese")
prompt_generator.add_constraint("Reply must be in Chinese")
prompt_generator.add_constraint("If the content of the reply is not in Chinese, you need to translate it into Chinese")
prompt_generator.add_constraint("无用户辅助")
# prompt_generator.add_constraint("请在回复中将自然语言字符串本地化为中文")

prompt_generator.add_constraint("回复必须为中文")
prompt_generator.add_constraint("如果回复内容不是中文,则需要将其翻译为中文")
prompt_generator.add_constraint(
'Exclusively use the commands listed in double quotes e.g. "command name"'
'仅使用双引号中列出的命令,例如"command name"'
)

# Define the command list
commands = [
("Task Complete (Shutdown)", "task_complete", {"reason": "<reason>"}),
]
# 定义命令列表
commands = [ ("任务完成(关闭)", "task_complete", {"reason": "<reason>"}),]

# Add commands to the PromptGenerator object
# 向PromptGenerator对象添加命令
for command_label, command_name, args in commands:
prompt_generator.add_command(command_label, command_name, args)

# Add resources to the PromptGenerator object
# 向PromptGenerator对象添加资源
prompt_generator.add_resource(
"Internet access for searches and information gathering."
"互联网访问以进行搜索和信息收集。"
)
prompt_generator.add_resource("Long Term memory management.")
prompt_generator.add_resource("长期记忆管理。")
prompt_generator.add_resource(
"GPT-3.5 powered Agents for delegation of simple tasks."
"由GPT-3.5提供支持的代理人用于简单任务的委派。"
)
prompt_generator.add_resource("File output.")
prompt_generator.add_resource("文件输出。")

# Add performance evaluations to the PromptGenerator object
# 向PromptGenerator对象添加绩效评估
prompt_generator.add_performance_evaluation(
"Continuously review and analyze your actions to ensure you are performing to"
" the best of your abilities."
"持续审查和分析您的行为,以确保您尽最大努力发挥能力。"
)
prompt_generator.add_performance_evaluation(
"Constructively self-criticize your big-picture behavior constantly."
"持续对自己的总体行为进行建设性的自我批评。"
)
prompt_generator.add_performance_evaluation(
"Reflect on past decisions and strategies to refine your approach."
"反思过去的决策和策略,以完善您的方法。"
)
prompt_generator.add_performance_evaluation(
"Every command has a cost, so be smart and efficient. Aim to complete tasks in"
" the least number of steps."
"每个命令都有成本,因此要聪明和高效。目标是以最少的步骤完成任务。"
)
prompt_generator.add_performance_evaluation("Write all code to a file.")
prompt_generator.add_performance_evaluation("将所有代码写入文件。")

return prompt_generator


Expand Down

0 comments on commit d171df1

Please sign in to comment.