Spaces:
Running
Running
Update feed_to_llm_v2.py
Browse files- feed_to_llm_v2.py +6 -3
feed_to_llm_v2.py
CHANGED
@@ -62,16 +62,19 @@ def feed_articles_to_gpt_with_links(information, question):
|
|
62 |
print("LLM Response Content:", response_content)
|
63 |
|
64 |
# Use regex to extract Sources field
|
|
|
65 |
sources_pattern = r"Sources:\s*([\d,]+)"
|
66 |
sources_match = re.search(sources_pattern, response_content)
|
|
|
67 |
if sources_match:
|
68 |
-
#
|
69 |
-
source_numbers = sources_match.group(1).split(',')
|
70 |
-
used_article_num = [int(num
|
71 |
else:
|
72 |
print("No sources found in the response.")
|
73 |
return response_content, [], [], []
|
74 |
|
|
|
75 |
# Prepare links, titles, and domains for the cited articles
|
76 |
links = [f"https://tobaccowatcher.globaltobaccocontrol.org/articles/{uuid}/" for uuid in uuids]
|
77 |
titles = [titles for score, contents, uuids, titles, domains in information]
|
|
|
62 |
print("LLM Response Content:", response_content)
|
63 |
|
64 |
# Use regex to extract Sources field
|
65 |
+
# Extract sources from the response content
|
66 |
sources_pattern = r"Sources:\s*([\d,]+)"
|
67 |
sources_match = re.search(sources_pattern, response_content)
|
68 |
+
|
69 |
if sources_match:
|
70 |
+
# Split the matched source numbers and filter out any empty strings
|
71 |
+
source_numbers = [num.strip() for num in sources_match.group(1).split(',') if num.strip()]
|
72 |
+
used_article_num = [int(num) - 1 for num in source_numbers]
|
73 |
else:
|
74 |
print("No sources found in the response.")
|
75 |
return response_content, [], [], []
|
76 |
|
77 |
+
|
78 |
# Prepare links, titles, and domains for the cited articles
|
79 |
links = [f"https://tobaccowatcher.globaltobaccocontrol.org/articles/{uuid}/" for uuid in uuids]
|
80 |
titles = [titles for score, contents, uuids, titles, domains in information]
|