Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions 1 aibridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func newInterceptionProcessor(p provider.Provider, cbs *circuitbreaker.ProviderC
Model: interceptor.Model(),
Provider: p.Type(),
ProviderName: p.Name(),
ProviderID: p.ID().String(),
UserAgent: r.UserAgent(),
Client: string(client),
ClientSessionID: sessionID,
Expand Down
11 changes: 11 additions & 0 deletions 11 aibridge/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config
import (
"time"

"github.com/google/uuid"

"github.com/coder/coder/v2/aibridge/keypool"
)

Expand All @@ -25,6 +27,9 @@ const (
// fields into a single abstraction per
// https://github.com/coder/aibridge/issues/266.
type Anthropic struct {
// ID is the ai_providers row this provider was constructed from.
// uuid.Nil for legacy env-driven constructors and tests.
ID uuid.UUID
// Name is the provider instance name. If empty, defaults to "anthropic".
Name string
BaseURL string
Expand Down Expand Up @@ -61,6 +66,9 @@ type AWSBedrock struct {
// TODO(ssncferreira): consolidate the authentication fields per
// https://github.com/coder/aibridge/issues/266.
type OpenAI struct {
// ID is the ai_providers row this provider was constructed from.
// uuid.Nil for legacy env-driven constructors and tests.
ID uuid.UUID
// Name is the provider instance name. If empty, defaults to "openai".
Name string
BaseURL string
Expand All @@ -73,6 +81,9 @@ type OpenAI struct {
}

type Copilot struct {
// ID is the ai_providers row this provider was constructed from.
// uuid.Nil for legacy env-driven constructors and tests.
ID uuid.UUID
// Name is the provider instance name. If empty, defaults to "copilot".
Name string
BaseURL string
Expand Down
3 changes: 3 additions & 0 deletions 3 aibridge/internal/testutil/mockprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"

"github.com/google/uuid"
"go.opentelemetry.io/otel/trace"

"cdr.dev/slog/v3"
Expand All @@ -13,6 +14,7 @@ import (
)

type MockProvider struct {
IDValue uuid.UUID
NameStr string
URL string
Bridged []string
Expand All @@ -23,6 +25,7 @@ type MockProvider struct {

func (m *MockProvider) Type() string { return m.NameStr }
func (m *MockProvider) Name() string { return m.NameStr }
func (m *MockProvider) ID() uuid.UUID { return m.IDValue }
func (m *MockProvider) BaseURL() string { return m.URL }
func (m *MockProvider) RoutePrefix() string { return fmt.Sprintf("/%s", m.NameStr) }
func (m *MockProvider) BridgedRoutes() []string { return m.Bridged }
Expand Down
4 changes: 4 additions & 0 deletions 4 aibridge/provider/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func (p *Anthropic) Name() string {
return p.cfg.Name
}

func (p *Anthropic) ID() uuid.UUID {
return p.cfg.ID
}

func (p *Anthropic) RoutePrefix() string {
return fmt.Sprintf("/%s", p.Name())
}
Expand Down
4 changes: 4 additions & 0 deletions 4 aibridge/provider/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (p *Copilot) Name() string {
return p.cfg.Name
}

func (p *Copilot) ID() uuid.UUID {
return p.cfg.ID
}

func (p *Copilot) BaseURL() string {
return p.cfg.BaseURL
}
Expand Down
4 changes: 4 additions & 0 deletions 4 aibridge/provider/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (p *OpenAI) Name() string {
return p.cfg.Name
}

func (p *OpenAI) ID() uuid.UUID {
return p.cfg.ID
}

func (p *OpenAI) RoutePrefix() string {
// Route prefix includes version to match default OpenAI base URL.
// More detailed explanation: https://github.com/coder/aibridge/pull/174#discussion_r2782320152
Expand Down
5 changes: 5 additions & 0 deletions 5 aibridge/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
"net/http"

"github.com/google/uuid"
"go.opentelemetry.io/otel/trace"
"golang.org/x/xerrors"

Expand Down Expand Up @@ -47,6 +48,10 @@ var ErrUnknownRoute = xerrors.New("unknown route")
// OpenAI includes the version '/v1' in the base url while Anthropic does not.
// More details/examples: https://github.com/coder/aibridge/pull/174#discussion_r2782320152
type Provider interface {
// ID returns the provider instance ID, sourced from the ai_providers
// row this provider was constructed from. uuid.Nil for providers built
// from non-DB sources (legacy env-driven constructors, tests).
ID() uuid.UUID
// Type returns the provider type: "copilot", "openai", or "anthropic".
// Multiple provider instances can share the same type.
Type() string
Expand Down
1 change: 1 addition & 0 deletions 1 aibridge/recorder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type InterceptionRecord struct {
Model string
Provider string
ProviderName string
ProviderID string
StartedAt time.Time
ClientSessionID *string
Client string
Expand Down
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.