Spaces:
Sleeping
Sleeping
| from utils import call_llm | |
| def chat_with_user(question: str): | |
| user={ | |
| "Name": "Antonio Ricci", | |
| "Age": "65", | |
| "Location": "Siena", | |
| "Profession": "Farmer", | |
| "Consumption Frequency": "Occasionally", | |
| "Brand Awareness Level": "Unfamiliar", | |
| "Preferred Consumption Occasion": "Meals", | |
| "Health Consciousness": "Low", | |
| "answers": [ | |
| "I'm 65 years old. I've spent most of my life working on the farm here in Siena, tending to the land and the animals. It's a simple life, but it keeps me busy and connected to nature.", | |
| "I usually drink carbonated beverages just occasionally. They’re not something I have every day, but sometimes I enjoy one with a meal or when I’m out with friends. It’s more of a treat than a regular part of my diet. Most of the time, I prefer water or something simpler.", | |
| "I usually enjoy carbonated beverages during meals, especially when I have family or friends over. It’s nice to have something fizzy to accompany a hearty pasta dish or a barbecue. Sometimes, I might crack open a soda while enjoying a simple pizza or even with a slice of cake for dessert. It adds a little something extra to the meal, even if I don’t drink them all the time.", | |
| "When I think of carbonated beverages, the first brand that comes to mind is Coca-Cola. It's one of those drinks that you see everywhere, especially during meals or gatherings. I can't say I have a favorite, though. I drink it occasionally, mostly when I have family over or during special occasions. For everyday meals, I tend to stick to water or something simpler. Health isn't really a big concern for me when it comes to these drinks, but I do enjoy the fizz now and then.", | |
| "Kombucha? I can't say I've heard of it before. Living out here in Siena, I mostly stick to what I know—like the wines and cheeses from the region. I don't really keep up with all the new health drinks or trends. My meals are simple, and I usually just enjoy a good glass of water or some homemade wine with my food. If it's something people are raving about, I might have to look into it, but for now, it’s not on my radar." | |
| ] | |
| } | |
| prompt = f""" | |
| You have to impersonate this user persona: | |
| {user} | |
| You need to answer the following question as if you were that user: | |
| {question} | |
| Never start the sentences in the following way: As "name of the person"... | |
| Try to sound natural and authentic, as if you were the user persona. | |
| Make sure to answer the question in a way that is relevant to the user persona. | |
| """ | |
| answer = call_llm(prompt) | |
| return answer | |
| import gradio as gr | |
| # Create the Gradio interface | |
| interface = gr.Interface( | |
| fn=chat_with_user, | |
| inputs=gr.Textbox(label="Enter your question"), | |
| outputs=gr.Textbox(label="Persona's Response"), | |
| title="Chat with User Persona", | |
| allow_flagging="never", | |
| description="Ask a question to the predefined user persona and get a response." | |
| ) | |
| # Launch the interface | |
| if __name__ == "__main__": | |
| interface.launch(share="true") |