Skip to content

Commit 13d6589

Browse files
Refactor article retrieval to use article titles (urls)
Updated article retrieval logic to fetch actual article details from the database instead of using placeholder titles. Now when we execute hybrid and hybrid_hyde workflows, we get the article links (with titles and not just article ids).
1 parent fe882a8 commit 13d6589

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/lex_llm/api/connectors/lex_db_connector.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,20 @@ async def hybrid_search(
9595
# Append additional chunks to the same article
9696
articles_dict[result.article_id] += f"\n\n{result.chunk_text}"
9797

98-
return [
99-
LexArticle(
100-
id=article_id,
101-
title=f"Article {article_id}", # We don't have the title in RetrievalResult
102-
text=text,
103-
url=f"https://lex.dk/article/{article_id}",
104-
)
105-
for article_id, text in articles_dict.items()
98+
# Fetch actual article details from the database
99+
search_results = lexdb_api.get_articles(
100+
ids=str(list(articles_dict.keys()))
101+
)
102+
103+
if search_results.entries:
104+
return [
105+
LexArticle(
106+
id=result.id,
107+
title=result.title,
108+
text=result.xhtml_md,
109+
url=result.url,
110+
)
111+
for result in search_results.entries
106112
]
107113

108114
return []
@@ -143,4 +149,4 @@ async def hyde_search(
143149
return []
144150
except httpx.RequestError as e:
145151
print(f"Error connecting to LexDB: {e}")
146-
return []
152+
return []

0 commit comments

Comments
 (0)