openai

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package openai provides a model.Client implementation backed by the OpenAI Chat Completions API. It translates loom-mcp requests into ChatCompletion calls using github.com/sashabaranov/go-openai and maps responses back to the generic planner structures.

Package openai wires OpenAI model clients into loom-mcp planners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatClient

type ChatClient interface {
	CreateChatCompletion(ctx context.Context, request openai.ChatCompletionRequest) (
		openai.ChatCompletionResponse, error)
}

ChatClient captures the subset of the go-openai client used by the adapter.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements model.Client via the OpenAI Chat Completions API.

func New

func New(opts Options) (*Client, error)

New builds an OpenAI-backed model client from the provided options.

func NewFromAPIKey

func NewFromAPIKey(apiKey, defaultModel string) (*Client, error)

NewFromAPIKey constructs a client using the default go-openai HTTP client.

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, req *model.Request) (*model.Response, error)

Complete renders a chat completion using the configured OpenAI client.

func (*Client) Stream

Stream reports that OpenAI Chat Completions streaming is not yet supported by this adapter. Callers should fall back to Complete.

type Options

type Options struct {
	Client       ChatClient
	DefaultModel string
}

Options configures the OpenAI adapter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL