Using Functions
Obiguard allows you to define functions in API requests using the OpenAI function signature. Thetools parameter can include functions and is supported by models that enable function or tool calling.
- Python SDK
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Obiguard’s AI Gateway enables function calling, allowing you to define functions in API requests. Supported models can respond with either plain text or a function name and its parameters.
tools parameter can include functions and is supported by models that enable function or tool calling.
from obiguard import Obiguard
client = Obiguard(
obiguard_api_key='vk-obg***', # Your Obiguard virtual key here
)
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
}
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=messages,
tools=tools,
tool_choice="auto"
)
print(completion)
| Provider | Supported Models |
|---|---|
| OpenAI | gpt-4 series, gpt-3.5-turbo series |
| Azure OpenAI | gpt-4 series, gpt-3.5-turbo series |
| Anyscale | mistralai/Mistral-7B-Instruct-v0.1, mistralai/Mixtral-8x7B-Instruct-v0.1 |
| Together AI | mistralai/Mixtral-8x7B-Instruct-v0.1, mistralai/Mistral-7B-Instruct-v0.1, togethercomputer/CodeLlama-34b-Instruct |
| Fireworks AI | firefunction-v1, fw-function-call-34b-v0 |
| Google Gemini / Vertex AI | gemini-1.0-pro, gemini-1.0-pro-001, gemini-1.5-pro-latest |
