#Why is my assistant not retrieving metadata context?

1 messages · Page 1 of 1 (latest)

dry oar
#

I have a set metadata being generated from a user's account to be called and update the thread whenever my assistant

run = openai_client.beta.threads.create_and_run(
                    assistant_id=assistantID,
                    instructions=f"...some instructions",
                    thread={
                        "messages": [
                            {"role": "user", "content": msg_content}
                        ]
                    },
                    metadata=metadata
                )
                runID = run.id```

Do i need to set the metadata on the thread ? I had it working before.
dry oar
#

this is where I'm setting the metadata: ```python
chat_threaddata = convertObjectids(chat_threaddata)
chat_threaddata['id'] = str(chat_threaddata['_id'])
threadID = chat_threaddata['threadID']
metadata = await processAiMetadataSocket(userdata, chat_threaddata['petID'], threadID)
print("🎟️ processAiMetadataSocket | 2", metadata)

                openai_client.beta.threads.update(threadID, metadata=metadata)
                openai_client.beta.threads.messages.create( threadID, role="user", content=msg_content)

                print("💨 run has been triggered")
                run = openai_client.beta.threads.runs.create(
                    thread_id=threadID,
                    assistant_id=assistantID,
                    instructions=instructions_2,
                    metadata=metadata
                )
                print("🎟️ run by petid")
                runID = run.id
                print(f"🎟️ runID: {runID}")
#

It returns information like this when I gave it basic information about my cat via metadata

            {
                "id": "msg_wi3c7uA38f9XOIZbXwwR4zHd",
                "assistant_id": "asst_FGrcHZ910DdQcTZ29DulhLsj",
                "run_id": "run_gIIy2ATvng6FppWFvwRmtaUw",
                "role": "assistant",
                "content": [
                    {
                        "value": "I don’t have access to specific information about Little's weight or other personal details. If you can tell me what kind of pet Little is and share any relevant information, I’d be happy to help with any questions or advice you need!",
                        "annotations": [],
                        "type": "text"
                    }
                ]```


here:

```Thread(id='thread_brhjg3heQwTc2wgJSesBVAUx', created_at=1720921009, metadata={'name': 'Little', 'device_codes': "['A0048']", 'weight': '9.0lbs', 'birthday': '2019-11-19',  'allergies': '[]', 'microchipped_number': '', 'vaccinations': ''}, object='thread', tool_resources=ToolResources(code_interpreter=None, file_search=None))```
dry oar
#

So far to get around this I just formualted my metadata directly into my instructions but I don' t think that's a sufficient use case so if any one can help me that'll be awesome

woeful dome
# dry oar So far to get around this I just formualted my metadata directly into my instruc...
OpenAI Developer Forum

The metadata field is purely an API affordance for you to store any data you want. A common example is to store IDs from your database, so you can have a connection between your user object / thread object and the one stored in the OpenAI API. It is not used for any API functionality and is not displayed to the model.