b3ndur commited on
Commit
0f46d1b
·
1 Parent(s): 1bad0b2

edit response

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -112,14 +112,14 @@ def get_similar_places(user_embedding):
112
  ranked_results = sorted(similarities, key=lambda x: (x[1], x[0]['Rating']), reverse=True)
113
  return ranked_results
114
 
115
- # Get top 5 destinations
116
- def get_top_5_destinations(user_query):
117
  normalized_query = normalize_query(user_query)
118
  user_embedding = get_user_embedding(normalized_query)
119
  similar_places = get_similar_places(user_embedding)
120
  if not similar_places:
121
  return "Tidak ada tempat yang ditemukan."
122
- return similar_places[:5]
123
 
124
  # Generate response using Groq VM
125
  def generate_response(user_query, top_places, temperature):
@@ -130,6 +130,7 @@ def generate_response(user_query, top_places, temperature):
130
  ])
131
  system_prompt = """
132
  You are a tour guide assistant. Present the tourism recommendations to the user in Bahasa Indonesia.
 
133
  """
134
  response = client.chat.completions.create(
135
  model="llama-3.1-70b-versatile",
@@ -146,7 +147,7 @@ def generate_response(user_query, top_places, temperature):
146
 
147
  # Main chatbot function
148
  def chatbot(user_query, temperature):
149
- top_places = get_top_5_destinations(user_query)
150
  if isinstance(top_places, str):
151
  return top_places
152
  response = generate_response(user_query, top_places[:5], temperature)
 
112
  ranked_results = sorted(similarities, key=lambda x: (x[1], x[0]['Rating']), reverse=True)
113
  return ranked_results
114
 
115
+ # Get top 10 destinations
116
+ def get_top_10_destinations(user_query):
117
  normalized_query = normalize_query(user_query)
118
  user_embedding = get_user_embedding(normalized_query)
119
  similar_places = get_similar_places(user_embedding)
120
  if not similar_places:
121
  return "Tidak ada tempat yang ditemukan."
122
+ return similar_places[:10]
123
 
124
  # Generate response using Groq VM
125
  def generate_response(user_query, top_places, temperature):
 
130
  ])
131
  system_prompt = """
132
  You are a tour guide assistant. Present the tourism recommendations to the user in Bahasa Indonesia.
133
+ Only and must only return 5 places that suitable what user wants and provided the data in a clear and concise format.
134
  """
135
  response = client.chat.completions.create(
136
  model="llama-3.1-70b-versatile",
 
147
 
148
  # Main chatbot function
149
  def chatbot(user_query, temperature):
150
+ top_places = get_top_10_destinations(user_query)
151
  if isinstance(top_places, str):
152
  return top_places
153
  response = generate_response(user_query, top_places[:5], temperature)