api

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserFromContext = staffio.UserFromContext
)

vars from staffio

Functions

func GetOAuthTokenFromCookie

func GetOAuthTokenFromCookie(ctx context.Context, r *http.Request) string

GetOAuthTokenFromCookie 从 cookie 获取 token(当前实现) tokenCN 需要与 handle_user.go 中的保持一致

func OAuthContextWithToken

func OAuthContextWithToken(ctx context.Context, token string) context.Context

OAuthContextWithToken 将 token 添加到 context

func OAuthTokenFromContext

func OAuthTokenFromContext(ctx context.Context) string

OAuthTokenFromContext 从 context 获取 token

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

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 ChatResponse

type ChatResponse struct {
	// contains filtered or unexported fields
}

type Done

type Done = resp.Done

type Failure

type Failure = resp.Failure

type GetOAuthTokenFunc

type GetOAuthTokenFunc func(ctx context.Context, r *http.Request) string

GetOAuthTokenFunc 用于获取 OAuth token 的函数类型 将来可能从 Redis/DB 获取,当前从 cookie 获取

type M

type M = render.M

type ResultData

type ResultData = resp.ResultData

type ResultID

type ResultID = resp.ResultID

type SummaryRequest

type SummaryRequest struct {
	Tips string `json:"tips,omitempty"`
	Text string `json:"text"`
}

SummaryRequest 摘要请求

type User

type User = staffio.User

Jump to

Keyboard shortcuts

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