Skip to content

Commit

Permalink
fix: when no related doc is found, should return retriever.spec.docNu…
Browse files Browse the repository at this point in the history
…llReturn

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
  • Loading branch information
Abirdcfly committed Jan 19, 2024
1 parent 736803e commit 26b4b17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/appruntime/retriever/knowledgebaseretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,15 @@ type KnowledgeBaseStuffDocuments struct {
References []Reference
}

var _ chains.Chain = &KnowledgeBaseStuffDocuments{}
var _ callbacks.Handler = &KnowledgeBaseStuffDocuments{}
func (c *KnowledgeBaseStuffDocuments) GetCallbackHandler() callbacks.Handler {
return c
}

var (
_ chains.Chain = &KnowledgeBaseStuffDocuments{}
_ callbacks.Handler = &KnowledgeBaseStuffDocuments{}
_ callbacks.HandlerHaver = &KnowledgeBaseStuffDocuments{}
)

func (c *KnowledgeBaseStuffDocuments) joinDocuments(ctx context.Context, docs []langchaingoschema.Document) string {
logger := klog.FromContext(ctx)
Expand Down
14 changes: 14 additions & 0 deletions tests/example-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,26 @@ kubectl apply -f config/samples/app_retrievalqachain_knowledgebase.yaml
waitCRDStatusReady "Application" "arcadia" "base-chat-with-knowledgebase"
sleep 3
getRespInAppChat "base-chat-with-knowledgebase" "arcadia" "旷工最小计算单位为多少天?" "" "true"
info "8.2.1.2 When no releated doc is found, return retriever.spec.docNullReturn info"

Check failure on line 368 in tests/example-test.sh

View workflow job for this annotation

GitHub Actions / misspellings

releated ==> related
getRespInAppChat "base-chat-with-knowledgebase" "arcadia" "飞天的主演是谁?" "" "false"
expected=$(kubectl get knowledgebaseretrievers -n arcadia base-chat-with-knowledgebase -o json | jq -r .spec.docNullReturn)
if [[ $ai_data != $expected ]]; then
echo "when no releated doc is found, return retriever.spec.docNullReturn info should be:"$expected ", but resp:"$resp

Check failure on line 372 in tests/example-test.sh

View workflow job for this annotation

GitHub Actions / misspellings

releated ==> related
exit 1
fi

info "8.2.2 QA app using knowledgebase base on pgvector"
kubectl apply -f config/samples/app_retrievalqachain_knowledgebase_pgvector.yaml
waitCRDStatusReady "Application" "arcadia" "base-chat-with-knowledgebase-pgvector"
sleep 3
getRespInAppChat "base-chat-with-knowledgebase" "arcadia" "旷工最小计算单位为多少天?" "" "true"
info "8.2.2.2 When no releated doc is found, return retriever.spec.docNullReturn info"

Check failure on line 381 in tests/example-test.sh

View workflow job for this annotation

GitHub Actions / misspellings

releated ==> related
getRespInAppChat "base-chat-with-knowledgebase" "arcadia" "飞天的主演是谁?" "" "false"
expected=$(kubectl get knowledgebaseretrievers -n arcadia base-chat-with-knowledgebase -o json | jq -r .spec.docNullReturn)
if [[ $ai_data != $expected ]]; then
echo "when no releated doc is found, return retriever.spec.docNullReturn info should be:"$expected ", but resp:"$resp

Check failure on line 385 in tests/example-test.sh

View workflow job for this annotation

GitHub Actions / misspellings

releated ==> related
exit 1
fi

info "8.3 conversation chat app"
kubectl apply -f config/samples/app_llmchain_chat_with_bot.yaml
Expand Down

0 comments on commit 26b4b17

Please sign in to comment.