Documentation
¶
Index ¶
- Variables
- func GetOAuthTokenFromCookie(ctx context.Context, r *http.Request) string
- func InitChannels(r chi.Router, preset *aigc.Preset, sto stores.Storage, llmClient llm.Client, ...) error
- func OAuthTokenMiddleware(getToken GetOAuthTokenFunc) func(http.Handler) http.Handler
- func StopChannels()
- type ChatMessage
- type ChatRequest
- type Command
- type Done
- type Failure
- type GetOAuthTokenFunc
- type M
- type O2User
- type ResultData
- type ResultID
- type SummaryRequest
- type ToolExecutor
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UserFromContext = staffio.UserFromContext ContextWithUser = staffio.ContextWithUser )
vars from staffio
Functions ¶
func GetOAuthTokenFromCookie ¶
GetOAuthTokenFromCookie 从 cookie 获取 token(当前实现) tokenCN 需要与 handle_user.go 中的保持一致
func InitChannels ¶ added in v0.3.0
func InitChannels(r chi.Router, preset *aigc.Preset, sto stores.Storage, llmClient llm.Client, toolreg *tools.Registry) error
InitChannels initializes channel adapters from preset configuration.
func OAuthTokenMiddleware ¶
func OAuthTokenMiddleware(getToken GetOAuthTokenFunc) func(http.Handler) http.Handler
OAuthTokenMiddleware 创建中间件,将 cookie 中的 token 注入 context
Types ¶
type ChatMessage ¶
type ChatMessage struct {
ID string `json:"id,omitempty"`
Delta string `json:"delta,omitempty"`
Text string `json:"text,omitempty"`
Think string `json:"think,omitempty"`
Role string `json:"role,omitempty"`
Name string `json:"name,omitempty"`
// For Role=assistant prompts this may be set to the tool calls generated by the model, such as function calls.
ToolCalls []map[string]any `json:"tool_calls,omitempty"`
// For Role=tool prompts this should be set to the ID given in the assistant's prior request to call a tool.
ToolCallID string `json:"tool_call_id,omitempty"`
FinishReason string `json:"finishReason,omitempty"`
ConversationID string `json:"csid,omitempty"`
Title string `json:"title,omitempty"`
}
for response to client
type ChatRequest ¶
type ChatRequest struct {
Prompt string `json:"prompt"`
ConversationID string `json:"csid"`
ParentMessageID string `json:"pmid"` // TODO: rename to PreviousMessageID
Regenerate bool `json:"regen"`
Stream bool `json:"stream"`
MCPs []string `json:"mcps,omitempty"`
// deprecated: for github.com/Chanzhaoyu/chatgpt-web only
Options struct {
ConversationId string `json:"conversationId,omitempty"`
} `json:"options,omitempty"`
}
func (*ChatRequest) GetConversionID ¶
func (z *ChatRequest) GetConversionID() string
type Command ¶ added in v0.3.0
type Command struct {
Name string
Aliases []string
Desc string
Action func(ctx context.Context, msg *channel.Message) (bool, error)
}
func DetectCommand ¶ added in v0.3.0
type GetOAuthTokenFunc ¶
GetOAuthTokenFunc 用于获取 OAuth token 的函数类型 将来可能从 Redis/DB 获取,当前从 cookie 获取
type ResultData ¶
type ResultData = resp.ResultData
type SummaryRequest ¶
SummaryRequest 摘要请求
type ToolExecutor ¶ added in v0.3.0
type ToolExecutor struct {
// contains filtered or unexported fields
}
ToolExecutor 封装工具调用循环逻辑
func NewToolExecutor ¶ added in v0.3.0
func NewToolExecutor(toolreg *tools.Registry) *ToolExecutor
NewToolExecutor 创建 ToolExecutor
func (*ToolExecutor) ExecuteToolCallLoop ¶ added in v0.3.0
func (e *ToolExecutor) ExecuteToolCallLoop( ctx context.Context, messages []llm.Message, tools []llm.ToolDefinition, exec chatExecutor, ) (string, []llm.ToolCall, *llm.Usage, error)
ExecuteToolCallLoop 执行工具调用循环,直到无 tool calls
Click to show internal directories.
Click to hide internal directories.