feat(provider): AI 渠道 - 新增 Atlas Cloud Chat 协议插件 (#445)
Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com> Co-authored-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com>
This commit is contained in:
1 parent
5ed480a8b0
commit
117c653bc8
6 files changed
+639
No files matched your search
@@ -86,6 +86,41 @@ func TestOfficialProtocolPackagesAreSelfContainedDeclarativePlugins(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
func TestOfficialAtlasCloudChatProfile(t *testing.T) {
|
||||
data, err := os.ReadFile(filepath.Join("..", "..", "..", "plugin-packages", "atlascloud-chat.yingce-plugin"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pkg, err := ParsePluginPackage(data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider := pkg.Manifest.Contributes.Providers[0]
|
||||
if provider.ID != "atlascloud-chat" || provider.BaseURL != "https://api.atlascloud.ai" || provider.Auth.Type != "bearer" {
|
||||
t.Fatalf("Atlas Cloud provider metadata = %#v", provider)
|
||||
}
|
||||
|
||||
adapter := officialPackageAdapter(t, "atlascloud-chat.yingce-plugin", "atlascloud-chat")
|
||||
spec, err := adapter.BuildCreate(context.Background(), RequestContext{Request: GenerationRequest{
|
||||
Model: "openai/gpt-5.6-luna",
|
||||
Messages: []Message{{Role: "user", Content: "hello"}},
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := manifestTestBody(t, spec)
|
||||
if spec.Method != "POST" || spec.Path != "/v1/chat/completions" || body["model"] != "openai/gpt-5.6-luna" {
|
||||
t.Fatalf("Atlas Cloud request = %#v, body = %#v", spec, body)
|
||||
}
|
||||
result, err := adapter.ParseCreate(context.Background(), []byte(`{"choices":[{"message":{"content":"atlas ok"}}],"usage":{"total_tokens":3}}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.Status != StatusSucceeded || result.Result == nil || result.Result.Text != "atlas ok" {
|
||||
t.Fatalf("Atlas Cloud response = %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func assertManifestContractMatchesPackage(t *testing.T, packageName string, manifestRaw []byte, interfaceDocs string) {
|
||||
t.Helper()
|
||||
start := strings.Index(interfaceDocs, manifestContractStart)
|
||||
|
||||
Reference in new issue
Block a user