mirror of
https://github.com/coder/coder.git
synced 2026-11-06 08:12:45 +08:00
This PR merges code from `coder/aibridge` repository into `coder/coder`. It was split into 4 PRs for easier review but stacked PRs will need to be merged into this PR so all checks pass. * https://github.com/coder/coder/pull/24190 -> raw code copy (this PR, before merging PRs on top of it, it was just 1 commit: https://github.com/coder/coder/commit/70d33f33200c7e77df910957595715f81f9bec24) * https://github.com/coder/coder/pull/24570 -> update imports in `coder/coder` to use copied code * https://github.com/coder/coder/pull/24586 -> linter fixes and CI integration (also added README.md) * https://github.com/coder/coder/pull/24571 -> added exclude to scripts/check_emdash.sh check Original PR message (before PR squash): Moves coder/aibridge code into coder/coder repository. Omitted files: - `go.mod`, `go.sum`, `.gitignore`, `.github/workflows/ci.yml,` `Makefile`, `LICENSE`, `README.md` (modified README.md is added later) - `.github`, `example`, `buildinfo,` `scripts` directories Simple verification script (will list omitted files) ``` tmp=$(mktemp -d) echo "$tmp" git clone --depth=1 https://github.com/coder/aibridge "$tmp/aibridge" git clone --depth=1 --branch pb/aibridge-code-move https://github.com/coder/coder "$tmp/coder" diff -rq --exclude=.git "$tmp/aibridge" "$tmp/coder/aibridge" # rm -rf "$tmp" ```
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package integrationtest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"cdr.dev/slog/v3"
|
|
"cdr.dev/slog/v3/sloggers/slogtest"
|
|
"github.com/coder/coder/v2/aibridge/config"
|
|
"github.com/coder/coder/v2/aibridge/recorder"
|
|
)
|
|
|
|
// anthropicCfg creates a minimal Anthropic config for testing.
|
|
func anthropicCfg(url string, key string) config.Anthropic {
|
|
return config.Anthropic{
|
|
BaseURL: url,
|
|
Key: key,
|
|
}
|
|
}
|
|
|
|
func anthropicCfgWithAPIDump(url string, key string, dumpDir string) config.Anthropic {
|
|
cfg := anthropicCfg(url, key)
|
|
cfg.APIDumpDir = dumpDir
|
|
return cfg
|
|
}
|
|
|
|
// bedrockCfg returns a test AWS Bedrock config pointing at the given URL.
|
|
func bedrockCfg(url string) *config.AWSBedrock {
|
|
return &config.AWSBedrock{
|
|
Region: "us-west-2",
|
|
AccessKey: "test-access-key",
|
|
AccessKeySecret: "test-secret-key",
|
|
Model: "beddel", // This model should override the request's given one.
|
|
SmallFastModel: "modrock", // Unused but needed for validation.
|
|
BaseURL: url,
|
|
}
|
|
}
|
|
|
|
// openAICfg creates a minimal OpenAI config for testing.
|
|
func openAICfg(url string, key string) config.OpenAI {
|
|
return config.OpenAI{
|
|
BaseURL: url,
|
|
Key: key,
|
|
}
|
|
}
|
|
|
|
func openaiCfgWithAPIDump(url string, key string, dumpDir string) config.OpenAI {
|
|
cfg := openAICfg(url, key)
|
|
cfg.APIDumpDir = dumpDir
|
|
return cfg
|
|
}
|
|
|
|
// newLogger creates a test logger at Debug level.
|
|
func newLogger(t *testing.T) slog.Logger {
|
|
t.Helper()
|
|
return slogtest.Make(t, &slogtest.Options{}).Leveled(slog.LevelDebug)
|
|
}
|
|
|
|
func newModelThought(content, source string) recorder.ModelThoughtRecord {
|
|
return recorder.ModelThoughtRecord{
|
|
Content: content,
|
|
Metadata: recorder.Metadata{
|
|
"source": source,
|
|
},
|
|
}
|
|
}
|