Skip to content
Open
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
29 changes: 29 additions & 0 deletions litellm/litellm_model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package litellm

import (
"github.com/cloudwego/eino-ext/libs/acl/openai"
)

// LitellmModel represents a model that interacts with OpenAI-compatible APIs.
type LitellmModel struct {
client *openai.Client
}

// NewLitellmModel creates a new instance of LitellmModel.
func NewLitellmModel(apiKey string) (*LitellmModel, error) {
client, err := openai.NewClient(apiKey)
if err != nil {
return nil, err
}
return &LitellmModel{client: client}, nil
}

// GenerateText generates text based on the given prompt.
func (m *LitellmModel) GenerateText(prompt string) (string, error) {
response, err := m.client.Completions.Create(prompt)
if err != nil {
return "", err
}
return response.Choices[0].Text, nil
}