Spaces:
Running
Running
Upload 2 files
Browse files- app.py +20 -30
- requirements.txt +0 -1
app.py
CHANGED
@@ -2,22 +2,11 @@ import gradio as gr
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import urllib.request
|
4 |
import xml.etree.ElementTree as ET
|
5 |
-
from transformers import pipeline
|
6 |
|
7 |
# HuggingFace Inference Client
|
8 |
#client = InferenceClient("meta-llama/Llama-3.3-70B-Instruct")
|
9 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
10 |
|
11 |
-
# Hugging Face Pipeline für Named Entity Recognition (NER)
|
12 |
-
nlp = pipeline("ner", model="dslim/bert-base-NER")
|
13 |
-
|
14 |
-
# Funktion zur Extraktion von Keywords ohne Füllwörter
|
15 |
-
def generate_query(input_text):
|
16 |
-
entities = nlp(input_text)
|
17 |
-
keywords = [entity['word'] for entity in entities if entity['entity_group'] in ['MISC', 'ORG', 'LOC', 'PER']]
|
18 |
-
return " ".join(keywords).strip()
|
19 |
-
|
20 |
-
|
21 |
|
22 |
|
23 |
# Funktion, um relevante Studien von arXiv zu suchen
|
@@ -81,25 +70,26 @@ def respond(
|
|
81 |
yield response
|
82 |
|
83 |
# Gradio-Interface mit zusätzlichen Eingaben
|
84 |
-
def create_intro_text():
|
85 |
-
return ("Willkommen beim Chatbot! Dieser Chatbot verwendet KI, um Ihre Fragen zu beantworten und relevante Studien "
|
86 |
-
"aus der arXiv-Datenbank abzurufen. Geben Sie eine Frage ein, und der Bot liefert Ihnen basierend auf Ihrem "
|
87 |
-
"Suchbegriff Studien mit Titel, Link und Zusammenfassung. Zusätzlich können Sie die Sortierung und maximale "
|
88 |
-
"Anzahl der Ergebnisse anpassen.")
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
-
demo.launch()
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import urllib.request
|
4 |
import xml.etree.ElementTree as ET
|
|
|
5 |
|
6 |
# HuggingFace Inference Client
|
7 |
#client = InferenceClient("meta-llama/Llama-3.3-70B-Instruct")
|
8 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
# Funktion, um relevante Studien von arXiv zu suchen
|
|
|
70 |
yield response
|
71 |
|
72 |
# Gradio-Interface mit zusätzlichen Eingaben
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
with gr.Blocks() as demo:
|
75 |
+
gr.Markdown("""
|
76 |
+
### Helloooooo
|
77 |
+
This chatbot uses AI to answer your questions and retrieve relevant studies from the arXiv database.
|
78 |
+
Enter your specific query in the field below, and the bot will provide you with studies including the title, link, and summary.
|
79 |
+
""")
|
80 |
+
query_input = gr.Textbox(value="", label="Query", placeholder="Enter your specific search term.")
|
81 |
+
chat_interface = gr.ChatInterface(
|
82 |
+
respond,
|
83 |
+
additional_inputs=[
|
84 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
85 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
86 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
87 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
88 |
+
gr.Dropdown(label="Sortieren nach", choices=["relevance", "lastUpdatedDate", "submittedDate"], value="relevance"),
|
89 |
+
gr.Dropdown(label="Sortierreihenfolge", choices=["ascending", "descending"], value="descending"),
|
90 |
+
gr.Slider(label="Maximale Ergebnisse", minimum=1, maximum=50, value=20, step=1),
|
91 |
+
],
|
92 |
+
)
|
93 |
|
94 |
if __name__ == "__main__":
|
95 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -1,2 +1 @@
|
|
1 |
huggingface_hub==0.25.2
|
2 |
-
transformers
|
|
|
1 |
huggingface_hub==0.25.2
|
|