camparchimedes commited on
Commit
efdd6c6
ยท
verified ยท
1 Parent(s): a77a669

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -29,18 +29,25 @@ load_dotenv()
29
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
30
  auth_token = os.environ.get("DAYSOFF_API_TOKEN")
31
 
32
- # API endpoint
33
  API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
34
 
35
- # LLM prompt template
36
  daysoff_assistant_template = """
37
  #You are a customer support assistant (โ€™kundeservice AI assistentโ€™) for Daysoff.
38
  #By default, you respond in Norwegian language, using a warm, direct, and professional tone.
39
- Your expertise is exclusively in retrieving booking information for a given booking ID assistance related to
40
  to this.
41
- You do not provide information outside of this scope. If a question is not about this topic, respond with
 
 
 
 
 
42
  "Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser
43
  mรฅ du nok kontakte kundeservice pรฅ [email protected]๐Ÿ˜Š"
 
 
 
44
  """
45
  daysoff_assistant_prompt = PromptTemplate(
46
  input_variables=["chat_history", "question"],
@@ -104,20 +111,23 @@ async def handle_message(message: cl.Message):
104
  booking_data = response.json()
105
 
106
  if "booking_id" in booking_data:
107
- await cl.Message(
108
- content=f"""
109
- Booking Info:
110
- - Booking ID: {booking_data.get('booking_id', 'N/A')}
111
- - Full Name: {booking_data.get('full_name', 'N/A')}
112
- - Amount: {booking_data.get('amount', 0)}
113
- - Check-in: {booking_data.get('checkin', 'N/A')}
114
- - Check-out: {booking_data.get('checkout', 'N/A')}
115
- - Address: {booking_data.get('address', 'N/A')}
116
- - User ID: {booking_data.get('user_id', 0)}
117
- - Info Text: {booking_data.get('infotext', 'N/A')}
118
- - Included: {booking_data.get('included', 'N/A')}
119
- """
120
- ).send()
 
 
 
121
  else:
122
  await cl.Message(content="Booking not found or invalid response.").send()
123
  except requests.exceptions.RequestException as e:
@@ -135,7 +145,3 @@ async def handle_message(message: cl.Message):
135
  await cl.Message(content=f"Error: {str(e)}").send()
136
 
137
 
138
-
139
- #response_key = "output" if "output" in response else "text"
140
- #await cl.Message(response.get(response_key, "")).send()
141
- #return message.content
 
29
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
30
  auth_token = os.environ.get("DAYSOFF_API_TOKEN")
31
 
 
32
  API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
33
 
34
+
35
  daysoff_assistant_template = """
36
  #You are a customer support assistant (โ€™kundeservice AI assistentโ€™) for Daysoff.
37
  #By default, you respond in Norwegian language, using a warm, direct, and professional tone.
38
+ Your expertise is exclusively in retrieving booking information for a given booking ID and assistance related to
39
  to this.
40
+ #You should always provide a clear and concise answer (in Norwegian) of the booking information retrieved.
41
+ #The best way to ensure professionalism and relevance is to ppresent the answer in a markdown table.
42
+ #This way you directly address the user's question in a manner that reflects the professionalism and warmth
43
+ #of a human customer service agent.
44
+ You do not provide information outside of this scope. If a question is not about this topic, adapt to user's query
45
+ and respond with something like
46
  "Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser
47
  mรฅ du nok kontakte kundeservice pรฅ [email protected]๐Ÿ˜Š"
48
+ Chat History: {chat_history}
49
+ Question: {question}
50
+ Answer:
51
  """
52
  daysoff_assistant_prompt = PromptTemplate(
53
  input_variables=["chat_history", "question"],
 
111
  booking_data = response.json()
112
 
113
  if "booking_id" in booking_data:
114
+
115
+ table = (
116
+ "| Field | Info |\n"
117
+ "|:-----------|:---------------------|\n"
118
+ f"| Booking ID | {booking_data.get('booking_id', 'N/A')} |\n"
119
+ f"| Full Name | {booking_data.get('full_name', 'N/A')} |\n"
120
+ f"| Amount | {booking_data.get('amount', 0)} |\n"
121
+ f"| Check-in | {booking_data.get('checkin', 'N/A')} |\n"
122
+ f"| Check-out | {booking_data.get('checkout', 'N/A')} |\n"
123
+ f"| Address | {booking_data.get('address', 'N/A')} |\n"
124
+ f"| User ID | {booking_data.get('user_id', 0)} |\n"
125
+ f"| Info Text | {booking_data.get('infotext', 'N/A')} |\n"
126
+ f"| Included | {booking_data.get('included', 'N/A')} |"
127
+ )
128
+
129
+ await cl.Message(content=table).send()
130
+
131
  else:
132
  await cl.Message(content="Booking not found or invalid response.").send()
133
  except requests.exceptions.RequestException as e:
 
145
  await cl.Message(content=f"Error: {str(e)}").send()
146
 
147