@@ -518,6 +518,49 @@ if response_message.tool_calls:
518518 print (f " Generated image saved as: { f.name} \n " )
519519```
520520
521+ #### Minimal Example Using ` smolagents ` With Ollama And Judge0
522+
523+ ``` python
524+ # pip install judge0 smolagents[openai]
525+ import os
526+ from typing import Any
527+
528+ import judge0
529+ from smolagents import CodeAgent, OpenAIServerModel, Tool
530+ from smolagents.local_python_executor import CodeOutput, PythonExecutor
531+
532+
533+ class Judge0PythonExecutor (PythonExecutor ):
534+ def send_tools (self , tools : dict[str , Tool]) -> None :
535+ pass
536+
537+ def send_variables (self , variables : dict[str , Any]) -> None :
538+ pass
539+
540+ def __call__ (self , code_action : str ) -> CodeOutput:
541+ source_code = f " final_answer = lambda x : print(x) \n { code_action} "
542+ result = judge0.run(source_code = source_code, language = judge0.PYTHON_FOR_ML )
543+ return CodeOutput(
544+ output = result.stdout,
545+ logs = result.stderr or " " ,
546+ is_final_answer = result.exit_code == 0 ,
547+ )
548+
549+
550+ # Get your free tier Ollama Cloud API key at https://ollama.com.
551+ model = OpenAIServerModel(
552+ model_id = " gpt-oss:120b-cloud" ,
553+ api_base = " https://ollama.com/v1" ,
554+ api_key = os.environ[" OLLAMA_API_KEY" ],
555+ )
556+
557+ agent = CodeAgent(tools = [], model = model)
558+ agent.python_executor = Judge0PythonExecutor()
559+
560+ result = agent.run(" How many r's are in the word 'strawberry'?" )
561+ print (result)
562+ ```
563+
521564### Filesystem
522565
523566This example shows how to use Judge0 Python SDK to:
0 commit comments