I created an assistant where I uploaded some files, I would like then to interact with the assistant through python to ask it to perform specific tasks, but not able to create a dialogue or get a response:
response = client.chat.completions.create(
assistant_id = “assistant.id. key”
model=“gpt-4-1106-preview”,
messages=[
{“role”: “system”, “content”: “You are a helpful assistant.”},
{
“role”: “user”,
“content”: “Hello, can you read the reports and make a summary of each one of them?”
}
],
The linked quickstart has a code snippet for each of:
Create an Assistant in the API by defining its custom instructions and picking a model. If helpful, enable tools like Code Interpreter, Retrieval, and Function calling.
Create a Thread when a user starts a conversation.
Add Messages to the Thread as the user ask questions.
Run the Assistant on the Thread to trigger responses. This automatically calls the relevant tools.
You then also need to add the regular polling for status, and retrieval of the final response, or handling of API tool calls, etc. Then management of all that for a pool of users and sessions.
I can see in your first post you still trying to use the chat completions endpoint. That’s not how the assistants agent works.
Basically rewrite ChatGPT plus yourself, but without the streamed responses, without the limitation on how much you are billed, without the built in web browsing or image creation, etc.
You are entering a very exciting journey. I started working with autogen as they have now added the assistants api. I would follow the advice provided before this, so as to get a sound footing in understanding how to engage with the api directly using python. Then when you hit the swarm discussions and getting assistants to colaborate and create “stuff”. It gets adictive. The same team created autogenstudio, but they do not seem to support the assistant api yet. But autogen definitely do. Getting to grip with how threads work is also important in the assistants api.