Repository navigation
feat(coderd): generate task names based on their prompt - #19335
Conversation
Generate the name of a task by querying an LLM
| } | ||
|
|
||
| return aisdk.AnthropicToDataStream(client.Messages.NewStreaming(ctx, anthropic.MessageNewParams{ | ||
| Model: anthropic.ModelClaude3_5HaikuLatest, |
There was a problem hiding this comment.
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.
Sounds good to me 👍 In that case, we should probably default to a newer model then.
There was a problem hiding this comment.
Haiku is cheap though! For something like this it seems to be "good enough"
| }, | ||
| } | ||
|
|
||
| if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" { |
There was a problem hiding this comment.
suggestion: allow passing in func(key string) string for testing / mocking
There was a problem hiding this comment.
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.
|
|
||
| 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.
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?
| - "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.
| - Respond with "task-workspace" | |
| - Respond with "task-unnamed" |
Suggestion to decouple this from workspaces, if possible.
| }, | ||
| } | ||
|
|
||
| if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey == "" { |
There was a problem hiding this comment.
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?