sourcebot/packages/web/src/features/chat
2025-07-23 12:03:44 -07:00
..
components feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
actions.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
agent.ts Add additional debug logs. Also fix build warning about environment variables 2025-07-23 12:03:44 -07:00
constants.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
customSlateEditor.tsx feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
README.md feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
tools.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
types.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useCreateNewChatThread.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useCustomSlateEditor.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useExtractReferences.test.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useExtractReferences.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useMessagePairs.test.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useMessagePairs.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useSelectedLanguageModel.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
useTOCItems.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
utils.test.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00
utils.ts feat: Ask Sourcebot (#392) 2025-07-23 11:25:15 -07:00

Sources and References

We have the concept of "sources" and "references" in sb:

  1. source - A source is some artifact that exists in the codebase (e.g., file, commit, etc.) that helps the LLM ground its answer in reality.
  2. references - A reference (or citation) is a pointer to a source that the LLM can output in it's response so that the developer can understand why the LLM got to the conclusion it got to.

Sources can be attached to a chat thread in two ways:

  1. The developer @ mentions a source (e.g., "what does @auth.ts do?") in their request.
  2. The LLM makes a tool call (e.g., readFile) in its response.

Sources are included in the chat thread using a custom data part as a JSON payload with the necessary data to allow us to retrieve the source at a later point (e.g., in ReferencedSourcesListView.tsx).

References are included in a LLMs response by embedding a known pattern (e.g., @file:{auth.ts:12-24}) that can be grepped and rendered with a custom component using a remark plugin. The LLM is instructed to use this pattern in the system prompt.

The process of resolving a reference to a source is inherently fuzzy since we are not guaranteed any determinism with LLMs (e.g., the LLM could hallucinate a source that doesn't exist). We perform reference resolution on a best-effort basis.