Skip to content

Commit

Permalink
fix: zhipu embedding error with empty string
Browse files Browse the repository at this point in the history
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
  • Loading branch information
Abirdcfly committed Mar 22, 2024
1 parent 8d3e355 commit 0d329e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apiserver/pkg/chat/chat_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (cs *ChatServer) ListPromptStarters(ctx context.Context, req APPMetadata, l
content := bytes.Buffer{}
// if there is a knowledgebase, use it to generate prompt starter
if kb != nil {
outArg, finish, err := retriever.GenerateKnowledgebaseRetriever(ctx, c, kb.Name, kb.Namespace, apiretriever.CommonRetrieverConfig{NumDocuments: limit}, map[string]any{"question": "开始"})
outArg, finish, err := retriever.GenerateKnowledgebaseRetriever(ctx, c, kb.Name, kb.Namespace, apiretriever.CommonRetrieverConfig{NumDocuments: limit * 2}, map[string]any{"question": "开始"})
if err != nil {
return nil, err
}
Expand All @@ -314,6 +314,9 @@ func (cs *ChatServer) ListPromptStarters(ctx context.Context, req APPMetadata, l
question := strings.TrimSuffix(d.PageContent, "\na: "+answer)
promptStarters = append(promptStarters, strings.TrimPrefix(question, "q: "))
hasAnswer = true
if len(promptStarters) == limit {
break
}
}
}
if !hasAnswer {
Expand Down

0 comments on commit 0d329e3

Please sign in to comment.