Skip to content

Golang library to access multiple LLM platforms with a unified API

Notifications You must be signed in to change notification settings

vildzi/llm-providers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llm-providers

This is a package meant to give a unified API to access multiple LLM platforms. Currently only an OpenAI / Azure OpenAI provider is implemented.

Warning

This package is a work in progress, expect breaking changes.

Installation

go get -u github.com/vildzi/llm-providers@master

Examples

OpenAI

import (
    llmproviders "github.com/vildzi/llm-providers"
    "github.com/vildzi/llm-providers/textproviders"
)

...

oaiProvider, err := textproviders.NewOpenAIProvider("<your openai api key>", nil)
if err != nil {
    panic("failed to init openai provider")
}

llmproviders.RegisterTextProvider("openai", oaiProvider)
// also becomes the default provider as the first registered provider, can be accessed with llmproviders.WithDefaultProvider()

completions, err := llmproviders.WithTextProvider("openai").GetCompletion(context.TODO(), "Tell me a joke", &llmproviders.TextCompletionOptions{
    Messages: textproviders.WithSystemPrompt("you are a helpful assistant", nil),
})
...

About

Golang library to access multiple LLM platforms with a unified API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages