Skip to content

Commit

Permalink
Return only unique source documents (#21)
Browse files Browse the repository at this point in the history
* return only unique source documents

* bump version to 0.3.4
  • Loading branch information
valeksiev authored Jun 4, 2024
1 parent c1f07da commit b9559a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "virtual-contributor-engine-expert"
version = "0.3.3"
version = "0.3.4"
description = "Alkemio Generative AI Virtul Persona"
authors = ["Alkemio BV <[email protected]>"]
license = "EUPL-1.2"
Expand Down
5 changes: 4 additions & 1 deletion virtual_contributor_engine_expert.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ async def query(user_id, message_body, language_code):
)
answer = llm_result["answer"]

unique_sources = {
doc["source"]: doc for doc in llm_result["source_documents"]
}.values()
# clean up the document sources to avoid sending too much information over.
sources = [
{
Expand All @@ -90,7 +93,7 @@ async def query(user_id, message_body, language_code):
),
"uri": doc["source"],
}
for doc in llm_result["source_documents"]
for doc in unique_sources
]
logger.debug(f"\n\nsources: {sources}\n\n")

Expand Down

0 comments on commit b9559a4

Please sign in to comment.