Documentation
¶
Index ¶
- Constants
- type APPMetadata
- type ChatReqBody
- type ChatRespBody
- type ChatServer
- func (cs *ChatServer) AppRun(ctx context.Context, req ChatReqBody, respStream chan string, messageID string, ...) (*ChatRespBody, error)
- func (cs *ChatServer) BuildConversationKnowledgeBase(ctx context.Context, req ConversationFilesReqBody, document storage.Document) error
- func (cs *ChatServer) DeleteConversation(ctx context.Context, conversationID string) error
- func (cs *ChatServer) FillAppIconToConversations(ctx context.Context, conversations *[]storage.Conversation) error
- func (cs *ChatServer) GetApp(ctx context.Context, appName, appNamespace string) (*v1alpha1.Application, error)
- func (cs *ChatServer) GetMessageReferences(ctx context.Context, req MessageReqBody) ([]retriever.Reference, error)
- func (cs *ChatServer) IsGPTUserHasPermissionForApp(ctx context.Context, app *v1alpha1.Application) (ok bool)
- func (cs *ChatServer) ListConversations(ctx context.Context, req APPMetadata) ([]storage.Conversation, error)
- func (cs *ChatServer) ListMessages(ctx context.Context, req ConversationReqBody) (storage.Conversation, error)
- func (cs *ChatServer) ListPromptStarters(ctx context.Context, req APPMetadata, limit int) (promptStarters []string, err error)
- func (cs *ChatServer) ReceiveConversationFile(ctx context.Context, messageID string, req ConversationFilesReqBody, ...) (*ChatRespBody, error)
- func (cs *ChatServer) Storage() storage.Storage
- type ConversatioSingleDocRespBody
- type ConversationDocsRespBody
- type ConversationFilesReqBody
- type ConversationReqBody
- type DocumentRespBody
- type ErrorResp
- type MessageReqBody
- type ResponseMode
- type SimpleResp
Constants ¶
const PromptForGeneratePromptStartersByAppInfo = `` /* 425-byte string literal not displayed */
const PromptForGeneratePromptStartersByChunk = `` /* 293-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APPMetadata ¶
type APPMetadata struct { // AppName, the name of the application APPName string `json:"app_name" form:"app_name" binding:"required" example:"chat-with-llm"` // AppNamespace, the namespace of the application, will be forced to use the value of the namespace in the request header for security reasons and is placed here only for compatibility with older versions AppNamespace string `json:"-" form:"-"` }
type ChatReqBody ¶
type ChatReqBody struct { // Query user query string Query string `json:"query" form:"query" binding:"required" example:"旷工最小计算单位为多少天?"` // Files this conversation will use in the context Files []string `json:"files" form:"files" example:"test.pdf,song.mp3"` // ResponseMode: // * Blocking - means the response is returned in a blocking manner // * Streaming - means the response will use Server-Sent Events ResponseMode ResponseMode `json:"response_mode" form:"response_mode" binding:"required" example:"blocking"` ConversationReqBody `json:",inline"` Debug bool `json:"-"` NewChat bool `json:"-"` StartTime time.Time `json:"-"` }
type ChatRespBody ¶
type ChatRespBody struct { ConversationID string `json:"conversation_id" example:"5a41f3ca-763b-41ec-91c3-4bbbb00736d0"` MessageID string `json:"message_id" example:"4f3546dd-5404-4bf8-a3bc-4fa3f9a7ba24"` // Action indicates what is this chat for Action string `json:"action,omitempty" example:"CHAT"` // Message is what AI say Message string `json:"message" example:"旷工最小计算单位为0.5天。"` // CreatedAt is the time when the message is created CreatedAt time.Time `json:"created_at" example:"2023-12-21T10:21:06.389359092+08:00"` // References is the list of references References []retriever.Reference `json:"references,omitempty"` // Latency(ms) is how much time the server cost to process a certain request. Latency int64 `json:"latency,omitempty" example:"1000"` // Documents in this chat Document DocumentRespBody `json:"document,omitempty"` }
type ChatServer ¶ added in v0.2.0
type ChatServer struct {
// contains filtered or unexported fields
}
func NewChatServer ¶ added in v0.2.0
func NewChatServer(cli runtimeclient.Client, isGpts bool) *ChatServer
func (*ChatServer) AppRun ¶ added in v0.2.0
func (cs *ChatServer) AppRun(ctx context.Context, req ChatReqBody, respStream chan string, messageID string, timeout *float64) (*ChatRespBody, error)
func (*ChatServer) BuildConversationKnowledgeBase ¶ added in v0.2.1
func (cs *ChatServer) BuildConversationKnowledgeBase(ctx context.Context, req ConversationFilesReqBody, document storage.Document) error
BuildConversationKnowledgeBase create/updates knowledgebase for this conversation. Conversation ID will be the knowledgebase name and document will be placed unde filegroup Knoweledgebase will embed the document into vectorstore which can be used in this conversation as references(similarity search)
func (*ChatServer) DeleteConversation ¶ added in v0.2.0
func (cs *ChatServer) DeleteConversation(ctx context.Context, conversationID string) error
func (*ChatServer) FillAppIconToConversations ¶ added in v0.2.2
func (cs *ChatServer) FillAppIconToConversations(ctx context.Context, conversations *[]storage.Conversation) error
func (*ChatServer) GetApp ¶ added in v0.2.2
func (cs *ChatServer) GetApp(ctx context.Context, appName, appNamespace string) (*v1alpha1.Application, error)
func (*ChatServer) GetMessageReferences ¶ added in v0.2.0
func (cs *ChatServer) GetMessageReferences(ctx context.Context, req MessageReqBody) ([]retriever.Reference, error)
func (*ChatServer) IsGPTUserHasPermissionForApp ¶ added in v0.2.2
func (cs *ChatServer) IsGPTUserHasPermissionForApp(ctx context.Context, app *v1alpha1.Application) (ok bool)
func (*ChatServer) ListConversations ¶ added in v0.2.0
func (cs *ChatServer) ListConversations(ctx context.Context, req APPMetadata) ([]storage.Conversation, error)
func (*ChatServer) ListMessages ¶ added in v0.2.0
func (cs *ChatServer) ListMessages(ctx context.Context, req ConversationReqBody) (storage.Conversation, error)
func (*ChatServer) ListPromptStarters ¶ added in v0.2.0
func (cs *ChatServer) ListPromptStarters(ctx context.Context, req APPMetadata, limit int) (promptStarters []string, err error)
ListPromptStarters PromptStarter are examples for users to help them get up and running with the application quickly. We use same name with chatgpt
func (*ChatServer) ReceiveConversationFile ¶ added in v0.2.1
func (cs *ChatServer) ReceiveConversationFile(ctx context.Context, messageID string, req ConversationFilesReqBody, file *multipart.FileHeader) (*ChatRespBody, error)
ReceiveConversationDocs receive and process docs for a conversation
func (*ChatServer) Storage ¶ added in v0.2.0
func (cs *ChatServer) Storage() storage.Storage
type ConversatioSingleDocRespBody ¶ added in v0.2.0
type ConversatioSingleDocRespBody struct { FileName string `json:"file_name,omitempty"` NumberOfDocuments int `json:"number_of_documents,omitempty"` TotalTimecost float64 `json:"total_time_cost,omitempty"` // Embedding info TimecostForEmbedding float64 `json:"timecost_for_embedding,omitempty"` // Summary info Summary string `json:"summary,omitempty"` TimecostForSummarization float64 `json:"timecost_for_summarization,omitempty"` }
ConversatioSingleDocRespBody is the response body for a single conversation doc
type ConversationDocsRespBody ¶ added in v0.2.0
type ConversationDocsRespBody struct { ChatRespBody `json:",inline"` // Docs are the responbody for each document Doc *ConversatioSingleDocRespBody `json:"doc,omitempty"` }
ConversationDocsRespBody is the response body for a ConversationDocsReq
type ConversationFilesReqBody ¶ added in v0.2.1
type ConversationFilesReqBody struct { ConversationReqBody `json:",inline"` Debug bool `json:"-"` NewChat bool `json:"-"` StartTime time.Time `json:"-"` }
type ConversationReqBody ¶
type ConversationReqBody struct { APPMetadata `json:",inline" form:",inline"` // ConversationID, if it is empty, a new conversation will be created ConversationID string `json:"conversation_id" form:"conversation_id" example:"5a41f3ca-763b-41ec-91c3-4bbbb00736d0"` }
type DocumentRespBody ¶ added in v0.2.1
type ErrorResp ¶
type ErrorResp struct {
Err string `json:"error" example:"conversation is not found"`
}
type MessageReqBody ¶
type MessageReqBody struct { ConversationReqBody `json:",inline"` // MessageID, single message id MessageID string `json:"message_id" example:"4f3546dd-5404-4bf8-a3bc-4fa3f9a7ba24"` }
type ResponseMode ¶
type ResponseMode string
const ( // Blocking means the response is returned in a blocking manner Blocking ResponseMode = "blocking" // Streaming means the response will use Server-Sent Events Streaming ResponseMode = "streaming" )
func (ResponseMode) IsStreaming ¶
func (r ResponseMode) IsStreaming() bool
type SimpleResp ¶
type SimpleResp struct {
Message string `json:"message" example:"ok"`
}