Skip to content

Commit b4677ba

Browse files
authored
Fix Rendering issue for FC guide (#2148)
1 parent fed4e13 commit b4677ba

File tree

3 files changed

+131
-395
lines changed

3 files changed

+131
-395
lines changed

guides/ipynb/keras_hub/function_calling_with_keras_hub.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
" context += hist + \"\\n\"\n",
432432
"\n",
433433
" # Get model response\n",
434-
" response = gemma.generate(context)\n",
434+
" response = gemma.generate(context, strip_prompt=True)\n",
435435
" print(f\"Model response: {response}\")\n",
436436
"\n",
437437
" # Extract tool call\n",
@@ -455,6 +455,7 @@
455455
" break\n",
456456
" else:\n",
457457
" print(\"No tool call found - conversation complete\")\n",
458+
" conversation_history.append(response)\n",
458459
" break\n",
459460
"\n",
460461
" print(\"\\n--- Final Conversation ---\")\n",
@@ -952,4 +953,4 @@
952953
},
953954
"nbformat": 4,
954955
"nbformat_minor": 0
955-
}
956+
}

guides/keras_hub/function_calling_with_keras_hub.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def capture_code_output(code_string, globals_dict=None, locals_dict=None):
181181
"""
182182
Executes Python code and captures any stdout output.
183183
184-
184+
185185
This function uses eval() and exec() which can execute arbitrary code.
186186
NEVER use this function with untrusted code in production environments.
187187
Always validate and sanitize code from LLMs before execution.
@@ -316,7 +316,7 @@ def convert(amount, currency, new_currency):
316316
context += hist + "\n"
317317

318318
# Get model response
319-
response = gemma.generate(context)
319+
response = gemma.generate(context, strip_prompt=True)
320320
print(f"Model response: {response}")
321321

322322
# Extract tool call
@@ -340,6 +340,7 @@ def convert(amount, currency, new_currency):
340340
break
341341
else:
342342
print("No tool call found - conversation complete")
343+
conversation_history.append(response)
343344
break
344345

345346
print("\n--- Final Conversation ---")

0 commit comments

Comments
 (0)