diff --git a/litellm/litellm_model.go b/litellm/litellm_model.go new file mode 100644 index 00000000..8974fc72 --- /dev/null +++ b/litellm/litellm_model.go @@ -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 +} +