Spaces:
Runtime error
Runtime error
ricklamers
commited on
Commit
·
7800b7d
1
Parent(s):
a939268
fix: attempt fix for state issue.
Browse files
app.py
CHANGED
@@ -66,10 +66,10 @@ def get_model_response(messages):
|
|
66 |
return None
|
67 |
|
68 |
def respond(message, history, system_message):
|
69 |
-
if not hasattr(
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
available_functions = {
|
75 |
"evaluate_math_expression": evaluate_math_expression,
|
@@ -77,9 +77,9 @@ def respond(message, history, system_message):
|
|
77 |
|
78 |
function_calls = []
|
79 |
while True:
|
80 |
-
response = get_model_response(
|
81 |
response_message = response.choices[0].message
|
82 |
-
|
83 |
|
84 |
if not response_message.tool_calls and response_message.content is not None:
|
85 |
break
|
@@ -92,7 +92,7 @@ def respond(message, history, system_message):
|
|
92 |
}
|
93 |
function_calls.append(function_call)
|
94 |
function_response = call_function(tool_call, available_functions)
|
95 |
-
|
96 |
function_calls.append({
|
97 |
"name": function_response["name"],
|
98 |
"result": json.loads(function_response["content"])
|
|
|
66 |
return None
|
67 |
|
68 |
def respond(message, history, system_message):
|
69 |
+
if not hasattr(history, 'conversation'):
|
70 |
+
history.conversation = [{"role": "system", "content": system_message}]
|
71 |
|
72 |
+
history.conversation.append({"role": "user", "content": message})
|
73 |
|
74 |
available_functions = {
|
75 |
"evaluate_math_expression": evaluate_math_expression,
|
|
|
77 |
|
78 |
function_calls = []
|
79 |
while True:
|
80 |
+
response = get_model_response(history.conversation)
|
81 |
response_message = response.choices[0].message
|
82 |
+
history.conversation.append(response_message)
|
83 |
|
84 |
if not response_message.tool_calls and response_message.content is not None:
|
85 |
break
|
|
|
92 |
}
|
93 |
function_calls.append(function_call)
|
94 |
function_response = call_function(tool_call, available_functions)
|
95 |
+
history.conversation.append(function_response)
|
96 |
function_calls.append({
|
97 |
"name": function_response["name"],
|
98 |
"result": json.loads(function_response["content"])
|