mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 00:46:42 +08:00
Fix /chat/completions to allow send only the latest message (#15197)
### What problem does this PR solve? 1. Fix /chat/completions to send only the latest message 2. Allo chat stream=False ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -4082,11 +4082,14 @@ The previous endpoint `POST /api/v1/chats/{chat_id}/completions` is deprecated.
|
||||
- `'content-Type: application/json'`
|
||||
- `'Authorization: Bearer <YOUR_API_KEY>'`
|
||||
- Body:
|
||||
|
||||
- `"messages"`: `list[object]`
|
||||
- `"question"`: `string`
|
||||
- `"stream"`: `boolean`
|
||||
- `"chat_id"`: `string` (optional)
|
||||
- `"session_id"`: `string` (optional)
|
||||
- `"llm_id"`: `string` (optional)
|
||||
- `"pass_all_history_messages"`: `boolean` (optional)
|
||||
|
||||
##### Request example
|
||||
|
||||
@@ -4117,10 +4120,6 @@ curl --request POST \
|
||||
"stream": true,
|
||||
"session_id":"9fa7691cb85c11ef9c5f0242ac120005",
|
||||
"messages": [
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Hi! I'\''m your assistant. What can I do for you?"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Who are you?"
|
||||
@@ -4131,8 +4130,10 @@ curl --request POST \
|
||||
|
||||
##### Request Parameters
|
||||
|
||||
- `"messages"`: (*Body Parameter*), `list[object]`, *Required*
|
||||
The conversation messages sent to the model.
|
||||
- `"messages"`: (*Body Parameter*), `list[object]`
|
||||
The latest user message, or the conversation messages sent to the model when `pass_all_history_messages` is `true`. Either `messages` or `question` is required.
|
||||
- `"question"`: (*Body Parameter*), `string`
|
||||
Latest user question. This is equivalent to passing `messages: [{"role": "user", "content": question}]`.
|
||||
- `"stream"`: (*Body Parameter*), `boolean`
|
||||
Indicates whether to output responses in a streaming way:
|
||||
- `true`: Enable streaming (default).
|
||||
@@ -4143,6 +4144,8 @@ curl --request POST \
|
||||
Optional session ID. If `chat_id` is provided but `session_id` is omitted, a new session will be generated automatically.
|
||||
- `"llm_id"`: (*Body Parameter*), `string`
|
||||
Optional model override when a specific chat model should be used for this request.
|
||||
- `"pass_all_history_messages"`: (*Body Parameter*), `boolean`
|
||||
When `chat_id` and `session_id` are provided, defaults to `false`, so the server uses stored session history and only the latest user message from the request. Set to `true` to replace/use the submitted full `messages` history, and overrides the stored session history.
|
||||
|
||||
#### Response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user