Skip to content

Commit

Permalink
fix multiple retrieval in knowledge node (langgenius#8942)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored Sep 30, 2024
1 parent 7850a28 commit 625e4c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def _fetch_dataset_retriever(self, node_data: KnowledgeRetrievalNodeData, query:
source["content"] = segment.get_sign_content()
retrieval_resource_list.append(source)
if retrieval_resource_list:
retrieval_resource_list = sorted(retrieval_resource_list, key=lambda x: x.get("score"), reverse=True)
retrieval_resource_list = sorted(
retrieval_resource_list, key=lambda x: x.get("metadata").get("score"), reverse=True
)
position = 1
for item in retrieval_resource_list:
item["metadata"]["position"] = position
Expand Down
4 changes: 2 additions & 2 deletions api/services/website_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ def get_crawl_status(cls, job_id: str, provider: str) -> dict:
@classmethod
def get_crawl_url_data(cls, job_id: str, provider: str, url: str, tenant_id: str) -> dict | None:
credentials = ApiKeyAuthService.get_auth_credentials(tenant_id, "website", provider)
# decrypt api_key
api_key = encrypter.decrypt_token(tenant_id=tenant_id, token=credentials.get("config").get("api_key"))
if provider == "firecrawl":
file_key = "website_files/" + job_id + ".txt"
if storage.exists(file_key):
data = storage.load_once(file_key)
if data:
data = json.loads(data.decode("utf-8"))
else:
# decrypt api_key
api_key = encrypter.decrypt_token(tenant_id=tenant_id, token=credentials.get("config").get("api_key"))
firecrawl_app = FirecrawlApp(api_key=api_key, base_url=credentials.get("config").get("base_url", None))
result = firecrawl_app.check_crawl_status(job_id)
if result.get("status") != "completed":
Expand Down

0 comments on commit 625e4c4

Please sign in to comment.