-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error when adding message to thread #331
Comments
Same issue Additionally, the issue is not present when when checking the thread state. Checking thread state... Adding prompt to the thread... On the endpoint: INFO: 10.0.1.4:52084 - "POST /threads/2949af24-9653-404e-8d2d-5210e8c0ffff/state HTTP/1.1" 500 Internal Server Error |
Confirming that this is indeed a valid issue. The OpenGPTs API has changed, and existing scripts/programs that use it might break. The payloads the API expects are largely just untyped In the short term, I'll work on updating Longer term, I feel the OpenGPTs community needs to decide upon and implement a more strongly-typed API. This is important since the untyped nature of the current API makes it inherently unstable. |
It looks like the recent changes that decouple agents from threads changed the API a bit. You now need to add messages to a run instead. Here's a sample of how to use the API now: # Create a RAG-enabled assistant
resp = requests.post('http://127.0.0.1:8100/assistants', json={
"name": "My Asisstant",
"config": {
"configurable": {
"type": "agent",
"type==agent/agent_type": "GPT 3.5 Turbo",
"type==agent/system_message": "You are a helpful assistant",
"type==agent/tools": [
# {"type": "wikipedia"},
# enable RAG
{"type": "retrieval"}
]
}
},
"public": False
}, cookies= {"user_id": "foo"}).content
assistant = json.loads(resp)
# Create a thread
thread = json.loads(requests.post('http://127.0.0.1:8100/threads', cookies= {"user_id": user_id}, json={
"name": "My Thread",
"assistant_id": assistant["assistant_id"]
}).content)
# Upload files for RAG
files = {
'files': ("opengpt_blog_1.txt", open("opengpt_blog_1.txt", 'rb'), 'text/plain'),
}
config = {
'configurable': {
# RAG files can be attached to thread or assistants, but not both
'thread_id': thread['thread_id'],
# 'assistant_id': assistant['assistant_id'],
}
}
config = {"config": json.dumps(config)}
cookie = {"user_id": user_id}
response = requests.post('http://localhost:8100/ingest', files=files, cookies=cookie, data=config, headers={'accept': 'application/json'})
# Send a message to the thread
payload = {
"input" : [
{
"content" : "Tell me about OpenGPTs.",
"type" : "human",
}
],
"thread_id" : thread["thread_id"]
}
response = requests.post(
"http://127.0.0.1:8100/runs/stream",
json.dumps(payload),
)
print(response.content) I'll try to get the |
Thanks, confirmed working example |
got the following error when running command following API.md
print(requests.post(
'http://127.0.0.1:8100/threads/266f60d1-ac42-43cd-ab93-f54b7e714971/state',
cookies= {"opengpts_user_id": "foo"}, json={
"values": [{
"content": "hi! my name is bob",
"type": "human",
}]
}
).content)
...
opengpts-backend | File "/backend/app/storage.py", line 122, in update_thread_state
opengpts-backend | await agent.aupdate_state(
opengpts-backend | File "/usr/local/lib/python3.11/site-packages/langgraph/pregel/init.py", line 479, in aupdate_state
opengpts-backend | raise InvalidUpdateError("Ambiguous update, specify as_node")
The text was updated successfully, but these errors were encountered: