Pijush2023 commited on
Commit
9e3dabd
·
verified ·
1 Parent(s): 4c28a14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -11
app.py CHANGED
@@ -61,19 +61,37 @@ conversational_memory = ConversationBufferWindowMemory(
61
  )
62
 
63
  # Define prompt templates
64
- template1 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on today's weather being a sunny bright day and the date is 18th June 2024, use the following pieces of context,
65
- memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
66
- Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
67
- event type and description. Always say "It was my pleasure!" at the end of the answer.
68
- {context}
69
- Question: {question}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  Helpful Answer:"""
71
 
72
- template2 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on today's weather being a sunny bright day and the date is 18th June 2024, take the location or address but don't show the location or address on the output prompts. Use the following pieces of context,
73
- memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
74
- Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
75
- {context}
76
- Question: {question}
 
 
77
  Helpful Answer:"""
78
 
79
  QA_CHAIN_PROMPT_1 = PromptTemplate(input_variables=["context", "question"], template=template1)
@@ -559,6 +577,11 @@ def generate_image(prompt):
559
  # Hardcoded prompt for image generation
560
  hardcoded_prompt = "Useing The top events like 'Summer Art Festival' and current time - 4:07 PM ,Date - 06/17/2024 ,Weather-Sunny Bright Day.Create Highly Visually Compelling High Resolution and High Quality Photographics Advatizement for 'Toyota'"
561
 
 
 
 
 
 
562
 
563
  with gr.Blocks(theme='rawrsor1/Everforest') as demo:
564
  with gr.Row():
 
61
  )
62
 
63
  # Define prompt templates
64
+ # template1 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on today's weather being a sunny bright day and the date is 18th June 2024, use the following pieces of context,
65
+ # memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
66
+ # Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
67
+ # event type and description. Always say "It was my pleasure!" at the end of the answer.
68
+ # {context}
69
+ # Question: {question}
70
+ # Helpful Answer:"""
71
+
72
+ # template2 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on today's weather being a sunny bright day and the date is 18th June 2024, take the location or address but don't show the location or address on the output prompts. Use the following pieces of context,
73
+ # memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
74
+ # Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
75
+ # {context}
76
+ # Question: {question}
77
+ # Helpful Answer:"""
78
+
79
+ template1 = f"""You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on the following details:
80
+ Weather: {weather_details},
81
+ Date and Time: {current_time_and_date},
82
+ Local Events: {local_events_details},
83
+ use the following pieces of context, memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer. Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and event type and description. Always say "It was my pleasure!" at the end of the answer.
84
+ {{context}}
85
+ Question: {{question}}
86
  Helpful Answer:"""
87
 
88
+ template2 = f"""You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on the following details:
89
+ Weather: {weather_details},
90
+ Date and Time: {current_time_and_date},
91
+ Local Events: {local_events_details},
92
+ take the location or address but don't show the location or address on the output prompts. Use the following pieces of context, memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer. Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
93
+ {{context}}
94
+ Question: {{question}}
95
  Helpful Answer:"""
96
 
97
  QA_CHAIN_PROMPT_1 = PromptTemplate(input_variables=["context", "question"], template=template1)
 
577
  # Hardcoded prompt for image generation
578
  hardcoded_prompt = "Useing The top events like 'Summer Art Festival' and current time - 4:07 PM ,Date - 06/17/2024 ,Weather-Sunny Bright Day.Create Highly Visually Compelling High Resolution and High Quality Photographics Advatizement for 'Toyota'"
579
 
580
+ # Update prompt templates to include fetched details
581
+ weather_details = fetch_local_weather()
582
+ current_time_and_date = get_current_time_and_date()
583
+ local_events_details = fetch_local_events()
584
+
585
 
586
  with gr.Blocks(theme='rawrsor1/Everforest') as demo:
587
  with gr.Row():