Created
August 16, 2025 22:29
-
-
Save mh61503891/28b99345bb96ff5841360405cad18a23 to your computer and use it in GitHub Desktop.
Using gpt-oss:120b with Tool Calling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openai import OpenAI | |
| LLM_PROMPT = """ | |
| Your Prompt to get the score. | |
| """ | |
| LLM_TOOLS = [ | |
| { | |
| "type": "function", | |
| "function": { | |
| "name": "get_score", | |
| "description": "Get a score", | |
| "parameters": { | |
| "type": "object", | |
| "properties": { | |
| "score": {"type": "number"}, | |
| }, | |
| "required": ["score"], | |
| }, | |
| }, | |
| }, | |
| ] | |
| client = OpenAI( | |
| base_url="http://localhost:11434/v1", | |
| api_key="[api-key]", | |
| ) | |
| response = client.chat.completions.create( | |
| model="gpt-oss:120b", | |
| messages=[ | |
| { | |
| "role": "system", | |
| "content": "You shall always respond using tool calling.", | |
| }, | |
| { | |
| "role": "user", | |
| "content": LLM_PROMPT, | |
| }, | |
| ], | |
| reasoning_effort="high", | |
| tools=LLM_TOOLS, | |
| tool_choice={ | |
| "type": "function", | |
| "function": { | |
| "name": "get_score", | |
| }, | |
| }, | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment