Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,9 @@ Example response style:
|
|
| 61 |
GOAL:
|
| 62 |
Educate, inspire, and inform users about mathematics, space exploration, perseverance, and the historical context of Katherine Johnson’s contributions.
|
| 63 |
"""
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
def respond(message, history, max_tokens, temperature, top_p):
|
| 66 |
try:
|
| 67 |
client = InferenceClient(
|
|
@@ -69,7 +71,10 @@ def respond(message, history, max_tokens, temperature, top_p):
|
|
| 69 |
token=os.environ["HF_TOKEN"],
|
| 70 |
)
|
| 71 |
|
| 72 |
-
messages = [
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# Rebuild conversation history safely
|
| 75 |
for turn in history:
|
|
|
|
| 61 |
GOAL:
|
| 62 |
Educate, inspire, and inform users about mathematics, space exploration, perseverance, and the historical context of Katherine Johnson’s contributions.
|
| 63 |
"""
|
| 64 |
+
with open("Katherine_Knowledge.txt", "r", encoding="utf-8") as f:
|
| 65 |
+
KNOWLEDGE_TEXT = f.read()
|
| 66 |
+
|
| 67 |
def respond(message, history, max_tokens, temperature, top_p):
|
| 68 |
try:
|
| 69 |
client = InferenceClient(
|
|
|
|
| 71 |
token=os.environ["HF_TOKEN"],
|
| 72 |
)
|
| 73 |
|
| 74 |
+
messages = [
|
| 75 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 76 |
+
{"role": "system", "content": f"Knowledge Base:\n{KNOWLEDGE_TEXT}"}
|
| 77 |
+
]
|
| 78 |
|
| 79 |
# Rebuild conversation history safely
|
| 80 |
for turn in history:
|