see in github: hambuger/HAI-GPT/blob/master/openai_util/s_auto_gpt.py
def run_conversation(user_content):
# Analyze the user's instructions into detailed operation steps through chatgpt
step_response = create_chat_completion(user_content, None,
[do_step_by_step()],
"auto")
message = step_response["choices"][0]["message"]
if not message.get("function_call"):
logger.info("response:{}".format(step_response["choices"][0]["message"]['content']))
return message['content']
function_args = message["function_call"]["arguments"]
steps = json.loads(function_args)['steps']
# order by step_order asc
steps.sort(key=lambda x: x['step_order'])
messages = [{"role": "system",
"content": "You are an advanced robot, and you can do almost anything that humans ask you to do."},
{"role": "user", "content": user_content}]
# loop through each step
for index, step in enumerate(steps):
order_step_response = run_single_step_chat(messages, [get_invoke_method_info_by_name(step['step_method'])])
logger.info(
"order:{}, response:{}".format(index, order_step_response["choices"][0]["message"]['content']))
1.By passing the user instruction statement and method name to chatgpt, let chagpt determine the order of method calls and return json data
2.In theory, it is possible to construct a method registration center, which maintains all the capabilities that chatgpt can call
3.todo: You can use the dynamic execution of the language to implement chatgpt to learn new skills and persist the skills as method codes