Skip to content
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

api request error #2908

Closed
3 tasks done
m5314 opened this issue Mar 20, 2024 · 2 comments
Closed
3 tasks done

api request error #2908

m5314 opened this issue Mar 20, 2024 · 2 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@m5314
Copy link

m5314 commented Mar 20, 2024

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.5.9

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

I already requested the chat-message api once, and I got a message-id . But when I request the suggested api it returned 404
curl -X POST 'http://127.0.0.1:5001/v1/chat-messages' \ --header 'Authorization: Bearer app-W7VONpikFmcEnMinBTUhua8K' \ --header 'Content-Type: application/json' \ --data-raw '{ "inputs": {}, "query": "What are the specs of the iPhone 13 Pro Max?", "response_mode": "streaming", "conversation_id": "", "user": "abc-123", "files": [ { "type": "image", "transfer_method": "remote_url", "url": "https://cloud.dify.ai/logo/logo-site.png" } ] }'
data: {"event": "message_end", "task_id": "535bf32f-338b-40e0-993b-aa9e85a10d55", "id": "cd9d7a95-5ab7-4aac-8e6e-7652d671c485", "message_id": "cd9d7a95-5ab7-4aac-8e6e-7652d671c485", "conversation_id": "5fcd73b6-0e4a-486b-8d28-bd23b75c0b6f", "metadata": {"usage": {"prompt_tokens": 228, "prompt_unit_price": "0.01", "prompt_price_unit": "0.001", "prompt_price": "0.0022800", "completion_tokens": 69, "completion_unit_price": "0.03", "completion_price_unit": "0.001", "completion_price": "0.0020700", "total_tokens": 297, "total_price": "0.0043500", "currency": "USD", "latency": 3.853132416988956}}}

curl 'http://127.0.0.1:5001/v1/messages/cd9d7a95-5ab7-4aac-8e6e-7652d671c485/suggested' --header 'Authorization: Bearer app-W7VONpikFmcEnMinBTUhua8K' --header 'Content-Type: application/json'
{ "code": "not_found", "message": "Message Not Exists.", "status": 404 }

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

@m5314 m5314 added the 🐞 bug Something isn't working label Mar 20, 2024
Copy link

dosubot bot commented Mar 20, 2024

Hey there @m5314! Great to see you back in the digital trenches with us. 🚀

Based on the information you've provided, it seems like you're encountering a "Message Not Exists" error when trying to request the suggested API after successfully getting a message-id from the chat-message API in Dify version 0.5.9. This error could be due to several reasons:

  1. Message ID Not Found in Database: The error is explicitly raised when the MessageService or CompletionService cannot find the message with the provided message_id. This could mean that the message ID you are using to make the request does not exist in the database or is not accessible by the current user.

  2. Incorrect API Endpoint or HTTP Method: Ensure that the request is made to the correct API endpoint and with the correct HTTP method (GET or POST). Using an incorrect endpoint or method could lead to a 404 error.

  3. Invalid Message ID Format: The endpoints expect the message_id to be in UUID format. If the format of the message_id provided in the request does not match the expected UUID format, Flask might not correctly route the request, potentially leading to a 404 error.

  4. App Mode Mismatch: For MessageMoreLikeThisApi and MessageSuggestedQuestionApi, there are checks for the app's mode (chat or completion). If the app's mode does not match the expected mode for the API being called, it will not proceed with fetching the message or suggested questions, although this would typically result in a different error than "Message Not Exists."

To resolve the issue, ensure that:

  • The message_id exists and is accessible by the current user.
  • The request is made to the correct endpoint with the correct HTTP method.
  • The message_id is in the correct UUID format.
  • The app's mode matches the expected mode for the API being called.

If all the above conditions are met and the error persists, it might be necessary to debug further by checking the implementation of the MessageService and CompletionService methods being called, ensuring they correctly handle the message_id and have access to the necessary data.

You can find more details about this in the api/controllers/console/explore/message.py file.

I hope this helps! If you have any more questions or need further clarification, feel free to ask.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@takatost
Copy link
Collaborator

takatost commented Mar 20, 2024

Sorry about that, we forgot to mention the user Query Param in the API documentation. We'll have that corrected ASAP.
cc @iamjoel

@iamjoel iamjoel closed this as completed Mar 20, 2024
@dosubot dosubot bot mentioned this issue May 23, 2024
4 tasks
@dosubot dosubot bot mentioned this issue Sep 20, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants