Skip to content

Commit fcef378

Browse files
Update simple example with Ollama
1 parent 78ef628 commit fcef378

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,12 @@ client = Client(
246246
headers={"Authorization": "Bearer " + os.environ.get("OLLAMA_API_KEY")},
247247
)
248248

249-
system = "You are a helpful assistant that can execute Python code. Only respond with the code to be executed and nothing else. Strip backticks in code blocks."
250-
prompt = "Calculate how many r's are in the word 'strawberry'."
249+
system = """
250+
You are a helpful assistant that can execute code written in the C programming language.
251+
Only respond with the code written in the C programming language that needs to be executed and nothing else.
252+
Strip the backticks in code blocks.
253+
"""
254+
prompt = "How many r's are in the word 'strawberry'."
251255

252256
response = client.chat(
253257
model="gpt-oss:120b-cloud",
@@ -258,10 +262,10 @@ response = client.chat(
258262
)
259263

260264
code = response["message"]["content"]
261-
print(f"Generated code:\n{code}")
265+
print(f"CODE GENERATED BY THE MODEL:\n{code}\n")
262266

263-
result = judge0.run(source_code=code, language=judge0.PYTHON)
264-
print(f"Execution result:\n{result.stdout}")
267+
result = judge0.run(source_code=code, language=judge0.C)
268+
print(f"CODE EXECUTION RESULT:\n{result.stdout}")
265269
```
266270

267271
#### Tool Calling (a.k.a. Function Calling) with Ollama

0 commit comments

Comments
 (0)