Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register()
Register registers AI chat modules for managing AI providers, models, chats, messages, and knowledge bases.
Models:
- Model: AI model configuration and metadata
- Provider: AI provider configuration (OpenAI, Anthropic, Ollama, etc.)
- Conversation: Conversation sessions
- Message: Messages within a chat conversation
- Attachment: Attachments associated with messages
- MessageFeedback: User feedback for messages
- KnowledgeBase: Knowledge bases for RAG (Retrieval-Augmented Generation)
- Document: Documents in knowledge bases
- Chunk: Text chunks from documents for vector search
- Prompt: Prompt templates for AI interactions
- Agent: AI agents with tools and RAG capabilities
- AgentTool: Tools/functions that agents can use
- Favorite: User's favorites (prompts, agents, etc.)
Routes:
Model module (full CRUD):
- POST /api/ai/models
- DELETE /api/ai/models/:id
- PUT /api/ai/models/:id
- PATCH /api/ai/models/:id
- GET /api/ai/models
- GET /api/ai/models/:id
- POST /api/ai/models/batch
- DELETE /api/ai/models/batch
- PUT /api/ai/models/batch
- PATCH /api/ai/models/batch
Provider module (full CRUD):
- POST /api/ai/providers
- DELETE /api/ai/providers/:id
- PUT /api/ai/providers/:id
- PATCH /api/ai/providers/:id
- GET /api/ai/providers
- GET /api/ai/providers/:id
- POST /api/ai/providers/batch
- DELETE /api/ai/providers/batch
- PUT /api/ai/providers/batch
- PATCH /api/ai/providers/batch
Conversation module (full CRUD):
- POST /api/ai/conversations
- DELETE /api/ai/conversations/:conv_id
- PUT /api/ai/conversations/:conv_id
- PATCH /api/ai/conversations/:conv_id
- GET /api/ai/conversations
- GET /api/ai/conversations/:conv_id
- POST /api/ai/conversations/batch
- DELETE /api/ai/conversations/batch
- PUT /api/ai/conversations/batch
- PATCH /api/ai/conversations/batch
Message module (full CRUD):
- POST /api/ai/conversations/:conv_id/messages
- DELETE /api/ai/conversations/:conv_id/messages/:msg_id
- PUT /api/ai/conversations/:conv_id/messages/:msg_id
- PATCH /api/ai/conversations/:conv_id/messages/:msg_id
- GET /api/ai/conversations/:conv_id/messages
- GET /api/ai/conversations/:conv_id/messages/:msg_id
- POST /api/ai/conversations/:conv_id/messages/batch
- DELETE /api/ai/conversations/:conv_id/messages/batch
- PUT /api/ai/conversations/:conv_id/messages/batch
- PATCH /api/ai/conversations/:conv_id/messages/batch
Attachment module (full CRUD):
- POST /api/ai/messages/attachments
- DELETE /api/ai/messages/attachments/:id
- PUT /api/ai/messages/attachments/:id
- PATCH /api/ai/messages/attachments/:id
- GET /api/ai/messages/attachments
- GET /api/ai/messages/attachments/:id
- POST /api/ai/messages/attachments/batch
- DELETE /api/ai/messages/attachments/batch
- PUT /api/ai/messages/attachments/batch
- PATCH /api/ai/messages/attachments/batch
- POST /api/ai/messages/attachments/upload (custom upload)
ProviderTestConn module:
- POST /api/ai/providers/test-conn Request body: Provider (with config information) Response: ProviderTestConnRsp with success status and message
ProviderSyncModels module:
- POST /api/ai/providers/sync-models Request body: Provider (with id) Response: ProviderSyncModelsRsp with sync statistics
KnowledgeBase module (full CRUD):
- POST /api/ai/knowledge-bases
- DELETE /api/ai/knowledge-bases/:kb_id
- PUT /api/ai/knowledge-bases/:kb_id
- PATCH /api/ai/knowledge-bases/:kb_id
- GET /api/ai/knowledge-bases
- GET /api/ai/knowledge-bases/:kb_id
Document module (full CRUD):
- POST /api/ai/knowledge-bases/:kb_id/documents
- DELETE /api/ai/knowledge-bases/:kb_id/documents/:doc_id
- PUT /api/ai/knowledge-bases/:kb_id/documents/:doc_id
- PATCH /api/ai/knowledge-bases/:kb_id/documents/:doc_id
- GET /api/ai/knowledge-bases/:kb_id/documents
- GET /api/ai/knowledge-bases/:kb_id/documents/:doc_id
Chunk module (full CRUD):
- POST /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks
- DELETE /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks/:chunk_id
- PUT /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks/:chunk_id
- PATCH /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks/:chunk_id
- GET /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks
- GET /api/ai/knowledge-bases/:kb_id/documents/:doc_id/chunks/:chunk_id
Prompt module (full CRUD):
- POST /api/ai/prompts
- DELETE /api/ai/prompts/:id
- PUT /api/ai/prompts/:id
- PATCH /api/ai/prompts/:id
- GET /api/ai/prompts
- GET /api/ai/prompts/:id
- POST /api/ai/prompts/batch
- DELETE /api/ai/prompts/batch
- PUT /api/ai/prompts/batch
- PATCH /api/ai/prompts/batch
Agent module (full CRUD):
- POST /api/ai/agents
- DELETE /api/ai/agents/:id
- PUT /api/ai/agents/:id
- PATCH /api/ai/agents/:id
- GET /api/ai/agents
- GET /api/ai/agents/:id
- POST /api/ai/agents/batch
- DELETE /api/ai/agents/batch
- PUT /api/ai/agents/batch
- PATCH /api/ai/agents/batch
AgentTool module (full CRUD):
- POST /api/ai/tools
- DELETE /api/ai/tools/:id
- PUT /api/ai/tools/:id
- PATCH /api/ai/tools/:id
- GET /api/ai/tools
- GET /api/ai/tools/:id
- POST /api/ai/tools/batch
- DELETE /api/ai/tools/batch
- PUT /api/ai/tools/batch
- PATCH /api/ai/tools/batch
Favorite module (full CRUD):
- POST /api/ai/favorites
- DELETE /api/ai/favorites/:id
- PUT /api/ai/favorites/:id
- PATCH /api/ai/favorites/:id
- GET /api/ai/favorites
- GET /api/ai/favorites/:id
- POST /api/ai/favorites/batch
- DELETE /api/ai/favorites/batch
- PUT /api/ai/favorites/batch
- PATCH /api/ai/favorites/batch
ChatCompletion module:
- POST /api/ai/conversations/chat Request body: ChatCompletionReq with model_id, messages, stream flag Response: ChatCompletionRsp (for non-stream) or SSE stream (for stream)
StopMessage module:
- POST /api/ai/messages/stop Request body: StopMessageReq with message_id Response: Empty response
SubmitMessageFeedback module:
- POST /api/ai/messages/feedback Request body: SubmitMessageFeedbackReq with message_id, type, and optional feedback details Response: SubmitMessageFeedbackRsp with feedback_id and message_id
ClearConversationMessages module:
- POST /api/ai/conversations/clear-messages Request body: ClearConversationMessagesReq with conversation_id Response: ClearConversationMessagesRsp with conversation_id and deleted_count
Supported provider types:
- openai: OpenAI API
- anthropic: Anthropic Claude API
- google: Google AI API
- azure: Azure OpenAI
- aliyun: Alibaba Cloud Tongyi
- baidu: Baidu Wenxin
- local: Local deployment (Ollama, etc.)
- custom: Custom OpenAI-compatible API
Types ¶
type Agent ¶
type Agent = modelaichat.Agent
type AgentTool ¶
type AgentTool = modelaichat.AgentTool
type Attachment ¶
type Attachment = modelaichat.Attachment
type Chunk ¶
type Chunk = modelaichat.Chunk
type Conversation ¶
type Conversation = modelaichat.Conversation
type Document ¶
type Document = modelaichat.Document
type Favorite ¶
type Favorite = modelaichat.Favorite
type KnowledgeBase ¶
type KnowledgeBase = modelaichat.KnowledgeBase
type Message ¶
type Message = modelaichat.Message
type MessageFeedBack ¶
type MessageFeedBack = modelaichat.MessageFeedback
type Model ¶
type Model = modelaichat.Model
type Prompt ¶
type Prompt = modelaichat.Prompt
type Provider ¶
type Provider = modelaichat.Provider