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 authored and 0xff-dev committed Jan 19, 2024
1 parent 36f6e18 commit 360066b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/data_processing_image_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Build KubeAGI Data Processing images
on:
pull_request:
branches: [main]
paths:
- 'pypi/data-processing'
workflow_dispatch:

jobs:
Expand All @@ -27,4 +29,4 @@ jobs:
context: ./pypi/data-processing
file: ./pypi/data-processing/Dockerfile
platforms: linux/amd64,linux/arm64
push: false
push: false
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 related doc is found, return retriever.spec.docNullReturn info"
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 related doc is found, return retriever.spec.docNullReturn info should be:"$expected ", but resp:"$resp
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 related doc is found, return retriever.spec.docNullReturn info"
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 related doc is found, return retriever.spec.docNullReturn info should be:"$expected ", but resp:"$resp
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 360066b

Please sign in to comment.