8000 chore: upgrade aisdk-go lib, remove vestigial code by dannykopping · Pull Request #18577 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: upgrade aisdk-go lib, remove vestigial code #18577

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

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: remove leftover pieces from #18535
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
  • Loading branch information
dannykopping committed Jun 25, 2025
commit 6e8245d1a7adeaa693f106419806ee090671d42e
71 changes: 0 additions & 71 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2624,77 +2624,6 @@ func redirectHTTPToHTTPSDeprecation(ctx context.Context, logger slog.Logger, inv
}
}

func ReadAIProvidersFromEnv(environ []string) ([]codersdk.AIProviderConfig, error) {
// The index numbers must be in-order.
sort.Strings(environ)

var providers []codersdk.AIProviderConfig
for _, v := range serpent.ParseEnviron(environ, "CODER_AI_PROVIDER_") {
tokens := strings.SplitN(v.Name, "_", 2)
if len(tokens) != 2 {
return nil, xerrors.Errorf("invalid env var: %s", v.Name)
}

providerNum, err := strconv.Atoi(tokens[0])
if err != nil {
return nil, xerrors.Errorf("parse number: %s", v.Name)
}

var provider codersdk.AIProviderConfig
switch {
case len(providers) < providerNum:
return nil, xerrors.Errorf(
"provider num %v skipped: %s",
len(providers),
v.Name,
)
case len(providers) == providerNum:
// At the next next provider.
providers = append(providers, provider)
case len(providers) == providerNum+1:
// At the current provider.
provider = providers[providerNum]
}

key := tokens[1]
switch key {
case "TYPE":
provider.Type = v.Value
case "API_KEY":
provider.APIKey = v.Value
case "BASE_URL":
provider.BaseURL = v.Value
case "MODELS":
provider.Models = strings.Split(v.Value, ",")
}
providers[providerNum] = provider
}
for _, envVar := range environ {
tokens := strings.SplitN(envVar, "=", 2)
if len(tokens) != 2 {
continue
}
switch tokens[0] {
case "OPENAI_API_KEY":
providers = append(providers, codersdk.AIProviderConfig{
Type: "openai",
APIKey: tokens[1],
})
case "ANTHROPIC_API_KEY":
providers = append(providers, codersdk.AIProviderConfig{
Type: "anthropic",
APIKey: tokens[1],
})
case "GOOGLE_API_KEY":
providers = append(providers, codersdk.AIProviderConfig{
Type: "google",
APIKey: tokens[1],
})
}
}
return providers, nil
}

// ReadExternalAuthProvidersFromEnv is provided for compatibility purposes with
// the viper CLI.
func ReadExternalAuthProvidersFromEnv(environ []string) ([]codersdk.ExternalAuthConfig, error) {
Expand Down
15 changes: 0 additions & 15 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3122,21 +3122,6 @@ Write out the current server config as YAML to stdout.`,
return opts
}

type AIProviderConfig struct {
// Type is the type of the API provider.
Type string `json:"type" yaml:"type"`
// APIKey is the API key to use for the API provider.
APIKey string `json:"-" yaml:"api_key"`
// Models is the list of models to use for the API provider.
Models []string `json:"models" yaml:"models"`
// BaseURL is the base URL to use for the API provider.
BaseURL string `json:"base_url" yaml:"base_url"`
}

type AIConfig struct {
Providers []AIProviderConfig `json:"providers,omitempty" yaml:"providers,omitempty"`
}

type SupportConfig struct {
Links serpent.Struct[[]LinkConfig] `json:"links" typescript:",notnull"`
}
Expand Down
3 changes: 2 additions & 1 deletion codersdk/toolsdk/toolsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"encoding/json"
"io"

"github.com/coder/aisdk-go"
"github.com/google/uuid"
"golang.org/x/xerrors"

"github.com/coder/aisdk-go"

"github.com/coder/coder/v2/codersdk"
)

Expand Down
2 changes: 2 additions & 0 deletions codersdk/toolsdk/toolsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/coder/aisdk-go"

"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbfake"
Expand Down
12 changes: 0 additions & 12 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0