I am learning about the tool/function calling aspect of the assistants api. To start with, I thought I wanted to add a web searching capability to an assistant.
is this the right way of defining the tooling?
assistant = client.beta.assistants.create(
name="AssistantMan",
instructions="You answer to everything concisely. If you don't know the answer, you search the internet for it.",
tools=[{"type": "code_interpreter"},
{
"type": "function",
"function": {
"name": "searchInternet",
"description": "Search the internet for information beyond your knowledge cut-off date",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query to be used to search the internet."
}
}
}
}
}],
model="gpt-4-turbo"
)
then, assuming I’ve written the method to search the internet which, let’s say looks like this:
def searchInternet(query):
url = internet_search_api_url
params = {'q': query}
response = requests.get(url, params=params)
return response.json()
then the ones that I am a bit confused are:
- How to I tell the assistant to call the search internet function?
- How to process the result of the function call and back to the threads messages again?
Many thanks