The robotic assistant answers questions it is unfamiliar with, why does it still display the source? #1016

Closed
opened 2026-02-21 17:29:30 -05:00 by yindo · 2 comments
Owner

Originally created by @andylzming on GitHub (Feb 1, 2024).

Self Checks

Dify version

0.5.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  • The robotic assistant answers questions it is unfamiliar with, why does it still display the source?
  • Additionally, the response will also display the question that was asked.

1

  • The programming mode uses the expert mode, with the following related prompts.

2

`Use the following context as your learned knowledge, inside XML tags.

{{#context#}} 如果用户提出的问题中包含查询电量,请根据用户户号、起止日期调用{{dianliang_api}}工具进行用户用电量查询。

When answer to user:

  • If you don't know, just say that you don't know.不显示引用。
  • If you don't know when you are not sure, ask for clarification.不显示引用。
    Avoid mentioning that you obtained the information from the context.
    And answer according to the language of the user's question.`

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @andylzming on GitHub (Feb 1, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to file this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). ### Dify version 0.5.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce - The robotic assistant answers questions it is unfamiliar with, why does it still display the source? - Additionally, the response will also display the question that was asked. ![1](https://github.com/langgenius/dify/assets/21255047/260b5850-4d18-49cc-92ca-a7c96071ec71) - The programming mode uses the expert mode, with the following related prompts. ![2](https://github.com/langgenius/dify/assets/21255047/a3ea5be4-6b34-4139-9c25-609775250943) `Use the following context as your learned knowledge, inside <context></context> XML tags. <context> {{#context#}} </context> <context> 如果用户提出的问题中包含查询电量,请根据用户户号、起止日期调用{{dianliang_api}}工具进行用户用电量查询。 </context> When answer to user: - If you don't know, just say that you don't know.不显示引用。 - If you don't know when you are not sure, ask for clarification.不显示引用。 Avoid mentioning that you obtained the information from the context. And answer according to the language of the user's question.` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 17:29:30 -05:00
yindo closed this issue 2026-02-21 17:29:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 1, 2024):

🤖

Hey there @andylzming! Great to see you back with us. Hope you're doing awesome! 🚀

The behavior you're observing is due to the configuration of the Dify application. There is a property named show_retrieve_source in the code, which is set to True if the retriever_resource is enabled in the application configuration. This property controls whether the source and asked question are displayed when the assistant answers questions it is unfamiliar with.

Here is the relevant code:

# show retrieve source
show_retrieve_source = False
retriever_resource_dict = copy_app_model_config_dict.get('retriever_resource')
if retriever_resource_dict:
    if 'enabled' in retriever_resource_dict and retriever_resource_dict['enabled']:
        show_retrieve_source = True

This code is located in the api/core/application_manager.py file.

The show_retrieve_source property is used in the retrieve method of the DatasetRetrievalFeature class, where it is passed to the to_dataset_retriever_tool method as return_resource. If return_resource is True, the source of the retrieved data will be included in the returned result. If return_resource is False, the source of the retrieved data will not be included in the returned result.

Here is the relevant code:

tool = DatasetRetrieverTool.from_dataset(
    dataset=dataset,
    top_k=top_k,
    score_threshold=score_threshold,
    hit_callbacks=[hit_callback],
    return_resource=return_resource,
    retriever_from=invoke_from.to_source()
)

tool = DatasetMultiRetrieverTool.from_dataset(
    dataset_ids=[dataset.id for dataset in available_datasets],
    tenant_id=tenant_id,
    top_k=retrieve_config.top_k or 2,
    score_threshold=retrieve_config.score_threshold,
    hit_callbacks=[hit_callback],
    return_resource=return_resource,
    retriever_from=invoke_from.to_source(),
    reranking_provider_name=retrieve_config.reranking_model.get('reranking_provider_name'),
    reranking_model_name=retrieve_config.reranking_model.get('reranking_model_name')
)

This code is located in the api/core/features/dataset_retrieval.py file.

As for how to modify the show_retrieve_source property in the Dify application configuration, I wasn't able to find a direct answer within the repository. It's possible that this property is set in a configuration file or through an environment variable, but without more information, I can't provide a definitive answer. If you have more details about your setup or specific configuration files, I might be able to provide a more accurate answer.

Please note that I'm unable to view the image you've attached as I can't process images. If there's any important information in the image, could you please describe it in text form?

Sources


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.

@dosubot[bot] commented on GitHub (Feb 1, 2024): _🤖_ <!-- Greeting --> Hey there @andylzming! Great to see you back with us. Hope you're doing awesome! 🚀 <!-- Answer --> The behavior you're observing is due to the configuration of the Dify application. There is a property named `show_retrieve_source` in the code, which is set to `True` if the `retriever_resource` is enabled in the application configuration. This property controls whether the source and asked question are displayed when the assistant answers questions it is unfamiliar with. Here is the relevant code: ```py # show retrieve source show_retrieve_source = False retriever_resource_dict = copy_app_model_config_dict.get('retriever_resource') if retriever_resource_dict: if 'enabled' in retriever_resource_dict and retriever_resource_dict['enabled']: show_retrieve_source = True ``` This code is located in the [api/core/application_manager.py](https://github.com/langgenius/dify/blob/main/api/core/application_manager.py) file. The `show_retrieve_source` property is used in the `retrieve` method of the `DatasetRetrievalFeature` class, where it is passed to the `to_dataset_retriever_tool` method as `return_resource`. If `return_resource` is `True`, the source of the retrieved data will be included in the returned result. If `return_resource` is `False`, the source of the retrieved data will not be included in the returned result. Here is the relevant code: ```py tool = DatasetRetrieverTool.from_dataset( dataset=dataset, top_k=top_k, score_threshold=score_threshold, hit_callbacks=[hit_callback], return_resource=return_resource, retriever_from=invoke_from.to_source() ) tool = DatasetMultiRetrieverTool.from_dataset( dataset_ids=[dataset.id for dataset in available_datasets], tenant_id=tenant_id, top_k=retrieve_config.top_k or 2, score_threshold=retrieve_config.score_threshold, hit_callbacks=[hit_callback], return_resource=return_resource, retriever_from=invoke_from.to_source(), reranking_provider_name=retrieve_config.reranking_model.get('reranking_provider_name'), reranking_model_name=retrieve_config.reranking_model.get('reranking_model_name') ) ``` This code is located in the [api/core/features/dataset_retrieval.py](https://github.com/langgenius/dify/blob/main/api/core/features/dataset_retrieval.py) file. As for how to modify the `show_retrieve_source` property in the Dify application configuration, I wasn't able to find a direct answer within the repository. It's possible that this property is set in a configuration file or through an environment variable, but without more information, I can't provide a definitive answer. If you have more details about your setup or specific configuration files, I might be able to provide a more accurate answer. Please note that I'm unable to view the image you've attached as I can't process images. If there's any important information in the image, could you please describe it in text form? ## Sources - [api/core/application_manager.py](https://github.com/langgenius/dify/blob/main/api/core/application_manager.py) - [api/core/features/dataset_retrieval.py](https://github.com/langgenius/dify/blob/main/api/core/features/dataset_retrieval.py) --- 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.
Author
Owner

@crazywoola commented on GitHub (Feb 1, 2024):

Try turn this on, answer below this value won't be retrieved.
image

@crazywoola commented on GitHub (Feb 1, 2024): Try turn this on, answer below this value won't be retrieved. <img width="583" alt="image" src="https://github.com/langgenius/dify/assets/100913391/398dbf27-f5cf-44c4-b509-59c5670fa6c6">
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1016