The configured knowledge base has already been referenced in the prompt as context, why doesn't the system display it as linked to the application? #1059

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

Originally created by @koulas on GitHub (Feb 18, 2024).

Originally assigned to: @JohnJyong on GitHub.

Self Checks

Provide a description of the help you need

The configured knowledge base has already been referenced in the prompt as context, why doesn't the system display it as linked to the application?
image
image

Originally created by @koulas on GitHub (Feb 18, 2024). Originally assigned to: @JohnJyong on GitHub. ### 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)). ### Provide a description of the help you need The configured knowledge base has already been referenced in the prompt as context, why doesn't the system display it as linked to the application? ![image](https://github.com/langgenius/dify/assets/2045443/d9222054-8b15-4026-aac3-88dce30e5a27) ![image](https://github.com/langgenius/dify/assets/2045443/bfa3618c-7260-4a01-82bc-4bd00a30ce12)
yindo added the 🐞 bug label 2026-02-21 17:29:45 -05:00
yindo closed this issue 2026-02-21 17:29:45 -05:00
Author
Owner

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

🤖

Hey there, @koulas! Good to see you back around. How have things been on your end?

Based on the information you've provided, it seems like the system isn't displaying the configured knowledge base as linked to the application because the knowledge base isn't directly linked in the prompt configuration. The prompt configuration file you provided only includes placeholders for context and query, but it doesn't specify where the context is coming from.

The context is inserted into the prompt using the {{context}} placeholder, but the source of this context isn't specified in this file. If the context is supposed to come from a knowledge base, the system needs to be configured to pull this context from the correct knowledge base and insert it into the prompt.

If you've done this and it's still not working, there might be an issue with how the system is processing the context or a problem with the knowledge base itself. Without more information about how the system is configured to use the knowledge base and how the knowledge base is structured, it's difficult to provide a more specific answer.

In terms of how the knowledge base is linked to the application in the dify codebase, it's done through the use of a React component. This component is defined in the file Knowledge.tsx and it uses an IconBase component to display an icon. The data for the icon is imported from a JSON file named Knowledge.json.

Here's the relevant code:

import * as React from 'react'
import data from './Knowledge.json'
import IconBase from '@/app/components/base/icons/IconBase'
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'

const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
  props,
  ref,
) => <IconBase {...props} ref={ref} data={data as IconData} />)

Icon.displayName = 'Knowledge'

export default Icon

In this code, Icon is a React component that uses the IconBase component to display the knowledge base icon. The data for the icon is passed to the IconBase component as a prop.

You can find this code in the Knowledge.tsx file.

I hope this helps! If you need further clarification or have more information that could help me provide a more specific answer, please let me know.

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.

@dosubot[bot] commented on GitHub (Feb 18, 2024): _🤖_ <!-- Greeting --> Hey there, @koulas! Good to see you back around. How have things been on your end? <!-- Answer --> Based on the information you've provided, it seems like the system isn't displaying the configured knowledge base as linked to the application because the knowledge base isn't directly linked in the prompt configuration. The prompt configuration file you provided only includes placeholders for context and query, but it doesn't specify where the context is coming from. The context is inserted into the prompt using the `{{context}}` placeholder, but the source of this context isn't specified in this file. If the context is supposed to come from a knowledge base, the system needs to be configured to pull this context from the correct knowledge base and insert it into the prompt. If you've done this and it's still not working, there might be an issue with how the system is processing the context or a problem with the knowledge base itself. Without more information about how the system is configured to use the knowledge base and how the knowledge base is structured, it's difficult to provide a more specific answer. In terms of how the knowledge base is linked to the application in the dify codebase, it's done through the use of a React component. This component is defined in the file `Knowledge.tsx` and it uses an IconBase component to display an icon. The data for the icon is imported from a JSON file named `Knowledge.json`. Here's the relevant code: ```tsx import * as React from 'react' import data from './Knowledge.json' import IconBase from '@/app/components/base/icons/IconBase' import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase' const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>(( props, ref, ) => <IconBase {...props} ref={ref} data={data as IconData} />) Icon.displayName = 'Knowledge' export default Icon ``` In this code, `Icon` is a React component that uses the `IconBase` component to display the knowledge base icon. The data for the icon is passed to the `IconBase` component as a prop. You can find this code in the [Knowledge.tsx](https://github.com/langgenius/dify/blob/main/web/app/components/base/icons/src/public/header-nav/knowledge/Knowledge.tsx) file. I hope this helps! If you need further clarification or have more information that could help me provide a more specific answer, please let me know. ## Sources - [配置了上下文,提问方式换一下,就无法命中上下文](https://github.com/langgenius/dify/issues/2327) - [开启【引用和归属】功能后,来自知识库的回答无法标记来源](https://github.com/langgenius/dify/issues/2295) - [加了知识库后,要如何配置提示词才能正确调用知识库,现在提示:上下文内容块缺失,提示词的有效性可能不好](https://github.com/langgenius/dify/issues/2203) - [api/core/prompt/generate_prompts/common_completion.json](https://github.com/langgenius/dify/blob/main/api/core/prompt/generate_prompts/common_completion.json) - [web/app/components/base/icons/src/public/header-nav/knowledge/Knowledge.tsx](https://github.com/langgenius/dify/blob/main/web/app/components/base/icons/src/public/header-nav/knowledge/Knowledge.tsx) <!-- Dosu Comment Footer --> <details open> <summary> #### About Dosu </summary> 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. </details>
Author
Owner

@takatost commented on GitHub (Feb 18, 2024):

@JohnJyong pls check it out.

@takatost commented on GitHub (Feb 18, 2024): @JohnJyong pls check it out.
Author
Owner

@JohnJyong commented on GitHub (Feb 19, 2024):

@koulas it has fixed by #2479 ,thanks for your feedback

@JohnJyong commented on GitHub (Feb 19, 2024): @koulas it has fixed by #2479 ,thanks for your feedback
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1059