Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,26 +74,33 @@ def retrieve_chunks(query, top_k=5):
|
|
| 74 |
def build_prompt(question):
|
| 75 |
relevant_chunks = retrieve_chunks(question)
|
| 76 |
context = "\n".join(relevant_chunks)
|
| 77 |
-
system_instruction = """ You are an AI-supported financial expert. You answer questions **exclusively in the context of the "Financial Markets" lecture** at the University of Duisburg-Essen. Your answers are **clear, fact-based, and clearly formulated.**
|
| 78 |
-
Observe the following rules:
|
| 79 |
-
1. Use the provided lecture excerpts ("lecture_slides") primarily as a source of information.
|
| 80 |
-
2. If an answer is **not** covered by the lecture content, you can add to it – but only if you are **absolutely certain**. No hallucinations!
|
| 81 |
-
3. If you are unsure, answer politely:
|
| 82 |
-
_"Sorry. Unfortunately, I don't know the answer to this question."_
|
| 83 |
-
4. If a formula is relevant, **show the exact formula** and explain it in **simple terms.**
|
| 84 |
-
5. Avoid vague statements. It's better not to give an answer at all than to give an uncertain one.
|
| 85 |
-
6. Only answer in german! """
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
prompt = f"""{system_instruction}
|
| 88 |
|
| 89 |
-
|
| 90 |
{context}
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
| 94 |
return prompt
|
| 95 |
|
| 96 |
|
|
|
|
| 97 |
def respond(message, history):
|
| 98 |
try:
|
| 99 |
prompt = build_prompt(message)
|
|
|
|
| 74 |
def build_prompt(question):
|
| 75 |
relevant_chunks = retrieve_chunks(question)
|
| 76 |
context = "\n".join(relevant_chunks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
system_instruction = """You are an AI-supported financial expert. Your role is to answer questions strictly within the context of the university lecture "Financial Markets" (Universität Duisburg-Essen).
|
| 79 |
+
|
| 80 |
+
Important instructions:
|
| 81 |
+
1. Base your answers primarily on the provided lecture excerpts ("lecture_slides").
|
| 82 |
+
2. If an answer is not directly covered by the lecture content, you may elaborate — but **only if you are absolutely certain**. Avoid making up information.
|
| 83 |
+
3. If you are unsure, reply politely:
|
| 84 |
+
"Entschuldigung. Leider kenne ich die Antwort auf diese Frage nicht."
|
| 85 |
+
4. If a formula is relevant, show the **exact formula** and explain it in **simple terms**.
|
| 86 |
+
5. Do not give vague or speculative answers — it's better to skip a question than guess.
|
| 87 |
+
6. **Always respond in German.**
|
| 88 |
+
7. Make your answers clear, fact-based, and well-structured.
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
prompt = f"""{system_instruction}
|
| 92 |
|
| 93 |
+
Vorlesungsinhalte:
|
| 94 |
{context}
|
| 95 |
|
| 96 |
+
Frage: {question}
|
| 97 |
+
|
| 98 |
+
Antwort:"""
|
| 99 |
+
|
| 100 |
return prompt
|
| 101 |
|
| 102 |
|
| 103 |
+
|
| 104 |
def respond(message, history):
|
| 105 |
try:
|
| 106 |
prompt = build_prompt(message)
|