I’m trying to make a chatbot through python, and the assistant api would make that MUCH easier! But I’m having trouble getting the response back from the assistant once I’ve posted the question.
Following this thread for updates from people.
What do you have so far? I built a nice terminal app to interface with assistants so I might be able to help.
After you have posted the question (added the question in thread) you need to run the assistant, then keep checking the run status, after it is completed, retrieve the thread latest message. and viola you have your response back from the assistant.
This github repository has assistant API demo code in a colab notebook
links:
https://github.com/davideuler/awesome-assistant-api/blob/main/GPT-Assistant-Tutoring.ipynb
That is perfect! Thanks so much! But how do I integrate function calling to this code?
I’m also looking for an example code with a call to an external API
There are some cookbooks that help:
* Assistants API Overview (Python SDK)
* Function-calling with an OpenAPI specification
There’s also AIAPI which is similar to assistant API but is a little simpler in my opinion but I’m biased since I wrote it to help me with function calling.
Yeah I couldn’t find much out there on this topic so I just winged it. If you scroll down to the output method you can see how I setup web search through function calling.
Here is the function I added to the assistant
{
"name": "web_search",
"description": "Search the web for answers.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Your search query"
}
},
"required": [
"query"
]
}
}
You basically have to check for requires action
in the run status. Since I only have one function, I have it just run the web_search method, once you get the output from that you submit it to a tool run which will basically create a new run and give the data to the assistant. The assistant will go over the data and submit its answer to the thread which will return a completed status.
I just posted a simple demo app in Python that could get you started: GitHub - dbookstaber/OpenAI_Assistant: Simple demo of OpenAI Assistant with Functions.