Can't add "assistant" role message in assistant api

I’m trying to use the Assistants API - it seems client.beta.threads.messages.create only works with role=“user” but not role=“assistant”. Is there any way to add as in the chat api a previous message history directly?

6 Likes

You maybe able to use threads enabled by OpenAI.

Ensure you are using assistant.id & thread.id

no, you can only create user messages. The assistant prompt is given only in the assistant config que you create it.

1 Like

okay so basically for those of us who use gpt to finish a conversation by feeding it something it already said

we should not use the assistants api? …that kinda sucks …but i guess…

I second this – I am trying to implement a caching mechanism, so that if a user asks for a response to U1,A1,U2, and the response was A2, the cache would store A2. Next time for the same sequence of messages U1,A1,U2, I would find the response A2 in the cache, and now I want to insert A2 into the thread so everything afterwards looks as if the assistant indeed produced A2.

[notation U1, A1 etc are user, asst msgs respectively]

1 Like

I tried createAndRun to see if that would trigger an Assistant reply without a user message and it does not work.

OpenAI team, we need an endpoint that triggers an assistant reply based on current Thread state. I’m specifically trying to get the Assistant to start the conversation, based on the Assistant instructions.

1 Like

what I’m doing is feeding the previous conversation as part of the user message (specifying what the assistant said previously). Not ideal

That is what threads do. They provide the whole context to the assistant. You add a user message, run the thread, get messages from the assistant, add a new user message and run the thread again…

You want the assistant to proactively start a conversation ? Any trigger that would make the assistant start, would be a user message. But what is your use case ?

I have a settings where I want to continue a previous conversation, but without using the thread memory.

As far as I know, assistants can only be used with threads. Before assistants I developed a session class that was essentially the same as a thread.
What I did different, was to create a conversation summary and storing that to feed to the model Summary + new input - > assistant output
But that works with the chat model, not with assistants

1 Like

Facing exactly the same issue. Would be nice if the Create message method would support the assistant role and not only user.

7 Likes

I second this as well. I am migrating my assistant built in chats completion API to assistants API. There is no way for me to migrate the prompt chaining that I have implemented earlier to give a context by giving a sample conversation. How do I prompt chain using Assistants API. Documentation should address this. Allowing Assistant role is extremely useful.

2 Likes

In Langroid (a Multi-Agent LLM framework from ex-CMU/UW-Madison researchers), I ended up using a simple trick to add “Assistant” role messages into a thread (in my case I do this to enable caching of Assistant responses, but it can work for other scenarios too): Simply prepend “Assistant:” in a user-role message, and the LLM takes that into account just fine:

Assistant spoofing trick for caching:

Langroid: GitHub - langroid/langroid: Harness LLMs with Multi-Agent Programming

This is the power. Highly focused information generates great responses, uses minimal tokens. Show the full message history to the user and it looks like a normal chat.

Being able to access messages in threads and add/remove/modify is what I’m waiting for. Until then I’m still using my system, very similar to assistants and what everyone else is doing. There’s kind of just a right way to do this stuff, so we’re all doing the same things. It’s pretty cool.

Hello, I noticed that too, do you have advice how to do a few shot example for the assistant if not through messages?

Thank you!

1 Like

In my case… I have an external event that triggers a message (for example a reminder), I want my assistant to be able to answer questions about the reminder, so it would be something like.

user: I want to eat healthy
assistant: sure, I will remind you to eat an apple every day
assistant (reminder): eat an apple
user: where do I find it?
assistant: in the fridge

I need the reminder in the context, and the reminder will be sent from a cron job using the api (with the specific thread)

2 Likes

I second this as well. I only need assistant in few scenario, like need retrieve docs, So it’s very important for me to be able to manually add assistant messages.

1 Like

I also second this. There is a lot of power in tailoring with system/assistant messages.

1 Like

Like the additional “context” field I suggested here: Assistants API and RAG - Best of Both Worlds?

Or, something similar.