openai

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const MetadataToolsSlug = "tools"

Variables

This section is empty.

Functions

func GetToolCallString added in v0.4.13

func GetToolCallString(toolCalls []go_openai.ToolCall) string

func IsOpenAiEngine

func IsOpenAiEngine(engine string) bool

Types

type ChatExecuteToolStep added in v0.4.13

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

ChatExecuteToolStep combines a chat step with a tool execution step.

func NewChatToolStep added in v0.4.1

func NewChatToolStep(stepSettings *settings.StepSettings, options ...ChatToolStepOption) (*ChatExecuteToolStep, error)

func (*ChatExecuteToolStep) AddPublishedTopic added in v0.4.13

func (t *ChatExecuteToolStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*ChatExecuteToolStep) Start added in v0.4.13

type ChatStep added in v0.4.13

type ChatStep struct {
	Settings *settings.StepSettings
	// contains filtered or unexported fields
}

func NewStep added in v0.2.24

func NewStep(settings *settings.StepSettings, options ...StepOption) (*ChatStep, error)

func (*ChatStep) AddPublishedTopic added in v0.4.13

func (csf *ChatStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*ChatStep) Start added in v0.4.13

func (csf *ChatStep) Start(
	ctx context.Context,
	messages conversation.Conversation,
) (steps.StepResult[string], error)

type ChatToolStepOption added in v0.4.1

type ChatToolStepOption func(step *ChatExecuteToolStep)

func WithReflector added in v0.4.1

func WithReflector(reflector *jsonschema.Reflector) ChatToolStepOption

WithReflector sets the JSON schema reflector for the step.

func WithToolFunctions added in v0.4.1

func WithToolFunctions(toolFunctions map[string]interface{}) ChatToolStepOption

WithToolFunctions sets the tool functions for the step. The schema is derived from these functions using the reflector.

type ChatWithToolsStep added in v0.4.13

type ChatWithToolsStep struct {
	Settings *settings.StepSettings
	Tools    []go_openai.Tool
	// contains filtered or unexported fields
}

ChatWithToolsStep is actually just like ChatStep, except that it also accumulates tool calls.

func NewChatWithToolsStep added in v0.4.13

func NewChatWithToolsStep(
	stepSettings *settings.StepSettings,
	Tools []go_openai.Tool,
	options ...ToolStepOption,
) (*ChatWithToolsStep, error)

func (*ChatWithToolsStep) AddPublishedTopic added in v0.4.13

func (r *ChatWithToolsStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*ChatWithToolsStep) SetStreaming added in v0.4.13

func (csf *ChatWithToolsStep) SetStreaming(b bool)

NOTE(manuel, 2024-06-04) I think this can be removed

func (*ChatWithToolsStep) Start added in v0.4.13

type ExecuteToolStep added in v0.2.24

type ExecuteToolStep struct {
	Tools map[string]interface{}
	// contains filtered or unexported fields
}

TODO(manuel, 2024-07-04) Make this use the chat.ToolCall and chat.ToolResult structs and make it generic

func NewExecuteToolStep added in v0.4.1

func NewExecuteToolStep(
	tools map[string]interface{},
	options ...ExecuteToolStepOption,
) (*ExecuteToolStep, error)

func (*ExecuteToolStep) AddPublishedTopic added in v0.4.1

func (e *ExecuteToolStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*ExecuteToolStep) Start added in v0.2.24

type ExecuteToolStepOption added in v0.4.1

type ExecuteToolStepOption func(*ExecuteToolStep) error

func WithExecuteToolStepMessageID added in v0.4.1

func WithExecuteToolStepMessageID(messageID conversation.NodeID) ExecuteToolStepOption

func WithExecuteToolStepParentID added in v0.4.1

func WithExecuteToolStepParentID(parentID conversation.NodeID) ExecuteToolStepOption

func WithExecuteToolStepSubscriptionManager added in v0.4.1

func WithExecuteToolStepSubscriptionManager(subscriptionManager *events.PublisherManager) ExecuteToolStepOption

type StepOption added in v0.4.1

type StepOption func(*ChatStep) error

func WithSubscriptionManager added in v0.4.1

func WithSubscriptionManager(subscriptionManager *events.PublisherManager) StepOption

type ToolCallMerger added in v0.2.24

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

func NewToolCallMerger added in v0.2.24

func NewToolCallMerger() *ToolCallMerger

func (*ToolCallMerger) AddToolCalls added in v0.2.24

func (tcm *ToolCallMerger) AddToolCalls(toolCalls []go_openai.ToolCall)

func (*ToolCallMerger) GetToolCalls added in v0.2.24

func (tcm *ToolCallMerger) GetToolCalls() []go_openai.ToolCall

type ToolCompletionResponse added in v0.2.24

type ToolCompletionResponse struct {
	Role      string               `json:"role"`
	Content   string               `json:"content"`
	ToolCalls []go_openai.ToolCall `json:"tool_calls"`
}

type ToolStepOption added in v0.4.1

type ToolStepOption func(*ChatWithToolsStep) error

func WithChatWithToolsStepMessageID added in v0.4.13

func WithChatWithToolsStepMessageID(messageID conversation.NodeID) ToolStepOption

func WithChatWithToolsStepParentID added in v0.4.13

func WithChatWithToolsStepParentID(parentID conversation.NodeID) ToolStepOption

func WithChatWithToolsStepSubscriptionManager added in v0.4.13

func WithChatWithToolsStepSubscriptionManager(subscriptionManager *events.PublisherManager) ToolStepOption

type Transcription added in v0.2.18

type Transcription struct {
	File     string                `json:"file"`
	Response *openai.AudioResponse `json:"response"`
	// contains filtered or unexported fields
}

type TranscriptionClient added in v0.2.18

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

func NewTranscriptionClient added in v0.2.18

func NewTranscriptionClient(apiKey, model, prompt, language string, temperature float32) *TranscriptionClient

func (*TranscriptionClient) TranscribeFile added in v0.2.18

func (tc *TranscriptionClient) TranscribeFile(mp3FilePath string, out chan<- Transcription, wg *sync.WaitGroup)

Jump to

Keyboard shortcuts

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