chatgpt

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func HttpChatResponseProcess(w http.ResponseWriter, r *http.Request,
	chStr <-chan string) string

HttpChatResponseProcess http sse 处理请求结果

func MakeChatRequest

func MakeChatRequest(in *Message, history []openai.ChatCompletionMessage) *openai.ChatCompletionRequest

MakeChatRequest 生成请求消息, history=不含系统提示语的聊天记录

func NewOpenAIClient

func NewOpenAIClient(apiKey, apiType, baseURL, proxy string) (*openai.Client, error)

NewOpenAIClient 客户端

func SSEServerChatResponseProcess added in v0.3.1

func SSEServerChatResponseProcess(r *http.Request,
	streamID string,
	chStr <-chan string) string

SSEServerChatResponseProcess http sse 处理请求结果

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"`
}

Jump to

Keyboard shortcuts

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