Documentation
¶
Index ¶
- func HandleNonStreamResponseUnTyped(ctx context.Context, resp *http.Response, isOpenAI bool, ch chan<- any) error
- func HandleStreamResponseUnTyped(ctx context.Context, resp *http.Response, isOpenAI bool, ch chan<- any) error
- func HandlerHttpWithChannel(xRequest XRequest, isPreCooked bool, ch chan<- any) error
- type ChatGPTRequest
- type ChatGPTResponse
- type ChatGPTStreamResponse
- type Usage
- type XRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleNonStreamResponseUnTyped ¶
func HandleNonStreamResponseUnTyped(ctx context.Context, resp *http.Response, isOpenAI bool, ch chan<- any) error
HandleNonStreamResponseUnTyped 处理非流式响应
Types ¶
type ChatGPTRequest ¶
type ChatGPTRequest struct {
Model string `json:"model"`
Messages []map[string]string `json:"messages"`
Stream *bool `json:"stream"`
MaxTokens *int `json:"max_tokens"`
Temperature *float32 `json:"temperature"`
TopP *float32 `json:"top_p"`
}
ChatGPTRequest ChatGPT API 请求的结构体
type ChatGPTResponse ¶
type ChatGPTResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
Usage Usage `json:"usage"`
Choices []struct {
Index int `json:"index"`
Message struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"message"`
FinishReason string `json:"finish_reason,omitempty"`
} `json:"choices"`
}
ChatGPTResponse OpenAI API 响应的结构体(非流式)
func (*ChatGPTResponse) GetResponse ¶
func (c *ChatGPTResponse) GetResponse() string
type ChatGPTStreamResponse ¶
type ChatGPTStreamResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
Choices []struct {
Delta struct {
Content string `json:"content"`
} `json:"delta"`
FinishReason string `json:"finish_reason,omitempty"`
} `json:"choices"`
}
ChatGPTStreamResponse OpenAI API 流式响应的结构体
func (*ChatGPTStreamResponse) GetResponse ¶
func (c *ChatGPTStreamResponse) GetResponse() string
Click to show internal directories.
Click to hide internal directories.