Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andreibondarev/51d9a21d5f5e2706b57c129eeb4f4e20 to your computer and use it in GitHub Desktop.
Save andreibondarev/51d9a21d5f5e2706b57c129eeb4f4e20 to your computer and use it in GitHub Desktop.
Ollama (mistral:7b-instruct-v0.3-fp16) with manual Tool Calling
TURN 1:
Request:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"prompt": "[AVAILABLE_TOOLS][{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'format': {'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.'}}, 'required': ['location', 'format']}}}][/AVAILABLE_TOOLS][INST] What's the weather like today in Paris[/INST]",
"stream": false,
"raw": true
}
Response:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"created_at": "2024-07-02T02:46:34.1324Z",
"response": "[TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'Paris, FR', 'format': 'celsius'}}]"
}
TURN 2:
Request:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"prompt": "[AVAILABLE_TOOLS][{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'format': {'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.'}}, 'required': ['location', 'format']}}}][/AVAILABLE_TOOLS][INST] What's the weather like today in Paris[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'Paris, FR', 'format': 'celsius'}}]</s>[TOOL_RESULTS][{'content': '22F'}][/TOOL_RESULTS]",
"stream": false,
"raw": true
}
Response:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"created_at": "2024-07-02T02:54:34.443805Z",
"response": " It is currently 22 degrees Fahrenheit in Paris. If you prefer Celsius, the temperature conversion would be approximately -5.56 degrees Celsius. Enjoy your day!"
}
TURN 3:
Request:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"prompt": "[AVAILABLE_TOOLS][{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'format': {'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.'}}, 'required': ['location', 'format']}}}][/AVAILABLE_TOOLS][INST] What's the weather like today in Paris[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'Paris, FR', 'format': 'celsius'}}]</s>[TOOL_RESULTS][{'content': '22F'}][/TOOL_RESULTS][INST] What about SF?[/INST]",
"stream": false,
"raw": true
}
Response:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"created_at": "2024-07-02T02:55:48.760937Z",
"response": "[TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'San Francisco, CA', 'format': 'fahrenheit'}}]"
}
TURN 4:
Request:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"prompt": "[AVAILABLE_TOOLS][{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'format': {'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.'}}, 'required': ['location', 'format']}}}][/AVAILABLE_TOOLS][INST] What's the weather like today in Paris[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'Paris, FR', 'format': 'celsius'}}]</s>[TOOL_RESULTS][{'content': '22F'}][/TOOL_RESULTS][INST] What about SF?[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'San Francisco, CA', 'format': 'fahrenheit'}}][TOOL_RESULTS][{'content': '25C'}][/TOOL_RESULTS]",
"stream": false,
"raw": true
}
Response:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"created_at": "2024-07-02T03:03:07.937232Z",
"response": " It looks like it's currently 25 degrees Celsius in San Francisco. For Paris, the temperature is 22 degrees Fahrenheit (around -6 degrees Celsius)."
}
TURN 5:
Request:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"prompt": "[AVAILABLE_TOOLS][{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'format': {'type': 'string', 'enum': ['celsius', 'fahrenheit'], 'description': 'The temperature unit to use. Infer this from the users location.'}}, 'required': ['location', 'format']}}}][/AVAILABLE_TOOLS][INST] What's the weather like today in Paris[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'Paris, FR', 'format': 'celsius'}}]</s>[TOOL_RESULTS][{'content': '22F'}][/TOOL_RESULTS][INST] What about SF?[/INST][TOOL_CALLS] [{'name': 'get_current_weather', 'arguments': {'location': 'San Francisco, CA', 'format': 'fahrenheit'}}][TOOL_RESULTS][{'content': '25C'}][/TOOL_RESULTS][INST]How to convert fahrenheit to celcius?[/INST]",
"stream": false,
"raw": true
}
Response:
{
"model": "mistral:7b-instruct-v0.3-fp16",
"created_at": "2024-07-02T03:04:50.938875Z",
"response": " The formula for converting Fahrenheit to Celsius is (F - 32) * 5/9. In your case, 25F is approximately 7.8 degrees Celsius."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment