Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,18 +14,17 @@ def get_wikipedia_summary(name):
|
|
| 14 |
return page.summary if page.exists() else "Sorry, I couldn't find information on that historical figure."
|
| 15 |
|
| 16 |
def generate_persona_response(person_name, user_input, context):
|
| 17 |
-
"""Generate a
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
return f"My armies rode thousands of miles across mountains and deserts. Do you seek adventure?"
|
| 24 |
else:
|
| 25 |
return random.choice([
|
| 26 |
-
f"
|
| 27 |
-
f"
|
| 28 |
-
f"
|
| 29 |
])
|
| 30 |
|
| 31 |
st.title("Chat with a Historical Figure!")
|
|
|
|
| 14 |
return page.summary if page.exists() else "Sorry, I couldn't find information on that historical figure."
|
| 15 |
|
| 16 |
def generate_persona_response(person_name, user_input, context):
|
| 17 |
+
"""Generate a response based on the Wikipedia summary dynamically."""
|
| 18 |
+
sentences = context.split('.')
|
| 19 |
+
relevant_info = [sentence for sentence in sentences if any(word in sentence.lower() for word in user_input.lower().split())]
|
| 20 |
+
|
| 21 |
+
if relevant_info:
|
| 22 |
+
return random.choice(relevant_info) + '.'
|
|
|
|
| 23 |
else:
|
| 24 |
return random.choice([
|
| 25 |
+
f"An interesting question. I have much knowledge to share—what else do you wish to know?",
|
| 26 |
+
f"Tell me, why does this interest you? Perhaps we may discover more together.",
|
| 27 |
+
f"My life was complex and filled with challenges. Ask again, and I shall elaborate."
|
| 28 |
])
|
| 29 |
|
| 30 |
st.title("Chat with a Historical Figure!")
|