feat: 优化后端知识库服务和文档解析
- 更新文档解析客户端 - 优化知识库服务逻辑 - 更新 protobuf 定义 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,16 @@ type ParseResult struct {
|
||||
ParserEngine string
|
||||
}
|
||||
|
||||
// VLMConfig VLM 模型配置
|
||||
type VLMConfig struct {
|
||||
Enabled bool
|
||||
Provider string // openai, anthropic, local 等
|
||||
Model string
|
||||
APIKey string
|
||||
BaseURL string
|
||||
Prompt string
|
||||
}
|
||||
|
||||
// NewAICoreClient 创建 AI-Core 客户端
|
||||
func NewAICoreClient(address string) (*AICoreClient, error) {
|
||||
return &AICoreClient{address: address}, nil
|
||||
@@ -56,7 +66,8 @@ func (c *AICoreClient) Close() {
|
||||
}
|
||||
|
||||
// ParseDocument 解析文档 - 使用生成的 protobuf 代码
|
||||
func (c *AICoreClient) ParseDocument(fileURL, fileName, fileType string) (*ParseResult, error) {
|
||||
// vlmConfig 可选,如果不使用 VLM 传 nil
|
||||
func (c *AICoreClient) ParseDocument(fileURL, fileName, fileType string, vlmConfig *VLMConfig) (*ParseResult, error) {
|
||||
if c.conn == nil {
|
||||
if err := c.Connect(); err != nil {
|
||||
return nil, err
|
||||
@@ -72,6 +83,18 @@ func (c *AICoreClient) ParseDocument(fileURL, fileName, fileType string) (*Parse
|
||||
FileType: fileType,
|
||||
}
|
||||
|
||||
// 如果提供了 VLM 配置,添加到请求中
|
||||
if vlmConfig != nil {
|
||||
req.VlmConfig = &docparser.VLMConfig{
|
||||
Enabled: vlmConfig.Enabled,
|
||||
Provider: vlmConfig.Provider,
|
||||
Model: vlmConfig.Model,
|
||||
ApiKey: vlmConfig.APIKey,
|
||||
BaseUrl: vlmConfig.BaseURL,
|
||||
Prompt: vlmConfig.Prompt,
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user