Skip to content
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

🔧 Ensure components implement interfaces at compilation #273

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
4 changes: 4 additions & 0 deletions pkg/providers/anthropic/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package anthropic

import (
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand All @@ -26,6 +27,9 @@ type Client struct {
tel *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new OpenAI client for the OpenAI API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint)
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/azureopenai/chat_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type ChatStream struct {
errMapper *ErrorMapper
}

// ensure interfaces are implemented at compilation
var _ clients.ChatStream = (*ChatStream)(nil)

func NewChatStream(
tel *telemetry.Telemetry,
client *http.Client,
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/azureopenai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package azureopenai

import (
"fmt"
"github.com/EinStack/glide/pkg/providers"
"net/http"
"time"

Expand All @@ -28,6 +29,9 @@ type Client struct {
tel *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new Azure OpenAI client for the OpenAI API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL := fmt.Sprintf(
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/bedrock/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bedrock
import (
"context"
"errors"
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -36,6 +37,9 @@ type Client struct {
telemetry *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new OpenAI client for the OpenAI API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint, providerConfig.ModelName, "/invoke")
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/cohere/chat_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type ChatStream struct {
tel *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ clients.ChatStream = (*ChatStream)(nil)

func NewChatStream(
tel *telemetry.Telemetry,
client *http.Client,
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/cohere/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cohere

import (
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand All @@ -26,6 +27,9 @@ type Client struct {
tel *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new Cohere client for the Cohere API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint)
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type LanguageModel struct {
latencyUpdateInterval *fields.Duration
}

// ensure interfaces are implemented at compilation
var _ LangModel = (*LanguageModel)(nil)

func NewLangModel(modelID string, client LangProvider, budget *health.ErrorBudget, latencyConfig latency.Config, weight int) *LanguageModel {
return &LanguageModel{
modelID: modelID,
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/octoml/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package octoml

import (
"errors"
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -31,6 +32,9 @@ type Client struct {
telemetry *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new OctoML client for the OctoML API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint)
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/ollama/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ollama

import (
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand All @@ -24,6 +25,9 @@ type Client struct {
telemetry *telemetry.Telemetry
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new OpenAI client for the OpenAI API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint)
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/openai/chat_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type ChatStream struct {
logger *zap.Logger
}

// ensure interfaces are implemented at compilation
var _ clients.ChatStream = (*ChatStream)(nil)

func NewChatStream(
client *http.Client,
req *http.Request,
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/openai/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openai

import (
"github.com/EinStack/glide/pkg/providers"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -29,6 +30,9 @@ type Client struct {
logger *zap.Logger
}

// ensure interfaces are implemented at compilation
var _ providers.LangProvider = (*Client)(nil)

// NewClient creates a new OpenAI client for the OpenAI API.
func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error) {
chatURL, err := url.JoinPath(providerConfig.BaseURL, providerConfig.ChatEndpoint)
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/testing/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type LangModelMock struct {
weight int
}

// ensure interfaces are implemented at compilation
var _ providers.Model = (*LangModelMock)(nil)

func NewLangModelMock(ID string, healthy bool, avgLatency float64, weight int) LangModelMock {
chatLatency := latency.NewMovingAverage(0.06, 3)

Expand Down
Loading