Documentation ¶
Index ¶
- Constants
- func HttpChatCompletion(r *http.Request, cfg *config.OpenAIConfig, req *openai.ChatCompletionRequest, ...)
- func HttpChatResponseProcess(w http.ResponseWriter, r *http.Request, chStr <-chan string) string
- func MakeChatRequest(in *Message, history []openai.ChatCompletionMessage) *openai.ChatCompletionRequest
- func NewOpenAIClient(apiKey, apiType, baseURL, proxy string) (*openai.Client, error)
- func SSEServerChatResponseProcess(r *http.Request, streamID string, chStr <-chan string) string
- type Message
Constants ¶
View Source
const (
Timeout = 180 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func HttpChatCompletion ¶
func HttpChatCompletion(r *http.Request, cfg *config.OpenAIConfig, req *openai.ChatCompletionRequest, chStr chan<- string)
HttpChatCompletion 聊天api
func HttpChatResponseProcess ¶
HttpChatResponseProcess http sse 处理请求结果
func MakeChatRequest ¶
func MakeChatRequest(in *Message, history []openai.ChatCompletionMessage) *openai.ChatCompletionRequest
MakeChatRequest 生成请求消息, history=不含系统提示语的聊天记录
func NewOpenAIClient ¶
NewOpenAIClient 客户端
Types ¶
type Message ¶
type Message struct { ID string `json:"id,omitempty"` User string `json:"user,omitempty"` Model string `json:"model"` Prompt string `json:"prompt"` System string `json:"system,omitempty"` Stream bool `json:"stream,omitempty"` StreamID string `json:"stream_id,omitempty"` History uint `json:"history,omitempty"` MaxTokens uint `json:"max_tokens,omitempty"` }
Click to show internal directories.
Click to hide internal directories.