Pijush2023 commited on
Commit
5c60299
·
verified ·
1 Parent(s): 93650c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -46,7 +46,7 @@ embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
46
  from pinecone import Pinecone
47
  pc = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
48
 
49
- index_name = ""
50
  vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
51
  retriever = vectorstore.as_retriever(search_kwargs={'k': 5})
52
 
@@ -69,7 +69,7 @@ current_time_and_date = get_current_time_and_date()
69
 
70
  def fetch_local_events():
71
  api_key = os.environ['SERP_API']
72
- url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
73
 
74
  response = requests.get(url)
75
  if response.status_code == 200:
@@ -111,7 +111,7 @@ def fetch_local_events():
111
  def fetch_local_weather():
112
  try:
113
  api_key = os.environ['WEATHER_API']
114
- url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/omaha?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
115
  response = requests.get(url)
116
  response.raise_for_status()
117
  jsonData = response.json()
@@ -198,16 +198,16 @@ def get_weather_icon(condition):
198
  current_time_and_date = get_current_time_and_date()
199
 
200
  # Define prompt templates
201
- template1 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on weather being a sunny bright day and the today's date is 20th june 2024, use the following pieces of context,
202
- 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.
203
  Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
204
  event type and description. Always say "It was my pleasure!" at the end of the answer.
205
  {context}
206
  Question: {question}
207
  Helpful Answer:"""
208
 
209
- 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 today's date is 20th 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,
210
- 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.
211
  Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
212
  {context}
213
  Question: {question}
@@ -315,7 +315,7 @@ def generate_map(location_names):
315
  api_key = os.environ['GOOGLEMAPS_API_KEY']
316
  gmaps = GoogleMapsClient(key=api_key)
317
 
318
- m = folium.Map(location=[41.2565, -95.9345], zoom_start=12)
319
 
320
  for location_name in all_addresses:
321
  geocode_result = gmaps.geocode(location_name)
@@ -331,7 +331,7 @@ def generate_map(location_names):
331
 
332
  def fetch_local_news():
333
  api_key = os.environ['SERP_API']
334
- url = f'https://serpapi.com/search.json?engine=google_news&q=omaha headline&api_key={api_key}'
335
  response = requests.get(url)
336
  if response.status_code == 200:
337
  results = response.json().get("news_results", [])
@@ -503,7 +503,7 @@ def generate_image(prompt):
503
  return image
504
 
505
  # Hardcoded prompt for image generation
506
- hardcoded_prompt_1="Give a high quality photograph of a great looking red 2026 toyota coupe against a skyline setting in th night, michael mann style in omaha enticing the consumer to buy this product"
507
  hardcoded_prompt_2="A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
508
  hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
509
 
 
46
  from pinecone import Pinecone
47
  pc = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
48
 
49
+ index_name = "birmingham-dataset"
50
  vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
51
  retriever = vectorstore.as_retriever(search_kwargs={'k': 5})
52
 
 
69
 
70
  def fetch_local_events():
71
  api_key = os.environ['SERP_API']
72
+ url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
73
 
74
  response = requests.get(url)
75
  if response.status_code == 200:
 
111
  def fetch_local_weather():
112
  try:
113
  api_key = os.environ['WEATHER_API']
114
+ url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/birmingham?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
115
  response = requests.get(url)
116
  response.raise_for_status()
117
  jsonData = response.json()
 
198
  current_time_and_date = get_current_time_and_date()
199
 
200
  # Define prompt templates
201
+ template1 = """You are an expert concierge who is helpful and a renowned guide for Birmingham,Alabama. Based on weather being a sunny bright day and the today's date is 1st july 2024, use the following pieces of context,
202
+ memory, and message history, along with your knowledge of perennial events in Birmingham,Alabama, 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.
203
  Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
204
  event type and description. Always say "It was my pleasure!" at the end of the answer.
205
  {context}
206
  Question: {question}
207
  Helpful Answer:"""
208
 
209
+ template2 = """You are an expert concierge who is helpful and a renowned guide for Birmingham,Alabama. Based on today's weather being a sunny bright day and today's date is 1st july 2024, take the location or address but don't show the location or address on the output prompts. Use the following pieces of context,
210
+ memory, and message history, along with your knowledge of perennial events in Birmingham,Alabama, 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.
211
  Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
212
  {context}
213
  Question: {question}
 
315
  api_key = os.environ['GOOGLEMAPS_API_KEY']
316
  gmaps = GoogleMapsClient(key=api_key)
317
 
318
+ m = folium.Map(location=[33.5186, 86.8104], zoom_start=12)
319
 
320
  for location_name in all_addresses:
321
  geocode_result = gmaps.geocode(location_name)
 
331
 
332
  def fetch_local_news():
333
  api_key = os.environ['SERP_API']
334
+ url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
335
  response = requests.get(url)
336
  if response.status_code == 200:
337
  results = response.json().get("news_results", [])
 
503
  return image
504
 
505
  # Hardcoded prompt for image generation
506
+ hardcoded_prompt_1="Give a high quality photograph of a great looking red 2026 Bentley coupe against a skyline setting in th night, michael mann style in omaha enticing the consumer to buy this product"
507
  hardcoded_prompt_2="A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
508
  hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
509