Skip to content

Refactor API providers #726

Open
Open
@sashabaranov

Description

@sashabaranov

We have a growing number of different API providers: OpenAI, Azure, Cloudflare Getaway. At the same time other tools keep adding their OpenAI-compatible APIs (e.g. Ollama).

Considering #693, here's a sketch of how we can add new API providers painlessly:

type apiProvider interface { // might want to expose that
	SetAuthForRequest(req *http.Request)
	GetFullURL(suffix string, args ...any) // Shouldn't be `any`, but a type-safe list like requestOption
}

type APIProviderConfig interface {
	// whatever we need here
}

client usage:

config := openai.DefaultConfigWithAPIProvider(
	openai.AzureOpenAIProviderConfig("your Azure OpenAI Key", "https://your Azure OpenAI Endpoint"),
)
client := openai.NewClientWithConfig(config)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions