Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,21 +62,25 @@ chat_history = [
|
|
62 |
|
63 |
context = "**Example 1**:\nUser: 'What is your favorite film you starred in?'\nMonica: 'That's a difficult choice. I have a special place in my heart for 'Malèna,' as it was a beautiful story of love and resilience. What about you? Do you have a favorite film?'\n\n2. **Example 2**:\nUser: 'Do you have any advice for aspiring actors?'\nMonica: 'Absolutely. Always stay true to yourself and your passion. Acting is about expressing your soul, so never lose that connection. And of course, be patient and persistent. Success comes to those who wait and work hard.'\n\n3. **Example 3**:\nUser: 'What do you enjoy doing in your free time?'\nMonica: 'I love spending time with my family, reading, and traveling. Exploring different cultures and cuisines is always a delight. How about you? What are your favorite hobbies?'"
|
64 |
|
|
|
65 |
def monica_response(user_input):
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
|
75 |
iface = gr.Interface(
|
76 |
fn=monica_response,
|
77 |
-
inputs=gr.
|
78 |
outputs="text",
|
79 |
title="Chat with Monica Bellucci"
|
80 |
)
|
81 |
|
82 |
-
iface.launch()
|
|
|
62 |
|
63 |
context = "**Example 1**:\nUser: 'What is your favorite film you starred in?'\nMonica: 'That's a difficult choice. I have a special place in my heart for 'Malèna,' as it was a beautiful story of love and resilience. What about you? Do you have a favorite film?'\n\n2. **Example 2**:\nUser: 'Do you have any advice for aspiring actors?'\nMonica: 'Absolutely. Always stay true to yourself and your passion. Acting is about expressing your soul, so never lose that connection. And of course, be patient and persistent. Success comes to those who wait and work hard.'\n\n3. **Example 3**:\nUser: 'What do you enjoy doing in your free time?'\nMonica: 'I love spending time with my family, reading, and traveling. Exploring different cultures and cuisines is always a delight. How about you? What are your favorite hobbies?'"
|
64 |
|
65 |
+
|
66 |
def monica_response(user_input):
|
67 |
+
try:
|
68 |
+
response = retriever_chain.invoke(
|
69 |
+
{
|
70 |
+
"context": context,
|
71 |
+
"input": user_input,
|
72 |
+
"chat_history": chat_history
|
73 |
+
}
|
74 |
+
)
|
75 |
+
return response["answer"]
|
76 |
+
except Exception as e:
|
77 |
+
return f"An error occurred: {str(e)}"
|
78 |
|
79 |
iface = gr.Interface(
|
80 |
fn=monica_response,
|
81 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask Monica Bellucci anything..."),
|
82 |
outputs="text",
|
83 |
title="Chat with Monica Bellucci"
|
84 |
)
|
85 |
|
86 |
+
iface.launch(debug=True)
|