Files
ragflow/conf/models/anthropic.json

118 lines
2.0 KiB
JSON
Raw Normal View History

Add Anthropic Go model provider (#14940) ### What problem does this PR solve? Adds the missing Anthropic provider implementation for the Go model provider layer. Closes #14939 ### What changed - Add `conf/models/anthropic.json` with Anthropic Claude chat/vision models and API endpoints. - Add `internal/entity/models/anthropic.go` implementing non-streaming Messages API chat, model listing, and connection checking. - Register `anthropic` in the Go model factory. - Add httptest coverage for headers, payload mapping, response parsing, validation errors, provider errors, model listing, connection checking, factory registration, and unsupported methods. ### Notes Streaming chat is left as an explicit `no such method` follow-up because this initial provider focuses on non-streaming chat and connection checking. ### Tests - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity/models -run Anthropic -count=1 -v` - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity -count=1` - `git diff --check` - `jq . conf/models/anthropic.json >/dev/null` Plain `go test ./internal/entity/models` currently hits pre-existing unrelated vet findings in other provider files (`baidu.go`, `cohere.go`, `fishaudio.go`, `openrouter.go`). --------- Co-authored-by: Jin Hai <haijin.chn@gmail.com>
2026-05-17 18:03:33 -10:00
{
"name": "Anthropic",
"url": {
"default": "https://api.anthropic.com"
},
"url_suffix": {
"chat": "v1/messages",
"models": "v1/models"
},
"class": "anthropic",
"models": [
{
"name": "claude-opus-4-8",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-opus-4-7",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-opus-4-6",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
Add Anthropic Go model provider (#14940) ### What problem does this PR solve? Adds the missing Anthropic provider implementation for the Go model provider layer. Closes #14939 ### What changed - Add `conf/models/anthropic.json` with Anthropic Claude chat/vision models and API endpoints. - Add `internal/entity/models/anthropic.go` implementing non-streaming Messages API chat, model listing, and connection checking. - Register `anthropic` in the Go model factory. - Add httptest coverage for headers, payload mapping, response parsing, validation errors, provider errors, model listing, connection checking, factory registration, and unsupported methods. ### Notes Streaming chat is left as an explicit `no such method` follow-up because this initial provider focuses on non-streaming chat and connection checking. ### Tests - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity/models -run Anthropic -count=1 -v` - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity -count=1` - `git diff --check` - `jq . conf/models/anthropic.json >/dev/null` Plain `go test ./internal/entity/models` currently hits pre-existing unrelated vet findings in other provider files (`baidu.go`, `cohere.go`, `fishaudio.go`, `openrouter.go`). --------- Co-authored-by: Jin Hai <haijin.chn@gmail.com>
2026-05-17 18:03:33 -10:00
{
"name": "claude-opus-4-5-20251101",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-opus-4-1-20250805",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-opus-4-20250514",
"max_tokens": 128000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-sonnet-4-6",
"max_tokens": 64000,
"model_types": [
"chat",
"vision"
]
},
Add Anthropic Go model provider (#14940) ### What problem does this PR solve? Adds the missing Anthropic provider implementation for the Go model provider layer. Closes #14939 ### What changed - Add `conf/models/anthropic.json` with Anthropic Claude chat/vision models and API endpoints. - Add `internal/entity/models/anthropic.go` implementing non-streaming Messages API chat, model listing, and connection checking. - Register `anthropic` in the Go model factory. - Add httptest coverage for headers, payload mapping, response parsing, validation errors, provider errors, model listing, connection checking, factory registration, and unsupported methods. ### Notes Streaming chat is left as an explicit `no such method` follow-up because this initial provider focuses on non-streaming chat and connection checking. ### Tests - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity/models -run Anthropic -count=1 -v` - `docker run --rm -v /home/ubuntu/Documents/gitTensor_repos/carlos/ragflow:/work -v /tmp/ragflow-go-cache:/go/pkg/mod -v /tmp/ragflow-go-build:/root/.cache/go-build -w /work golang:1.25 go test -vet=off ./internal/entity -count=1` - `git diff --check` - `jq . conf/models/anthropic.json >/dev/null` Plain `go test ./internal/entity/models` currently hits pre-existing unrelated vet findings in other provider files (`baidu.go`, `cohere.go`, `fishaudio.go`, `openrouter.go`). --------- Co-authored-by: Jin Hai <haijin.chn@gmail.com>
2026-05-17 18:03:33 -10:00
{
"name": "claude-sonnet-4-5-20250929",
"max_tokens": 64000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-sonnet-4-20250514",
"max_tokens": 64000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-haiku-4-5-20251001",
"max_tokens": 64000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-3-7-sonnet-20250219",
"max_tokens": 64000,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-3-5-sonnet-20241022",
"max_tokens": 8192,
"model_types": [
"chat",
"vision"
]
},
{
"name": "claude-3-5-haiku-20241022",
"max_tokens": 8192,
"model_types": [
"chat",
"vision"
]
}
]
}