Documentation ¶
Overview ¶
Endpoints for mocking OpenAI API calls.
Index ¶
- func StartHTTPTestServer(response OpenAIResponse) *httptest.Server
- type AIMessage
- type ChatClient
- func (c *ChatClient) AddMessage(role string, content string)
- func (c *ChatClient) ClearMessages()
- func (c *ChatClient) CreateChatCompletion(messages []ChatMessage, model string) ([]ChatMessage, error)
- func (c *ChatClient) GetLastMessage() ChatMessage
- func (c *ChatClient) GetMessages() []ChatMessage
- func (c *ChatClient) LoadMessages(filename string) error
- func (c *ChatClient) SaveMessages(filename string) error
- func (c *ChatClient) SendAssistantMessage(msg string) error
- func (c *ChatClient) SendMessage(content string, role string) error
- func (c *ChatClient) SendSystemMessage(msg string) error
- func (c *ChatClient) SendUserMessage(msg string) error
- func (c *ChatClient) SetBaseURL(baseURL string)
- func (c *ChatClient) SetMessages(messages []ChatMessage)
- type ChatMessage
- type OpenAI
- type OpenAIResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartHTTPTestServer ¶
func StartHTTPTestServer(response OpenAIResponse) *httptest.Server
Types ¶
type AIMessage ¶
func (*AIMessage) GetContent ¶
type ChatClient ¶
type ChatClient struct {
// contains filtered or unexported fields
}
func NewChatClient ¶
func NewChatClient(apiKey string) *ChatClient
func (*ChatClient) AddMessage ¶
func (c *ChatClient) AddMessage(role string, content string)
func (*ChatClient) ClearMessages ¶
func (c *ChatClient) ClearMessages()
func (*ChatClient) CreateChatCompletion ¶
func (c *ChatClient) CreateChatCompletion(messages []ChatMessage, model string) ([]ChatMessage, error)
func (*ChatClient) GetLastMessage ¶
func (c *ChatClient) GetLastMessage() ChatMessage
func (*ChatClient) GetMessages ¶
func (c *ChatClient) GetMessages() []ChatMessage
func (*ChatClient) LoadMessages ¶
func (c *ChatClient) LoadMessages(filename string) error
func (*ChatClient) SaveMessages ¶
func (c *ChatClient) SaveMessages(filename string) error
func (*ChatClient) SendAssistantMessage ¶
func (c *ChatClient) SendAssistantMessage(msg string) error
func (*ChatClient) SendMessage ¶
func (c *ChatClient) SendMessage(content string, role string) error
func (*ChatClient) SendSystemMessage ¶
func (c *ChatClient) SendSystemMessage(msg string) error
func (*ChatClient) SendUserMessage ¶
func (c *ChatClient) SendUserMessage(msg string) error
func (*ChatClient) SetBaseURL ¶
func (c *ChatClient) SetBaseURL(baseURL string)
func (*ChatClient) SetMessages ¶
func (c *ChatClient) SetMessages(messages []ChatMessage)
type ChatMessage ¶
func (ChatMessage) GetContent ¶
func (msg ChatMessage) GetContent() string
func (ChatMessage) GetRole ¶
func (msg ChatMessage) GetRole() string
func (*ChatMessage) ToAIMessage ¶
func (msg *ChatMessage) ToAIMessage() (AIMessage, error)
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
func NewOpenAIWithBaseURL ¶
func (*OpenAI) GetCompletion ¶
type OpenAIResponse ¶
type OpenAIResponse string
const ( SampleChatCompletion OpenAIResponse = `` /* 299-byte string literal not displayed */ SampleChatJSONCompletion OpenAIResponse = `` /* 333-byte string literal not displayed */ SampleChatYAMLCompletion OpenAIResponse = `` /* 354-byte string literal not displayed */ SampleChatFileCompletion OpenAIResponse = `` /* 384-byte string literal not displayed */ )
Click to show internal directories.
Click to hide internal directories.