-
Notifications
You must be signed in to change notification settings - Fork 974
feat(coderd): generate task names based on their prompt #19335
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(coderd): generate task names based on their prompt #19335
Conversation
Generate the name of a task by querying an LLM
coderd/taskname/taskname.go
Outdated
} | ||
|
||
return aisdk.AnthropicToDataStream(client.Messages.NewStreaming(ctx, anthropic.MessageNewParams{ | ||
Model: anthropic.ModelClaude3_5HaikuLatest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be deprecated at some point in future based on https://docs.anthropic.com/en/docs/about-claude/model-deprecations#deprecation-history
I would suggest we allow reading from ANTHROPIC_MODEL
. This will also allow administrators to choose a different model if they prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me 👍 In that case, we should probably default to a newer model then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haiku is cheap though! For something like this it seems to be "good enough"
coderd/taskname/taskname.go
Outdated
}, | ||
} | ||
|
||
if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: allow passing in func(key string) string
for testing / mocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using an env, should we provide API key as argument to the function? Would solve the testing aspect.
Fine to have another exported function like GetAnthropicAPIKeyFromEnv
in this package too that can be used at the call-site to avoid magic strings and os.Getenv
.
coderd/taskname/taskname.go
Outdated
|
||
stream, err := anthropicDataStream(ctx, anthropicClient, conversation) | ||
if err != nil { | ||
return fallback, xerrors.Errorf("create anthropic data stream: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Returning a value and error is not common practice and may be surprising to the reader. The way fallback is used here it would make sense to either return error or provide the fallback, but not both. Perhaps returning empty strings in all fallback cases and handling it at the call-site would be preferable?
coderd/taskname/taskname.go
Outdated
- "Set up CI/CD pipeline" → "task-setup-cicd-44" | ||
|
||
If you cannot create a suitable name: | ||
- Respond with "task-workspace" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Respond with "task-workspace" | |
- Respond with "task-unnamed" |
Suggestion to decouple this from workspaces, if possible.
coderd/taskname/taskname.go
Outdated
}, | ||
} | ||
|
||
if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using an env, should we provide API key as argument to the function? Would solve the testing aspect.
Fine to have another exported function like GetAnthropicAPIKeyFromEnv
in this package too that can be used at the call-site to avoid magic strings and os.Getenv
.
Closes #18159
If an Anthropic API key is available, we call out to Claude to generate a task name based on the user-provided prompt instead of our random name generator.
A question I have: Should we have an option to disable this even with an API key present? Or should we make this feature opt in even with an API key being present?