shukdevdatta123 commited on
Commit
4f634bb
·
verified ·
1 Parent(s): 02231a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -37,10 +37,8 @@ else:
37
  try:
38
  response = openai.ChatCompletion.create(
39
  model="gpt-3.5-turbo", # Ensure using the chat model
40
- messages=[
41
- {"role": "system", "content": "You are a helpful assistant."},
42
- {"role": "user", "content": prompt}
43
- ],
44
  max_tokens=150,
45
  temperature=0.7 # You can adjust temperature for more creative results
46
  )
@@ -48,7 +46,18 @@ else:
48
  except Exception as e:
49
  return f"Error: {str(e)}"
50
 
51
- # Adding GPT-3.5 functionality to your app
 
 
 
 
 
 
 
 
 
 
 
52
  def main():
53
  st.title("Dhaka Local Buses and Routes Finder with GPT Creativity")
54
 
@@ -64,9 +73,15 @@ else:
64
  start_location = st.text_input("Enter your starting location (e.g., Mirpur):")
65
  destination_location = st.text_input("Enter your destination location (e.g., Dhaka University):")
66
  if start_location and destination_location:
67
- route_suggestion_prompt = f"Suggest the best bus route from {start_location} to {destination_location}, considering speed, convenience, and the most popular routes."
68
- route_suggestion = generate_creative_content(route_suggestion_prompt)
69
- st.write(route_suggestion)
 
 
 
 
 
 
70
 
71
  # Bus-Themed Storytelling Section
72
  st.header("Create a Bus-Themed Story!")
 
37
  try:
38
  response = openai.ChatCompletion.create(
39
  model="gpt-3.5-turbo", # Ensure using the chat model
40
+ messages=[{"role": "system", "content": "You are a helpful assistant."},
41
+ {"role": "user", "content": prompt}],
 
 
42
  max_tokens=150,
43
  temperature=0.7 # You can adjust temperature for more creative results
44
  )
 
46
  except Exception as e:
47
  return f"Error: {str(e)}"
48
 
49
+ # Adding this function to find buses between two locations
50
+ def get_buses_between_locations(start_location, destination_location):
51
+ # Filter buses that pass through both the start and destination locations
52
+ buses_start = df[df['Routes'].str.contains(start_location, case=False, na=False)]
53
+ buses_destination = df[df['Routes'].str.contains(destination_location, case=False, na=False)]
54
+
55
+ # Find buses that are common in both filtered dataframes
56
+ common_buses = pd.merge(buses_start, buses_destination, on='Dhaka Local Buses')
57
+
58
+ return common_buses
59
+
60
+ # Main Streamlit function
61
  def main():
62
  st.title("Dhaka Local Buses and Routes Finder with GPT Creativity")
63
 
 
73
  start_location = st.text_input("Enter your starting location (e.g., Mirpur):")
74
  destination_location = st.text_input("Enter your destination location (e.g., Dhaka University):")
75
  if start_location and destination_location:
76
+ # Get buses that pass through both the start and destination locations
77
+ buses_with_common_routes = get_buses_between_locations(start_location, destination_location)
78
+
79
+ if not buses_with_common_routes.empty:
80
+ st.write(f"Suggested buses from **{start_location}** to **{destination_location}**:")
81
+ for idx, row in buses_with_common_routes.iterrows():
82
+ st.write(f"- **{row['Dhaka Local Buses']}**: {clean_route(row['Routes'])}")
83
+ else:
84
+ st.write(f"No buses found passing through both **{start_location}** and **{destination_location}**.")
85
 
86
  # Bus-Themed Storytelling Section
87
  st.header("Create a Bus-Themed Story!")