Better results
This commit is contained in:
15
main.py
15
main.py
@@ -327,11 +327,18 @@ def process_history(conversation_history):
|
|||||||
for message in conversation_history:
|
for message in conversation_history:
|
||||||
# if there is content append it
|
# if there is content append it
|
||||||
if message.get("content") and message["role"] == "function":
|
if message.get("content") and message["role"] == "function":
|
||||||
messages+="Function result: " + message["content"]+"\n"
|
messages+="Function result: \n" + message["content"]+"\n"
|
||||||
elif message.get("function_call"):
|
elif message.get("function_call"):
|
||||||
# encode message["function_call" to json and appends it
|
# encode message["function_call" to json and appends it
|
||||||
fcall = json.dumps(message["function_call"])
|
fcall = json.dumps(message["function_call"])
|
||||||
messages+= fcall+"\n"
|
parameters = "calling " + message["function_call"]["name"]+" with arguments:"
|
||||||
|
args=json.loads(message["function_call"]["arguments"])
|
||||||
|
for arg in args:
|
||||||
|
logger.debug(arg)
|
||||||
|
logger.debug(args)
|
||||||
|
v=args[arg]
|
||||||
|
parameters+=f""" {arg}=\"{v}\""""
|
||||||
|
messages+= parameters+"\n"
|
||||||
elif message.get("content") and message["role"] == "user":
|
elif message.get("content") and message["role"] == "user":
|
||||||
messages+=message["content"]+"\n"
|
messages+=message["content"]+"\n"
|
||||||
elif message.get("content") and message["role"] == "assistant":
|
elif message.get("content") and message["role"] == "assistant":
|
||||||
@@ -572,7 +579,7 @@ def search_duckduckgo(a, agent_actions={}):
|
|||||||
a = json.loads(a)
|
a = json.loads(a)
|
||||||
list=ddg(a["query"], args.search_results)
|
list=ddg(a["query"], args.search_results)
|
||||||
|
|
||||||
text_res="Internet search results:\n"
|
text_res=""
|
||||||
for doc in list:
|
for doc in list:
|
||||||
text_res+=f"""- {doc["snippet"]}. Source: {doc["title"]} - {doc["link"]}\n"""
|
text_res+=f"""- {doc["snippet"]}. Source: {doc["title"]} - {doc["link"]}\n"""
|
||||||
|
|
||||||
@@ -636,7 +643,7 @@ def evaluate(user_input, conversation_history = [],re_evaluate=False, agent_acti
|
|||||||
#reasoning = post_process(reasoning)
|
#reasoning = post_process(reasoning)
|
||||||
function_completion_message=""
|
function_completion_message=""
|
||||||
if processed_messages > 0:
|
if processed_messages > 0:
|
||||||
function_completion_message += "History:\n ```\n"+process_history(conversation_history)+"\n```\n"
|
function_completion_message += process_history(conversation_history)+"\n"
|
||||||
function_completion_message += "Request: "+user_input+"\nReasoning: "+reasoning
|
function_completion_message += "Request: "+user_input+"\nReasoning: "+reasoning
|
||||||
responses, function_results = process_functions(function_completion_message, action=action["action"], agent_actions=agent_actions)
|
responses, function_results = process_functions(function_completion_message, action=action["action"], agent_actions=agent_actions)
|
||||||
# if there are no subtasks, we can just reply,
|
# if there are no subtasks, we can just reply,
|
||||||
|
|||||||
Reference in New Issue
Block a user