openai

package
v0.0.0-...-81db2af Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuestionFromLLMMessage

func GetQuestionFromLLMMessage(messages []openai2.ChatCompletionMessage) string

func GetSystemPromptFromLLMMessage

func GetSystemPromptFromLLMMessage(messages []openai2.ChatCompletionMessage) string

func LastUserPrompt

func LastUserPrompt(messages []openai2.ChatCompletionMessage) string

func UpdateSystemPromptInLLMRequest

func UpdateSystemPromptInLLMRequest(message []openai2.ChatCompletionMessage, systemPrompt string) []openai2.ChatCompletionMessage

Types

type AgentThinking

type AgentThinking struct {
	Question    string `json:"question"`
	Thought     string `json:"thought"`
	Action      string `json:"action"`
	ActionInput string `json:"action_input"`
	Observation string `json:"observation"`
	FinalAnswer string `json:"final_answer"`
}

type ChatResponse

type ChatResponse struct {
	Id      string `json:"id"`
	Choices []*struct {
		Index   int `json:"index"`
		Message *struct {
			Content string `json:"content"`
			Role    string `json:"role"`
		} `json:"message"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
	Model   string `json:"model"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Usage   *struct {
		PromptTokens     int `json:"prompt_tokens"`
		TotalTokens      int `json:"total_tokens"`
		CompletionTokens int `json:"completion_tokens"`
	} `json:"usage"`
}

type OpenAI

type OpenAI struct {
	BaseURL         string
	ApiKey          string
	AutoAgentApiUrl string
	ModelName       string
}

func NewAgentAI

func NewAgentAI(apiKey string) *OpenAI

func NewOpenAI

func NewOpenAI(baseUrl, apiKey string, modelName string) *OpenAI

func (OpenAI) AgentChats

func (c OpenAI) AgentChats(systemPrompt, baseUrl string, messages serializers.AgentChatMessageReq) (*ChatResponse, error)

func (OpenAI) CallDirectlyEternalLLM

func (c OpenAI) CallDirectlyEternalLLM(messages, model, baseUrl string, options map[string]interface{}) (string, error)

func (OpenAI) CallStreamDirectlyEternalLLM

func (c OpenAI) CallStreamDirectlyEternalLLM(ctx context.Context, messages, model, baseUrl string, options map[string]interface{}, outputChan chan *models.ChatCompletionStreamResponse, errChan chan error, doneChan chan bool)

func (OpenAI) CallStreamOnchainEternalLLM

func (c OpenAI) CallStreamOnchainEternalLLM(ctx context.Context, baseUrl string, apiKey string, llmRequest openai.ChatCompletionRequest, outputChan chan *models.ChatCompletionStreamResponse, errChan chan error, doneChan chan bool)

func (OpenAI) ChatMessage

func (c OpenAI) ChatMessage(msgChat string) (string, error)

func (OpenAI) ChatMessageWithSystemPromp

func (c OpenAI) ChatMessageWithSystemPromp(msgChat, systemContent string) (string, error)

func (OpenAI) SummaryWebContent

func (c OpenAI) SummaryWebContent(webContent string) (string, error)

func (OpenAI) TestAgentPersinality

func (c OpenAI) TestAgentPersinality(systemPrompt, userPrompt, baseUrl string) (string, error)

func (OpenAI) TestAgentPersinalityV1

func (c OpenAI) TestAgentPersinalityV1(messages, baseUrl string) (string, error)

Jump to

Keyboard shortcuts

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