Version 1.0
Browse files
app.py
CHANGED
@@ -105,12 +105,12 @@ def respond(
|
|
105 |
|
106 |
print("messages", messages)
|
107 |
output = ""
|
|
|
108 |
function_calls_to_handle = []
|
109 |
|
110 |
for chunk in stream:
|
111 |
delta = chunk.choices[0].delta
|
112 |
|
113 |
-
# Handle function calls
|
114 |
if hasattr(delta, "tool_calls") and delta.tool_calls:
|
115 |
for tool_call in delta.tool_calls:
|
116 |
if tool_call.function:
|
@@ -122,14 +122,12 @@ def respond(
|
|
122 |
)
|
123 |
|
124 |
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
125 |
-
|
126 |
-
output = f"""*{output}{delta.reasoning_content}*\n"""
|
127 |
elif delta.content:
|
128 |
output += delta.content
|
129 |
|
130 |
-
yield output
|
131 |
|
132 |
-
# Handle any function calls that were made
|
133 |
if function_calls_to_handle:
|
134 |
for func_call in function_calls_to_handle:
|
135 |
func_result = handle_function_call(
|
|
|
105 |
|
106 |
print("messages", messages)
|
107 |
output = ""
|
108 |
+
reasoning = ""
|
109 |
function_calls_to_handle = []
|
110 |
|
111 |
for chunk in stream:
|
112 |
delta = chunk.choices[0].delta
|
113 |
|
|
|
114 |
if hasattr(delta, "tool_calls") and delta.tool_calls:
|
115 |
for tool_call in delta.tool_calls:
|
116 |
if tool_call.function:
|
|
|
122 |
)
|
123 |
|
124 |
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
|
125 |
+
reasoning += delta.reasoning_content
|
|
|
126 |
elif delta.content:
|
127 |
output += delta.content
|
128 |
|
129 |
+
yield f"*{reasoning}*\n{output}"
|
130 |
|
|
|
131 |
if function_calls_to_handle:
|
132 |
for func_call in function_calls_to_handle:
|
133 |
func_result = handle_function_call(
|