Unlike Upsert Conversation, with thread conversation, you do not need to send us the entire transcript each time that you have new messages in your LLM conversations. As the conversation progresses, you only need to send us the new messages alongside the thread conversation identifier and we will append these messages to the corresponding conversation transcript in Context.ai.
The semantics of thread conversation are: If a conversation request is received without the id property, a new thread conversation is created and the corresponding identifier is returned. For all subsequent appends to this thread conversation, the user is expected to send this identifier in the request. If a conversation request has the id property, the messages are appended to the conversation matching that id.
To use thread conversation, you must:
Always use the same id when appending messages to an existing thread conversation.
Always include the same metadata on each thread conversation log request.
{ "status":"ok","data": {"id":"custom_id""appended_messages": [ {"id":"e_aeglcefpnoqeumu","role":"assistant","message":"Can I help you with something?","rating":"neutral" } ] }}
{"status":"failed","error":"Metadata for thread with id:<id> does not match this conversation."}
Example Request
{"conversation": {"id":"custom_id""messages": [ {"role":"system","message":"You are a LLM providing information about a local football club.","event_timestamp":"2020-02-20T20:20:23Z" }, {"role":"user","message":"What time does the team arrive?","event_timestamp":"2020-02-20T20:21:34Z" }, {"role":"assistant","message":"I'm not sure what time the team arrives.","event_timestamp":"2020-02-20T23:20:40Z","rating":-1 } ],"metadata": {"model":"gpt-3.5-turbo-16k","user_id":"2947451" } }}
Example Response
{"status":"ok","data": {"id":"c_djncroenvory""provided_id": "custom_id","appended_messages": [ {"id":"e_aeglcefpnoqeumu","role":"system","message":"You are a LLM providing information about a local football club.","rating":"neutral" }, {"id":"e_alkdmnvllmvqcmu","role":"user","message":"What time does the team arrive?","rating":"neutral" }, {"id":"e_aubsjdiehysxop","role":"assistant","message":"I'm not sure what time the team arrives.","rating":"thumbs_down" }, ] }}