Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chat): generate custom chat titles on first message automatically #7063

Merged
merged 10 commits into from
Feb 18, 2025

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Feb 12, 2025

CLOSE https://linear.app/sourcegraph/issue/SRCH-829 https://linear.app/sourcegraph/issue/CODY-4966

Automatically generate and display custom chat titles based on the first message in a conversation to improve chat history readability and navigation.

Loom: https://www.loom.com/share/ca36d5c26e024a15988ce8bd7751dd46?sid=6e0f88b1-4ff8-42c3-9c2c-ce5c91bffa71

Problem
Chat history currently shows the last message as the title, which may not be the best representation of the conversation's topic.

Implementation

  • Add setCustomChatTitle method to generate concise titles using a fast chat model
  • Update ChatBuilder to store and expose custom chat titles
  • Display custom chat titles in the History tab UI
  • Use fast chat model from model preferences for title generation
  • Fix model preference sync to use correct fastChat model for edit operations

Requires ChatTitleAutoGeneration feature flag.

Test plan

  1. Start a new chat conversation
  2. Submit first question
  3. Verify a custom title is generated for the question
  4. Check the history tab shows the custom title instead of the last message
  5. Verify titles are persisted between sessions

Examples

In Chat History:

image

  1. "create a new html file at the root of the codebase named "candle.html" , with css stylesheet to center the candle in the middle of the screen. The candel should also be created using css. There should also be a button at the bottom of the screen that is used for toggling between Dark mode and Light mode, and the candel would change color based on the mode." -> "Create HTML file with centered CSS candle and mode toggle"

image

  1. "Rename the PromptsTab component to PromptLibraryTab PromptsTab.tsx " -> "Rename PromptsTab to PromptLibraryTab in PromptsTab.tsx"

image

Automatically generate and display custom chat titles based on the first message in a conversation to improve chat history readability and navigation.

**Problem (why)**
Chat history currently shows the last message as the title, which may not be the best representation of the conversation's topic.

**Implementation (what)**
- Add `setCustomChatTitle` method to generate concise titles using a fast chat model
- Update ChatBuilder to store and expose custom chat titles
- Display custom chat titles in the History tab UI
- Use fast chat model from model preferences for title generation
- Fix model preference sync to use correct fastChat model for edit operations

**Test plan**

- Start a new chat conversation
- Submit first question
- Verify a custom title is generated for the question
- Check the history tab shows the custom title instead of the last message
- Verify titles are persisted between sessions
@abeatrix abeatrix requested review from umpox, hitesh-1997, julialeex and a team February 12, 2025 19:17
Copy link
Contributor

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the direction but I am concerned you're flipping the edits model to the fast model to do it.

lib/shared/src/models/modelsService.ts Outdated Show resolved Hide resolved
lib/shared/src/models/sync.ts Outdated Show resolved Hide resolved
vscode/src/chat/chat-view/ChatBuilder.ts Outdated Show resolved Hide resolved
vscode/src/chat/chat-view/ChatController.ts Outdated Show resolved Hide resolved
vscode/src/chat/chat-view/ChatController.ts Outdated Show resolved Hide resolved
vscode/src/chat/chat-view/ChatController.ts Outdated Show resolved Hide resolved
@abeatrix abeatrix requested review from dominiccooney and a team February 14, 2025 18:53
Copy link
Contributor

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for not changing the edits model.

model: fastModel,
maxTokensToSample: 100,
},
const prompt = ps`You are Cody, an AI coding assistant from Sourcegraph. Your task is to generate a concise title (<10 words without quotation) for <codyUserInput>${inputText}</codyUserInput>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gut feel we should say "about 10 words" instead of "<10 words" so we don't get titles apologizing for not begin able to do the task. But I claim this without hard evidence... just bitter experience.

@abeatrix abeatrix merged commit b9d4476 into main Feb 18, 2025
23 checks passed
@abeatrix abeatrix deleted the bee/auto-generate-chat-title branch February 18, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants