Update app.py
Browse files
app.py
CHANGED
|
@@ -75,15 +75,15 @@ async def generate(input_text: str):
|
|
| 75 |
yield "π Thinking...", ""
|
| 76 |
|
| 77 |
config = types.GenerateContentConfig(
|
| 78 |
-
tools=[train_tool],
|
| 79 |
temperature=0.3,
|
| 80 |
)
|
| 81 |
|
| 82 |
-
# Create async chat session (
|
| 83 |
-
chat =
|
| 84 |
|
| 85 |
-
# Send the user input to the model
|
| 86 |
-
response =
|
| 87 |
|
| 88 |
# --- Manual Tool Loop ---
|
| 89 |
max_turns = 5
|
|
@@ -97,7 +97,7 @@ async def generate(input_text: str):
|
|
| 97 |
if not parts:
|
| 98 |
break
|
| 99 |
|
| 100 |
-
# Collect function calls from parts
|
| 101 |
tool_calls = []
|
| 102 |
for p in parts:
|
| 103 |
call = getattr(p, "function_call", None)
|
|
@@ -140,7 +140,7 @@ async def generate(input_text: str):
|
|
| 140 |
if tool_responses:
|
| 141 |
yield "π Finalizing response...", ""
|
| 142 |
# Provide tool results back to the model so it can compose the final answer
|
| 143 |
-
response =
|
| 144 |
else:
|
| 145 |
break
|
| 146 |
|
|
|
|
| 75 |
yield "π Thinking...", ""
|
| 76 |
|
| 77 |
config = types.GenerateContentConfig(
|
| 78 |
+
tools=[train_tool, types.Tool(google_search=types.GoogleSearch())],
|
| 79 |
temperature=0.3,
|
| 80 |
)
|
| 81 |
|
| 82 |
+
# Create async chat session (DO NOT await here)
|
| 83 |
+
chat = client.aio.chats.create(model=model_id, config=config)
|
| 84 |
|
| 85 |
+
# Send the user input to the model (await is correct here)
|
| 86 |
+
response = chat.send_message(input_text)
|
| 87 |
|
| 88 |
# --- Manual Tool Loop ---
|
| 89 |
max_turns = 5
|
|
|
|
| 97 |
if not parts:
|
| 98 |
break
|
| 99 |
|
| 100 |
+
# Collect function calls from parts (correct attribute is function_call)
|
| 101 |
tool_calls = []
|
| 102 |
for p in parts:
|
| 103 |
call = getattr(p, "function_call", None)
|
|
|
|
| 140 |
if tool_responses:
|
| 141 |
yield "π Finalizing response...", ""
|
| 142 |
# Provide tool results back to the model so it can compose the final answer
|
| 143 |
+
response = chat.send_message(tool_responses)
|
| 144 |
else:
|
| 145 |
break
|
| 146 |
|