Spaces:
Running
Running
File size: 1,909 Bytes
8fa3acc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
from typing import List
def init_function_calling(labels: List[str], tool_choices: str, open_ai_api_call: bool):
if open_ai_api_call:
call = {
"tools": [
{
"type": "function",
"function": {
"name": "classification",
"description": "Use this function to return your response to the user question.",
"parameters": {
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": labels,
"description": "The permitted categories to response to the question.",
},
},
"required": ["category"],
},
},
}
],
"tool_choice": tool_choices,
}
else:
# Anthropic call
call = {
"tools": [
{
"name": "classification",
"description": "Use this function to return your response to the user question.",
"input_schema": {
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": labels,
"description": "The permitted categories to response to the question.",
},
},
"required": ["category"],
},
},
],
"tool_choice": tool_choices,
}
return call
|