Skip to content

Commit bc2c693

Browse files
Update Ollama examples
1 parent fcef378 commit bc2c693

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ You are a helpful assistant that can execute code written in the C programming l
251251
Only respond with the code written in the C programming language that needs to be executed and nothing else.
252252
Strip the backticks in code blocks.
253253
"""
254-
prompt = "How many r's are in the word 'strawberry'."
254+
prompt = "How many r's are in the word 'strawberry'?"
255255

256256
response = client.chat(
257257
model="gpt-oss:120b-cloud",
@@ -284,20 +284,20 @@ client = Client(
284284
model="qwen3-coder:480b-cloud"
285285

286286
messages=[
287-
{"role": "user", "content": "Calculate how many r's are in the word 'strawberry'."},
287+
{"role": "user", "content": "How many r's are in the word 'strawberry'?"},
288288
]
289289

290290
tools = [{
291291
"type": "function",
292292
"function": {
293-
"name": "execute_python",
294-
"description": "Execute Python code and return result",
293+
"name": "execute_c",
294+
"description": "Execute the C programming language code.",
295295
"parameters": {
296296
"type": "object",
297297
"properties": {
298298
"code": {
299299
"type": "string",
300-
"description": "The Python code to execute"
300+
"description": "The code written in the C programming language."
301301
}
302302
},
303303
"required": ["code"]
@@ -312,16 +312,21 @@ messages.append(response_message)
312312

313313
if response_message.tool_calls:
314314
for tool_call in response_message.tool_calls:
315-
if tool_call.function.name == "execute_python":
316-
result = judge0.run(source_code=tool_call.function.arguments["code"], language=judge0.PYTHON)
315+
if tool_call.function.name == "execute_c":
316+
code = tool_call.function.arguments["code"]
317+
print(f"CODE GENERATED BY THE MODEL:\n{code}\n")
318+
319+
result = judge0.run(source_code=code, language=judge0.C)
320+
print(f"CODE EXECUTION RESULT:\n{result.stdout}\n")
321+
317322
messages.append({
318323
"role": "tool",
319-
"tool_name": "execute_python",
324+
"tool_name": "execute_c",
320325
"content": result.stdout,
321326
})
322327

323328
final_response = client.chat(model=model, messages=messages)
324-
print(final_response["message"]["content"])
329+
print(f'FINAL RESPONSE BY THE MODEL:\n{final_response["message"]["content"]}')
325330
```
326331

327332
### Filesystem

0 commit comments

Comments
 (0)