AI-Powered Chat

Chat

Discover how Cody's Chat feature provides contextually-aware answers and code suggestions, enhancing your coding workflow.

Cody's Chat feature allows you to interact with AI to ask questions about your code, generate new code snippets, and refactor existing code. It leverages context from your open files and repository to provide accurate and relevant responses.

Versatile Assistance

Get help with code understanding, generation, and editing

Context-Aware Responses

Answers are informed by your codebase for better accuracy

How Chat Works

Cody's Chat uses a sophisticated approach to provide you with the best possible assistance:

  • Codebase Search

    Cody searches your codebase using Sourcegraph's native search and keyword search to find relevant context.

  • Contextual Understanding

    By understanding the context, Cody provides informed responses specific to your project.

  • Informative Responses

    Cody indicates which code files it has analyzed to generate its responses, ensuring transparency.

Key Features

Default Context

Automatic context chips for opened file and repository in new chats.

Custom Context

Add context using @-mentions: repositories, files, symbols, and line ranges.

OpenCtx Support

Experimental support for fetching context from web URLs and non-code artifacts.

Offline Mode

Experimental offline chat via Ollama, no Sourcegraph account needed.

LLM Selection

Choose between different LLMs for chat, optimized for speed or accuracy.

Smart Apply

Dynamically insert code from chat into your files with intelligent placement.

Chat History

View, export, and clear your chat history for session management.

Quick Prompts

Ready-to-use prompts for common coding actions.

Code Generation Example

See how Cody can write code for you. In VS Code, ask Cody to "write a function that sorts an array in ascending order."

Prompt
Write a function that sorts an array in ascending order

Cody provides code suggestions directly in the chat window, offering options to:

  • Copy code to clipboard
  • Insert code at cursor
  • Save code to a new file
Interactive Example

Live Chat Demo

Interact with the embedded chat demo below to experience Cody's chat capabilities firsthand.

Try asking questions about code or requesting code generation.

Cody Smart Apply Example

Improving Cody's Answers

If Cody's initial response isn't quite right, refine your approach:

  • Use Public Knowledge Only: Limit context to general model knowledge for broader queries.
  • Focus on Current File: Restrict context to the open file for file-specific questions.
  • Add Specific Context: Utilize @-mentions to include relevant files, symbols, or external resources for more precise answers.

Explore More