From 2587ea4a0b5d428ed3b2770abac8b349895f7da3 Mon Sep 17 00:00:00 2001 From: Ado Kukic Date: Tue, 5 Nov 2024 11:52:21 -0800 Subject: [PATCH 1/4] Hackathon - Context --- docs/cody/core-concepts/context.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/cody/core-concepts/context.mdx b/docs/cody/core-concepts/context.mdx index 59b2069aa..4e6edf3e0 100644 --- a/docs/cody/core-concepts/context.mdx +++ b/docs/cody/core-concepts/context.mdx @@ -1,3 +1,4 @@ + # Cody Context

Understand how context helps Cody write more accurate code.

From 92c7bdfdfb57bb93219ed6bb87c4335ef7990c73 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 5 Nov 2024 12:23:05 -0800 Subject: [PATCH 2/4] Edit comment format --- docs/cody/core-concepts/context.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/cody/core-concepts/context.mdx b/docs/cody/core-concepts/context.mdx index 4e6edf3e0..a48ee3b68 100644 --- a/docs/cody/core-concepts/context.mdx +++ b/docs/cody/core-concepts/context.mdx @@ -1,4 +1,5 @@ - +{/* Hackathon */} + # Cody Context

Understand how context helps Cody write more accurate code.

From b4a5787b457726e5f81ef0a44717203cbac3e4cd Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Thu, 14 Nov 2024 17:41:09 -0800 Subject: [PATCH 3/4] Rmv banner --- docs/cody/core-concepts/context.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/cody/core-concepts/context.mdx b/docs/cody/core-concepts/context.mdx index a48ee3b68..59b2069aa 100644 --- a/docs/cody/core-concepts/context.mdx +++ b/docs/cody/core-concepts/context.mdx @@ -1,5 +1,3 @@ -{/* Hackathon */} - # Cody Context

Understand how context helps Cody write more accurate code.

From 39a63f6222647465376584876b818a0bd9b7117f Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Thu, 14 Nov 2024 18:33:13 -0800 Subject: [PATCH 4/4] Add imporvements --- docs/cody/clients/install-jetbrains.mdx | 2 +- docs/cody/clients/install-vscode.mdx | 2 +- docs/cody/core-concepts/context.mdx | 42 ++++++++++++++++--------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/docs/cody/clients/install-jetbrains.mdx b/docs/cody/clients/install-jetbrains.mdx index 08c901d3f..66dd2218e 100644 --- a/docs/cody/clients/install-jetbrains.mdx +++ b/docs/cody/clients/install-jetbrains.mdx @@ -153,7 +153,7 @@ If Cody's answer isn't helpful, you can try asking again with a different contex ## Context fetching mechanism -JetBrains users on the Free or Pro plan use [local context](/cody/core-concepts/context#context-selection). +JetBrains users on the Free or Pro plan use [local context](/cody/core-concepts/context#context-sources). Enterprise users can leverage the full power of the Sourcegraph search engine as Cody's primary context provider. diff --git a/docs/cody/clients/install-vscode.mdx b/docs/cody/clients/install-vscode.mdx index 662aa0c14..8b8ddca9f 100644 --- a/docs/cody/clients/install-vscode.mdx +++ b/docs/cody/clients/install-vscode.mdx @@ -213,7 +213,7 @@ If Cody's answer isn't helpful, you can try asking again with different context: ## Context fetching mechanism -VS Code users on the Free or Pro plan use [local context](/cody/core-concepts/context#context-selection). +VS Code users on the Free or Pro plan use [local context](/cody/core-concepts/context#context-sources). Enterprise users can use the full power of the Sourcegraph search engine as Cody's primary context provider. diff --git a/docs/cody/core-concepts/context.mdx b/docs/cody/core-concepts/context.mdx index 59b2069aa..c0d9b3076 100644 --- a/docs/cody/core-concepts/context.mdx +++ b/docs/cody/core-concepts/context.mdx @@ -6,28 +6,43 @@ Context refers to any additional information provided to help Cody understand an ## Why is context important? -Context and [methods of retrieving context](#context-selection) are crucial to the quality and accuracy of AI. Cody relies on its ability to retrieve context from user codebases to provide reliable and accurate answers to developers’ questions. When Cody has access to the most relevant context about your codebase, it can: +Context and [methods of retrieving context](#context-sources) are crucial to the quality and accuracy of AI. Cody relies on its ability to retrieve context from user codebases to provide reliable and accurate answers to developers’ questions. When Cody has access to the most relevant context about your codebase, it can: - Answer questions about your codebase - Produce unit tests and docs - Generate code that aligns with the libraries and style of your codebase - Significantly reduce your work that's required to translate LLM-provided answers into actionable value for your users -## Context selection +## Context sources -Cody employs various methods to gather context relevant to user input, ensuring the quality of the information provided. These methods include: +Cody uses a variety of sources to retrieve context relevant to the user input. These sources include: -- **Keyword Search**: A traditional text search approach that finds keywords matching the user input. When needed, queries are automatically rewritten to include more relevant terms. -- **Sourcegraph Search**: Sourcegraph Search API. Queries are sent to the SG instance (managed or self-hosted), and search is done using the SG search stack. Relevant documents are returned to the user IDE for use by the LLM -- **Code Graph**: Analyzing the structure of the code, Cody examines how components are interconnected and used, finding context based on code elements' relationships +- **Keyword Search**: A traditional text-based search method that finds keywords matching the user input. When needed, queries are automatically rewritten to include more relevant terms. +- **Sourcegraph Search**: The powerful native Sourcegraph Search API. Queries are sent to the SG instance (managed or self-hosted), and search is done using the SG search stack. Relevant documents are returned to the user IDE for use by the LLM. +- **Code Graph**: Analyzing the structure of the code, Cody examines how components are interconnected and used, finding context based on code elements' relationships. All these methods collectively ensure Cody's ability to provide relevant and high-quality context to enhance your coding experience. -## Context fetching mechanism +## Cody context fetching features + +Cody uses @-mentions to retrieve context from your codebase. Inside the chat window, there is an `@` icon that you can click to select a context source. Alternatively, you can press `@` to open the context picker. + +Based on your Cody tier, you can @-mention the following: + +| **Tier** | **Client** | **Files** | **Symbols** | **Web URLs** | **Remote Files/Directories** | **OpenCtx** | +| -------------- | ------------- | --------- | ----------- | ------------ | ---------------------------- | ----------- | +| **Free/Pro** | VS Code | ✅ | ✅ | ✅ | ❌ | ✅ | +| | JetBrains | ✅ | ❌ | ✅ | ❌ | ❌ | +| | Visual Studio | ✅ | ✅ | ✅ | ❌ | ❌ | +| | Cody Web | ✅ | ✅ | ✅ | ❌ | ❌ | +| **Enterprise** | VS Code | ✅ | ✅ | ✅ | ✅ | ✅ | +| | JetBrains | ✅ | ❌ | ✅ | ✅ | ❌ | +| | Visual Studio | ✅ | ✅ | ✅ | ✅ | ✅ | +| | Cody Web | ✅ | ✅ | ✅ | ✅ | ❌ | -You can @-mention files, symbols, and web pages in Cody. Cody Enterprise also supports @-mentioning remote directories to search for context in a broader scope. Cody's experimental [OpenCtx](https://openctx.org) support adds more context sources, including Jira, Linear, Google Docs, Notion, and more. +## Repo-based context -Here's a detailed breakdown of the number of repositories supported by each client for Cody Free, Pro, and Enterprise users: +Cody supports repo-based context. You can link single or multiple repositories based on your tier. Here's a detailed breakdown of the number of repositories supported by each client for Cody Free, Pro, and Enterprise users: | **Tier** | **Client** | **Repositories** | | -------------- | ------------- | ---------------- | @@ -37,14 +52,11 @@ Here's a detailed breakdown of the number of repositories supported by each clie | **Enterprise** | Cody Web | Multi | | | VS Code | Multi | | | JetBrains | Multi | - -## Context sources - -You can @-mention files, symbols, and web pages in Cody. Cody Enterprise also supports @-mentioning repositories to search for context in a broader scope. Cody's experimental [OpenCtx](https://openctx.org) support adds more context sources, including Jira, Linear, Google Docs, Notion, and more. +| | Visual Studio | Multi | ## How does context work with Cody prompts? -Cody works in conjunction with an LLM to provide codebase-aware answers. The LLM is a machine learning model that generates text in response to natural language prompts. However, the LLM doesn't inherently understand your codebase or specific coding requirements. Cody bridges this gap by generating context-aware prompts. +Cody works in conjunction with an LLM to provide codebase-aware answers. The LLM is a machine learning model that generates text in response to natural language prompts. However, the LLM needs to inherently understand your codebase or specific coding requirements. Cody bridges this gap by generating context-aware prompts. A typical prompt has three parts: @@ -54,7 +66,7 @@ A typical prompt has three parts: ## Impact of context LLM vs Cody -When the same prompt is sent to a standard LLM, the response may lack specifics about your codebase. In contrast, Cody augments the prompt with context from relevant code snippets, making the answer far more specific to your codebase. This difference underscores the importance of context in Cody's functionality. +When the same prompt is sent to a standard LLM, the response may need more specifics about your codebase. In contrast, Cody augments the prompt with context from relevant code snippets, making the answer far more specific to your codebase. This difference underscores the importance of context in Cody's functionality. ## Manage Cody context window size