get_suggested_questions_after_answer return diffrent data struct
Self Checks
- [X] This is only for bug report, if you would like to ask a quesion, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] Pleas do not modify this template :) and fill in all the required fields.
Dify version
0.6.7
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
/installed-apps/uuid:installed_app_id/messages/uuid:message_id/suggested-questions:
✔️ Expected Behavior
same data struct
❌ Actual Behavior
different structure
The discrepancy you're observing with the get_suggested_questions_after_answer function returning a different data structure than expected is due to its design in Dify version 0.6.7. This function is intended to return an array of objects, each with a "question" key, rather than a simple array of strings. This approach allows for handling rich metadata associated with each question, which can include identifiers, timestamps, or additional attributes relevant to the application's logic.
The underlying method, LLMGenerator.generate_suggested_questions_after_answer, is designed to produce a list of Message objects. These objects are more complex than plain strings, providing enhanced flexibility and functionality within the system's architecture. The design choice supports the platform's requirements for rich data handling, which is why you're seeing an array of objects instead of strings.
If you're encountering issues or need further clarification on handling the returned data structure from this function, it might be helpful to review the related components in the Dify codebase, such as ModelManager.get_default_model_instance, PromptTemplateParser.format, and SuggestedQuestionsAfterAnswerOutputParser.parse. These components could influence the output of the get_suggested_questions_after_answer function and provide insight into managing the data structure effectively.
Understanding this design choice and how it integrates with the broader system architecture can help in adjusting your expectations or implementation to work with the data structure as returned by the function. If you have further questions or require additional assistance, feel free to ask.
Details
Sources
- api/services/message_service.py
- api/core/llm_generator/llm_generator.py
- api/core/llm_generator/output_parser/suggested_questions_after_answer.py
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.
To continue the conversation, mention @dosu.