[GH-ISSUE #1773] [BUG]: API OpenAi chat not working when workspace in mode 'query' #1158

Closed
opened 2026-02-22 18:23:24 -05:00 by yindo · 4 comments
Owner

Originally created by @woasischo on GitHub (Jun 27, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1773

Originally assigned to: @shatfield4 on GitHub.

How are you running AnythingLLM?

Docker (local)

What happened?

When trying to execute a question against a workspace with loaded documents, I get a correct answer using the GUI, but the followig response using the API:

{
"id": "3cead8ee-3772-4b6a-a0b1-eeb80ef83a91",
"object": "chat.completion",
"created": 1719489644791,
"model": "chroma",
"choices": [
{
"message": {
"role": "assistant",
"content": "There is no relevant information in this workspace to answer your query."
},
"logprobs": null,
"finish_reason": "no_content"
}
]
}

This happens with different vector databases

Are there known steps to reproduce?

No response

Originally created by @woasischo on GitHub (Jun 27, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1773 Originally assigned to: @shatfield4 on GitHub. ### How are you running AnythingLLM? Docker (local) ### What happened? When trying to execute a question against a workspace with loaded documents, I get a correct answer using the GUI, but the followig response using the API: { "id": "3cead8ee-3772-4b6a-a0b1-eeb80ef83a91", "object": "chat.completion", "created": 1719489644791, "model": "chroma", "choices": [ { "message": { "role": "assistant", "content": "There is no relevant information in this workspace to answer your query." }, "logprobs": null, "finish_reason": "no_content" } ] } This happens with different vector databases ### Are there known steps to reproduce? _No response_
yindo added the bug label 2026-02-22 18:23:24 -05:00
yindo closed this issue 2026-02-22 18:23:24 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jun 27, 2024):

Are you sending the same exact prompt in the UI with no chat history. The previous chat history would impact results and refusal when a workspace is in query mode.

@timothycarambat commented on GitHub (Jun 27, 2024): Are you sending the same exact prompt in the UI with _no chat history_. The previous chat history would impact results and refusal when a workspace is in `query` mode.
Author
Owner

@timothycarambat commented on GitHub (Jun 27, 2024):

For reference there are only two escape hatches in the code for refusal

@timothycarambat commented on GitHub (Jun 27, 2024): For reference there are only two escape hatches in the code for refusal - No found vectors/namespace and in query mode https://github.com/Mintplex-Labs/anything-llm/blob/7a78ad3960e069dbc783971dc7ff13cf1868c767/server/utils/chats/openaiCompatible.js#L29 - No contextTexts from the vector search response (could have been filtered out or nothing was found) https://github.com/Mintplex-Labs/anything-llm/blob/7a78ad3960e069dbc783971dc7ff13cf1868c767/server/utils/chats/openaiCompatible.js#L120
Author
Owner

@woasischo commented on GitHub (Jun 28, 2024):

First, thanks for your fast response :-)

According to your comment, I created a new workspace, vectorized a pdf document sucessfully and immediately went to the API.

Here I posted the following request:

curl -X 'POST'
'http://localhost:3001/api/v1/openai/chat/completions'
-H 'accept: /'
-H 'Authorization: Bearer SHK026W-C0640SA-PNV5YMF-AYQD1S1'
-H 'Content-Type: application/json'
-d '{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "What is DocXChain ?"
}
],
"model": "weaviate",
"stream": false,
"temperature": 0.7
}'

and again, got the same response:

{
"id": "3779bb1f-e8af-430e-bb10-45db2791e97f",
"object": "chat.completion",
"created": 1719565432835,
"model": "weaviate",
"choices": [
{
"message": {
"role": "assistant",
"content": "There is no relevant information in this workspace to answer your query."
},
"logprobs": null,
"finish_reason": "no_content"
}
]
}

When I switch the workspace to chat, my question is directly routed to the LLM, neglating the document:

{
"id": "a720313f-062f-430a-9947-ab1b02779b15",
"object": "chat.completion",
"created": 1719566047337,
"model": "weaviate",
"choices": [
{
"message": {
"role": "assistant",
"content": "DocXChain appears to be a term or a concept related to digital documentation or document management. However, I could not find any specific information about it in my database. To better understand DocXChain, I recommend searching for more details on the specific context or platform where you encountered the term. You may also try reaching out to relevant communities or forums to gather more information and insights.\n"
},
"logprobs": null,
"finish_reason": "stop"
}
]
}

Thanks also for the hint with openaiCompatible.js. I had already found this code and thought of starting to do some debugging.
Do you already have some suggestions or should I try my luck with digging into your code ?

@woasischo commented on GitHub (Jun 28, 2024): First, thanks for your fast response :-) According to your comment, I created a new workspace, vectorized a pdf document sucessfully and immediately went to the API. Here I posted the following request: curl -X 'POST' \ 'http://localhost:3001/api/v1/openai/chat/completions' \ -H 'accept: */*' \ -H 'Authorization: Bearer SHK026W-C0640SA-PNV5YMF-AYQD1S1' \ -H 'Content-Type: application/json' \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant" }, { "role": "user", "content": "What is DocXChain ?" } ], "model": "weaviate", "stream": false, "temperature": 0.7 }' and again, got the same response: { "id": "3779bb1f-e8af-430e-bb10-45db2791e97f", "object": "chat.completion", "created": 1719565432835, "model": "weaviate", "choices": [ { "message": { "role": "assistant", "content": "There is no relevant information in this workspace to answer your query." }, "logprobs": null, "finish_reason": "no_content" } ] } When I switch the workspace to chat, my question is directly routed to the LLM, neglating the document: { "id": "a720313f-062f-430a-9947-ab1b02779b15", "object": "chat.completion", "created": 1719566047337, "model": "weaviate", "choices": [ { "message": { "role": "assistant", "content": "DocXChain appears to be a term or a concept related to digital documentation or document management. However, I could not find any specific information about it in my database. To better understand DocXChain, I recommend searching for more details on the specific context or platform where you encountered the term. You may also try reaching out to relevant communities or forums to gather more information and insights.\n" }, "logprobs": null, "finish_reason": "stop" } ] } Thanks also for the hint with openaiCompatible.js. I had already found this code and thought of starting to do some debugging. Do you already have some suggestions or should I try my luck with digging into your code ?
Author
Owner

@timothycarambat commented on GitHub (Jun 28, 2024):

Let me try to replicate real quick, nothing above what you just posted is different from the intended code path, so something is amiss or I am overlooking a detail

@timothycarambat commented on GitHub (Jun 28, 2024): Let me try to replicate real quick, nothing above what you just posted is different from the intended code path, so something is amiss or I am overlooking a detail
yindo changed title from [BUG]: API OpenAi chat not working when workspace in mode 'query' to [GH-ISSUE #1773] [BUG]: API OpenAi chat not working when workspace in mode 'query' 2026-06-05 14:39:16 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#1158