ricklamers commited on
Commit
7800b7d
·
1 Parent(s): a939268

fix: attempt fix for state issue.

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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(respond, 'conversation'):
70
- respond.conversation = [{"role": "system", "content": system_message}]
71
 
72
- respond.conversation.append({"role": "user", "content": message})
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(respond.conversation)
81
  response_message = response.choices[0].message
82
- respond.conversation.append(response_message)
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
- respond.conversation.append(function_response)
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"])