openai

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TOOL_CALL_ITERATIONS = 20

Variables

View Source
var (
	WithToolHandler                 = mcpopenai.WithToolHandler
	ToolHandlerFromContext          = mcpopenai.ToolHandlerFromContext
	NewChatStream                   = mcpopenai.NewChatStream
	BuildToolResultMessage          = mcpopenai.BuildToolResultMessage
	BuildAssistantToolCallMessage   = mcpopenai.BuildAssistantToolCallMessage
	NewStreamingToolCallAccumulator = mcpopenai.NewStreamingToolCallAccumulator
	NewMaxToolIterationsError       = mcpopenai.NewMaxToolIterationsError
	ExtractToolResult               = mcpopenai.ExtractToolResult
	MCPToolsToOpenAI                = mcpopenai.MCPToolsToOpenAI
	MCPToolsToOpenAIFiltered        = mcpopenai.MCPToolsToOpenAIFiltered
	ExecuteToolCalls                = mcpopenai.ExecuteToolCalls
	GenerateToolCallID              = mcpopenai.GenerateToolCallID
)

Re-export functions from mcp/openai

Functions

This section is empty.

Types

type ChatCompletionRequest

type ChatCompletionRequest = mcpopenai.ChatCompletionRequest

Re-export types from mcp/openai for convenience

type ChatCompletionResponse

type ChatCompletionResponse = mcpopenai.ChatCompletionResponse

Re-export types from mcp/openai for convenience

type ChatStream

type ChatStream = mcpopenai.ChatStream

Re-export types from mcp/openai for convenience

type Choice

type Choice = mcpopenai.Choice

Re-export types from mcp/openai for convenience

type Client

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

Client represents an OpenAI API client

func New

func New(config Config, mcpServer MCPServer) (*Client, error)

New creates a new OpenAI client

func (*Client) ChatCompletion

func (c *Client) ChatCompletion(ctx context.Context, req ChatCompletionRequest) (*ChatCompletionResponse, error)

ChatCompletion performs a non-streaming chat completion with automatic tool processing

func (*Client) GetModels

func (c *Client) GetModels(ctx context.Context) (*ModelsResponse, error)

GetModels retrieves the list of available models from OpenAI

func (*Client) StreamChatCompletion

func (c *Client) StreamChatCompletion(ctx context.Context, req ChatCompletionRequest) *ChatStream

StreamChatCompletion performs a streaming chat completion with automatic tool processing Returns a channel of pure OpenAI ChatCompletionResponse chunks

type Config

type Config struct {
	APIKey  string
	BaseURL string
	Timeout time.Duration
}

Config holds configuration for the OpenAI client

type Delta

type Delta = mcpopenai.Delta

Re-export types from mcp/openai for convenience

type DeltaFunction

type DeltaFunction = mcpopenai.DeltaFunction

Re-export types from mcp/openai for convenience

type DeltaToolCall

type DeltaToolCall = mcpopenai.DeltaToolCall

Re-export types from mcp/openai for convenience

type MCPServer

type MCPServer interface {
	ListTools() []mcp.MCPTool
	CallTool(ctx context.Context, name string, args map[string]any) (*mcp.ToolResponse, error)
}

MCPServer interface for MCP server operations

type Message

type Message = mcpopenai.Message

Re-export types from mcp/openai for convenience

type Model

type Model = mcpopenai.Model

Re-export types from mcp/openai for convenience

type ModelsResponse

type ModelsResponse = mcpopenai.ModelsResponse

Re-export types from mcp/openai for convenience

type Service

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

func NewService

func NewService(client *Client, systemPrompt string) *Service

func (*Service) HandleChatCompletions

func (s *Service) HandleChatCompletions(w http.ResponseWriter, r *http.Request)

Handles POST /v1/chat/completions

func (*Service) HandleGetModels

func (s *Service) HandleGetModels(w http.ResponseWriter, r *http.Request)

Handles GET /v1/models

type Tool

type Tool = mcpopenai.Tool

Re-export types from mcp/openai for convenience

type ToolCall

type ToolCall = mcpopenai.ToolCall

Re-export types from mcp/openai for convenience

type ToolCallFunction

type ToolCallFunction = mcpopenai.ToolCallFunction

Re-export types from mcp/openai for convenience

type ToolFilter

type ToolFilter = mcpopenai.ToolFilter

Re-export types from mcp/openai for convenience

type ToolFunction

type ToolFunction = mcpopenai.ToolFunction

Re-export types from mcp/openai for convenience

type ToolHandler

type ToolHandler = mcpopenai.ToolHandler

Re-export types from mcp/openai for convenience

type Usage

type Usage = mcpopenai.Usage

Re-export types from mcp/openai for convenience

Jump to

Keyboard shortcuts

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