8000 Fix:The OpenAI-Compatible Agent API returns an incorrect message by Woody-Hu · Pull Request #8177 · infiniflow/ragflow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix:The OpenAI-Compatible Agent API returns an incorrect message #8177

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

Conversation

Woody-Hu
Copy link
Contributor

What problem does this PR solve?

#8175

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jun 11, 2025
@KevinHuSh KevinHuSh requested a review from asiroliu June 12, 2025 03:38
@KevinHuSh KevinHuSh added the ci Continue Integration label Jun 12, 2025
@asiroliu
Copy link
Contributor
asiroliu commented Jun 12, 2025

@Woody-Hu

Reproduce (v0.19.0):

infiniflow@infiniflow168:~/workspace/python/ragflow$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/f268bed0474011f0824c52398dbdd522/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-ZhNDQ0NzI2NDc0MTExZjBiMzg5NTIzOT' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "Say this is a test!"}],
        "stream": true
      }'
data: {"id": "88634540474111f08a3852398dbdd522", "object": "chat.completion.chunk", "created": null, "model": "f268bed0474011f0824c52398dbdd522", "param": null, "usage": {"prompt_tokens": 6, "completion_tokens": 15, "total_tokens": 21, "completion_tokens_details": {"reasoning_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}}, "choices": [{"message": {"role": "assistant", "content": "Hi! I'm your smart assistant. What can I do for you?"}, "logprobs": null, "finish_reason": "stop", "index": 0}]}

data: [DONE]

infiniflow@infiniflow168:~/workspace/python/ragflow$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/f268bed0474011f0824c52398dbdd522/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-ZhNDQ0NzI2NDc0MTExZjBiMzg5NTIzOT' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "Who are you"}],
        "stream": true
      }'
data: {"id": "ca219310474111f0b86e52398dbdd522", "object": "chat.completion.chunk", "created": null, "model": "f268bed0474011f0824c52398dbdd522", "param": null, "usage": {"prompt_tokens": 3, "completion_tokens": 15, "total_tokens": 18, "completion_tokens_details": {"reasoning_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}}, "choices": [{"message": {"role": "assistant", "content": "Hi! I'm your smart assistant. What can I do for you?"}, "logprobs": null, "finish_reason": "stop", "index": 0}]}

data: [DONE]

Verified (8adb576)

infiniflow@infiniflow168:~/workspace/python/ragflow$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/d984fe86474211f0a109c670e0700f36/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-YzZDJkNzQwNDc0MjExZjBhYTZkYzY3MG' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "Say this is a test!"}],
        "stream": true
      }'
data: {"id": "01005b68474311f0b356c670e0700f36", "object": "chat.completion", "created": null, "model": "d984fe86474211f0a109c670e0700f36", "param": null, "usage": {"prompt_tokens": 6, "completion_tokens": 9, "total_tokens": 15, "completion_tokens_details": {"reasoning_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0}}, "choices": [{"message": {"role": "assistant", "content": "**ERROR**: the first argument must be callable"}, "logprobs": null, "finish_reason": "stop", "index": 0}]}

data: [DONE]

RAGFlow log:

Traceback (most recent call last):
  File "/ragflow/api/db/services/canvas_service.py", line 334, in completionOpenAI
    for ans in canvas.run(stream=True, pass_begin=True):
  File "/ragflow/agent/canvas.py", line 287, in run
    ans = self.components[cpn_id]["obj"].run(self.history, **kwargs)
  File "/ragflow/agent/component/base.py", line 378, in run
    raise e
  File "/ragflow/agent/component/base.py", line 374, in run
    res = self._run(history, **kwargs)
  File "/ragflow/agent/component/answer.py", line 45, in _run
    return partial(self.stream_output(pass_begin=pass_begin))
TypeError: the first argument must be callable
2025-06-12 12:09:15,396 INFO     25 192.168.200.105 - - [12/Jun/2025 12:09:15] "POST /api/v1/agents_openai/d984fe86474211f0a109c670e0700f36/chat/completions HTTP/1.1" 200 -

@asiroliu
Copy link
Contributor

@Woody-Hu
Verified (dfbaab1)

Traceback (most recent call last):
  File "/ragflow/api/db/services/canvas_service.py", line 334, in completionOpenAI
    for ans in canvas.run(stream=True, pass_begin=True):
  File "/ragflow/agent/canvas.py", line 291, in run
    for an in ans():
  File "/ragflow/agent/component/answer.py", line 69, in stream_output
    for st in stream():
TypeError: 'NoneType' object is not callable
2025-06-12 12:46:03,278 INFO     25 192.168.200.105 - - [12/Jun/2025 12:46:03] "POST /api/v1/agents_openai/fda48fb6474711f0bec2c6548cceaca6/chat/completions HTTP/1.1" 200 -

@asiroliu
Copy link
Contributor

@Woody-Hu
Verified (ed7595b)
No Response Returned After API Call​

infiniflow@infiniflow168:~/workspace/python/8177$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/6fc9ff1c474e11f0aabeaee5c2cac8e2/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-g5NjM1NGQyNDc0ZTExZjBiNzNhYWVlNW' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "Say this is a test!"}],
        "stream": true
      }'
data: [DONE]

infiniflow@infiniflow168:~/workspace/python/8177$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/6fc9ff1c474e11f0aabeaee5c2cac8e2/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-g5NjM1NGQyNDc0ZTExZjBiNzNhYWVlNW' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "Who are you"}],
        "stream": true
      }'
data: [DONE]

infiniflow@infiniflow168:~/workspace/python/8177$ curl --request POST \
     --url http://192.168.200.234:9380/api/v1/agents_openai/6fc9ff1c474e11f0aabeaee5c2cac8e2/chat/completions \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer ragflow-g5NjM1NGQyNDc0ZTExZjBiNzNhYWVlNW' \
     --data '{
        "model": "model",
        "messages": [{"role": "user", "content": "1+1等于几"}],
        "stream": true
      }'
data: [DONE]
image

will not change the begin output
just modify the path
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 12, 2025
@asiroliu
Copy link
Contributor

@KevinHuSh
LGTM

@Woody-Hu
Verified (24283da)
image

@KevinHuSh KevinHuSh merged commit 1ab0f52 into infiniflow:main Jun 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0