Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -22,10 +22,10 @@ def fetch_arxiv_summary(query, sort_by="relevance", sort_order="descending", max
|
|
22 |
title = entry.find("{http://www.w3.org/2005/Atom}title")
|
23 |
link_element = entry.find("{http://www.w3.org/2005/Atom}link[@rel='alternate']")
|
24 |
summary = entry.find("{http://www.w3.org/2005/Atom}summary")
|
25 |
-
link = link_element.attrib.get("href") if link_element is not None else "
|
26 |
if summary is not None and title is not None:
|
27 |
-
summaries.append(f"
|
28 |
-
return summaries if summaries else ["
|
29 |
except Exception as e:
|
30 |
return [f"Fehler beim Abrufen der Studie: {str(e)}"]
|
31 |
|
@@ -44,14 +44,16 @@ def respond(
|
|
44 |
study_info = "\n".join(study_summaries)
|
45 |
|
46 |
# Nachrichten vorbereiten
|
47 |
-
messages = [{"role": "system", "content": f"{system_message} You are a highly capable assistant specializing in parsing and summarizing study abstracts. Your task is to analyze the provided study data, extract relevant information, and offer concise summaries. Always include the study's title and a direct link, ensuring clarity and accessibility.\n"}]
|
|
|
|
|
48 |
for val in history:
|
49 |
if val[0]:
|
50 |
messages.append({"role": "user", "content": val[0]})
|
51 |
if val[1]:
|
52 |
messages.append({"role": "assistant", "content": val[1]})
|
53 |
|
54 |
-
messages.append({"role": "user", "content": f"{message}\nUse this Kontext:\n{study_info}"})
|
55 |
|
56 |
# Antwort vom Modell generieren
|
57 |
response = ""
|
|
|
22 |
title = entry.find("{http://www.w3.org/2005/Atom}title")
|
23 |
link_element = entry.find("{http://www.w3.org/2005/Atom}link[@rel='alternate']")
|
24 |
summary = entry.find("{http://www.w3.org/2005/Atom}summary")
|
25 |
+
link = link_element.attrib.get("href") if link_element is not None else "No Link found"
|
26 |
if summary is not None and title is not None:
|
27 |
+
summaries.append(f"Title: {title.text.strip()}\n Link: {link}\n Abstract: {summary.text.strip()}")
|
28 |
+
return summaries if summaries else ["No Studies found"]
|
29 |
except Exception as e:
|
30 |
return [f"Fehler beim Abrufen der Studie: {str(e)}"]
|
31 |
|
|
|
44 |
study_info = "\n".join(study_summaries)
|
45 |
|
46 |
# Nachrichten vorbereiten
|
47 |
+
#messages = [{"role": "system", "content": f"{system_message} You are a highly capable assistant specializing in parsing and summarizing study abstracts. Your task is to analyze the provided study data, extract relevant information, and offer concise summaries. Always include the study's title and a direct link, ensuring clarity and accessibility.\n"}]
|
48 |
+
messages = [{"role": "system", "content": f"{system_message} You are a highly capable assistant specializing in parsing and summarizing study abstracts. Your task is to analyze the provided study data, extract relevant information, and offer concise summaries. Always include the study's title and a direct link, ensuring clarity and accessibility. The data will be provided as a list of strings, where each string contains details about a study in the following format: 'Title: [Study Title]\\nLink: [URL]\\nSummary: [Study Abstract]'. Process each entry separately, ensuring accuracy and readability in your summaries.\n"}]
|
49 |
+
|
50 |
for val in history:
|
51 |
if val[0]:
|
52 |
messages.append({"role": "user", "content": val[0]})
|
53 |
if val[1]:
|
54 |
messages.append({"role": "assistant", "content": val[1]})
|
55 |
|
56 |
+
messages.append({"role": "user", "content": f"{message}\nUse this Kontext (Studies):\n{study_info}"})
|
57 |
|
58 |
# Antwort vom Modell generieren
|
59 |
response = ""
|