service

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// Time interval to check if the chat stream should be closed if no more message arrives
	WaitTimeoutForChatStreaming = 120
	// default prompt starter
	PromptLimit = 4
)

Variables

This section is empty.

Functions

func Cors

func Cors() gin.HandlerFunc

func NamespaceInHeader added in v0.2.1

func NamespaceInHeader(c *gin.Context) string

func NewServerAndRun

func NewServerAndRun(conf config.ServerConfig)

Types

type ChatService added in v0.2.0

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

func NewChatService added in v0.2.0

func NewChatService(cli runtimeclient.Client, isGpts bool) (*ChatService, error)

func (*ChatService) ChatFile added in v0.2.1

func (cs *ChatService) ChatFile() gin.HandlerFunc

@Summary receive conversational files for one conversation @Schemes @Description receive conversational files for one conversation @Tags application @Accept multipart/form-data @Produce json

@Param namespace header string true "namespace this request is in" @Param app_name formData string true "The app name for this conversation" @Param conversation_id formData string false "The conversation id for this file" @Param file formData file true "This is the file for the conversation"

@Success 200 {object} chat.ChatRespBody @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/conversations/file [post]

func (*ChatService) ChatHandler added in v0.2.0

func (cs *ChatService) ChatHandler() gin.HandlerFunc

@Summary chat with application @Schemes @Description chat with application @Tags application @Accept json @Produce json @Param namespace header string true "namespace this request is in" @Param debug query bool false "Should the chat request be treated as debugging?" @Param request body chat.ChatReqBody true "query params" @Success 200 {object} chat.ChatRespBody "blocking mode, will return all field; streaming mode, only conversation_id, message and created_at will be returned" @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat [post]

func (*ChatService) DeleteConversationHandler added in v0.2.0

func (cs *ChatService) DeleteConversationHandler() gin.HandlerFunc

@Summary delete one conversation @Schemes @Description delete one conversation @Tags application @Accept json @Produce json @Param conversationID path string true "conversationID" @Success 200 {object} chat.SimpleResp @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/conversations/:conversationID [delete]

func (*ChatService) HistoryHandler added in v0.2.0

func (cs *ChatService) HistoryHandler() gin.HandlerFunc

@Summary get all messages history for one conversation @Schemes @Description get all messages history for one conversation @Tags application @Accept json @Produce json @Param namespace header string true "namespace this request is in" @Param request body chat.ConversationReqBody true "query params" @Success 200 {object} storage.Conversation @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/messages [post]

func (*ChatService) ListConversationHandler added in v0.2.0

func (cs *ChatService) ListConversationHandler() gin.HandlerFunc

@Summary list all conversations @Schemes @Description list all conversations @Tags application @Accept json @Produce json @Param namespace header string true "namespace this request is in" @Param request body chat.APPMetadata false "query params, if not set will return all current user's conversations" @Success 200 {object} []storage.Conversation @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/conversations [post]

func (*ChatService) PromptStartersHandler added in v0.2.0

func (cs *ChatService) PromptStartersHandler() gin.HandlerFunc

@Summary get app's prompt starters @Schemes @Description get app's prompt starters @Tags application @Accept json @Produce json @Param namespace header string true "namespace this request is in" @Param limit query int false "how many prompts you need should > 0 and < 10" @Param request body chat.APPMetadata true "query params" @Success 200 {object} []string @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/prompt-starter [post]

func (*ChatService) ReferenceHandler added in v0.2.0

func (cs *ChatService) ReferenceHandler() gin.HandlerFunc

@Summary get one message references @Schemes @Description get one message's references @Tags application @Accept json @Produce json @Param namespace header string true "namespace this request is in" @Param messageID path string true "messageID" @Param request body chat.MessageReqBody true "query params" @Success 200 {object} []retriever.Reference @Failure 400 {object} chat.ErrorResp @Failure 500 {object} chat.ErrorResp @Router /chat/messages/:messageID/references [post]

type Chunk

type Chunk struct {
	PartNumber int    `json:"partNubmer"`
	ETag       string `json:"etag"`
	Size       int64  `json:"size"`
}

type CompleteBody

type CompleteBody struct {
	MD5        string `json:"md5"`
	UploadID   string `json:"uploadID"`
	Bucket     string `json:"bucket"`
	FileName   string `json:"fileName"`
	BucketPath string `json:"bucketPath"`
}

type DelteFileBody

type DelteFileBody struct {
	Files      []string `json:"files"`
	Bucket     string   `json:"bucket"`
	BucketPath string   `json:"bucketPath"`
}

type FrowarAPI added in v0.2.1

type FrowarAPI struct{}

FrowarAPI is the forward api handler which forward requests to other services

func (*FrowarAPI) Revisions added in v0.2.1

func (f *FrowarAPI) Revisions(ctx *gin.Context)

func (*FrowarAPI) Summary added in v0.2.1

func (f *FrowarAPI) Summary(ctx *gin.Context)

type GenChunkURLBody

type GenChunkURLBody struct {
	PartNumber int    `json:"partNumber"`
	Size       int64  `json:"size"`
	MD5        string `json:"md5"`
	UploadID   string `json:"uploadID"`
	Bucket     string `json:"bucket"`
	FileName   string `json:"fileName"`
	BucketPath string `json:"bucketPath"`
}

type GenChunkURLResult

type GenChunkURLResult struct {
	Completed bool   `json:"completed"`
	URL       string `json:"url"`
}

type NewMultipartBody

type NewMultipartBody struct {
	// How many pieces do we have to divide it into?
	ChunkCount int `json:"chunkCount"`
	// part size
	Size int64 `json:"size"`
	// file md5
	MD5 string `json:"md5"`

	// The file is eventually stored in bucketPath/filtName in the bucket.
	Bucket     string `json:"bucket"`
	FileName   string `json:"fileName"`
	BucketPath string `json:"bucketPath"`
}

type RagAPI added in v0.2.0

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

func (*RagAPI) ReportDetail added in v0.2.0

func (r *RagAPI) ReportDetail(ctx *gin.Context)

@Summary Get detail data of a rag @Schemes @Description Get detail data of a rag @Tags RAG @Accept json @Produce json @Param ragName query string true "rag name" @Param namespace header string true "Namespace of the rag" @Param page query int false "default is 1" @Param size query string false "default is 10" @Param sortBy query string false "rag metrcis" @Param order query string false "desc or asc" @Success 200 {object} rag.ReportDetail @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /rags/detail [get]

func (*RagAPI) ReportScatter added in v0.2.0

func (r *RagAPI) ReportScatter(ctx *gin.Context)

@Summary Get scatter data of a rag @Schemes @Description Get scatter data of a rag @Tags RAG @Accept json @Produce json @Param ragName query string true "rag name" @Param namespace header string true "Namespace of the rag" @Success 200 {object} rag.ReportDetail @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /rags/scatter [get]

func (*RagAPI) Summary added in v0.2.0

func (r *RagAPI) Summary(ctx *gin.Context)

@Summary Get a summary of rag @Schemes @Description Get a summary of rag @Tags RAG @Accept json @Produce json @Param ragName query string true "rag name" @Param namespace header string true "Namespace of the rag" @Success 200 {object} rag.Report @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /rags/report [get]

type SuccessChunksResult

type SuccessChunksResult struct {
	Done     bool    `json:"done"`
	UploadID string  `json:"uploadID,omitempty"`
	Chunks   []Chunk `json:"chunks,omitempty"`
}

type SummaryResp added in v0.2.1

type SummaryResp struct {
	Summary string `json:"summary"`
}

type WebCrawlerFileBody added in v0.2.0

type WebCrawlerFileBody struct {
	VersionedDataset string `json:"versioneddataset" binding:"required"`
	Datasource       string `json:"datasource" binding:"required"`

	// Params to generate a web crawler file
	Params struct {
		URL *string `json:"url,omitempty"`
		// Params
		IntervalTime   *int     `json:"interval_time,omitempty"`
		ResourceTypes  []string `json:"resource_types,omitempty"`
		MaxDepth       int      `json:"max_depth,omitempty"`
		MaxCount       int      `json:"max_count,omitempty"`
		ExcludeSubUrls []string `json:"exclude_sub_urls,omitempty"`
		IncludeSubUrls []string `json:"include_sub_urls,omitempty"`
		ExcludeImgInfo struct {
			Weight int `json:"weight,omitempty"`
			Height int `json:"height,omitempty"`
		} `json:"exclude_img_info,omitempty"`
	} `json:"params"`
}

Jump to

Keyboard shortcuts

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