Skip to content

Commit

Permalink
Checking DSL's (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
1AhmedYasser authored May 10, 2024
1 parent 3c109fe commit eab97d7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 68 deletions.
42 changes: 21 additions & 21 deletions DSL/Ruuter.public/DSL/POST/internal/external-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ declaration:
post_answer:
call: http.post
args:
url: "PLACEHOLDER-URL"
url: "[#CHATBOT_EXTERNAL_BOT_URL]"
headers:
"Content-Type": "application/json"
"api-key": "PLACEHOLDER-API-KEY"
"api-key": "[#CHATBOT_EXTERNAL_API_KEY]"
body:
dataSources:
- type: AzureCognitiveSearch
parameters:
"endpoint": "https://gptproov.search.windows.net"
"indexName": "proov"
"semanticConfiguration": "default"
"queryType": "simple"
"fieldsMapping": {}
"inScope": false
"roleInformation": "You are a government AI assistant who helps out questions with taxes and social services. If the question is not in English, answer in the language used in the question. In any other case ALWAYS answer in Estonian. When you cannot find the answer in the sources that you are given, then say that you don't know and if there is anything else you can help them with."
"filter":
"strictness": 3
"topNDocuments": 5
"key": "PLACEHOLDER-KEY"
- type: AzureCognitiveSearch
parameters:
"endpoint": "https://gptproov.search.windows.net"
"indexName": "proov"
"semanticConfiguration": "default"
"queryType": "simple"
"fieldsMapping": {}
"inScope": false
"roleInformation": "You are a government AI assistant who helps out questions with taxes and social services. If the question is not in English, answer in the language used in the question. In any other case ALWAYS answer in Estonian. When you cannot find the answer in the sources that you are given, then say that you don't know and if there is anything else you can help them with."
"filter":
"strictness": 3
"topNDocuments": 5
"key": "[#CHATBOT_EXTERNAL_KEY]"
messages:
- "role": "system"
"content": "You are a government AI assistant who helps out questions with taxes and social services. If the question is not in English, answer in the language used in the question. In any other case ALWAYS answer in Estonian. When you cannot find the answer in the sources that you are given, then say that you don't know and if there is anything else you can help them with."
- "role": "user"
"content": ${incoming.body.message}
- "role": "system"
"content": "You are a government AI assistant who helps out questions with taxes and social services. If the question is not in English, answer in the language used in the question. In any other case ALWAYS answer in Estonian. When you cannot find the answer in the sources that you are given, then say that you don't know and if there is anything else you can help them with."
- "role": "user"
"content": ${incoming.body.message}
deployment: "finetune"
temperature: 0
top_p: 1
Expand All @@ -52,8 +52,8 @@ post_answer:
assign_value:
assign:
correct_value:
- recipient_id: ${incoming.body.sender}
text: ${test.response.body.choices[0].message.content.replace(/\n/g," ")}
- recipient_id: ${incoming.body.sender}
text: ${test.response.body.choices[0].message.content.replace(/\n/g," ")}
next: return_value

return_value:
Expand Down
96 changes: 50 additions & 46 deletions DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ get_chat:
body:
id: ${chatId}
result: get_chat_result
next: check_for_get_chat_result
next: check_for_get_chat_result

check_for_get_chat_result:
switch:
Expand Down Expand Up @@ -100,6 +100,8 @@ check_if_bot_is_unable_to_reply:
switch:
- condition: ${post_message_to_client_result.response.body[0].text == 'UNKNOWN'}
next: check_for_fallback_bot
- condition: ${post_message_to_client_result.response.body[0].text == 'Suunan teid klienditeenindajale. Varuge natukene kannatust.'}
next: get_organization_working_details
next: extract_bot_responses

check_for_fallback_bot:
Expand Down Expand Up @@ -134,27 +136,27 @@ assign_organization_details:
org_details: ${org_res.response.body[0]}
next: check_if_organization_is_available

check_if_organization_is_available:
check_if_organization_is_available:
switch:
- condition: ${org_details.isWithinWorkingTime === true && org_details.isWithinWorkingDays === true && org_details.isAllowedToWorkAtHolidays === true}
next: get_all_available_csas
- condition: ${org_details.isWithinWorkingTime === true && org_details.isWithinWorkingDays === true && org_details.isAllowedToWorkAtHolidays === false && org_details.isHoliday == true}
next: return_is_a_holiday
- condition: ${org_details.isWithinWorkingTime === true && org_details.isWithinWorkingDays === true && org_details.isAllowedToWorkAtHolidays === false && org_details.isHoliday == false}
next: get_all_available_csas
next: get_all_available_csas
next: return_organization_is_not_available

return_is_a_holiday:
call: http.post
args:
url: "[#CHATBOT_RESQL]/insert-bot-message"
body:
messages:
-
messages:
-
chatId: ${chatId}
content: ${org_details.holidayMessage}
authorTimestamp: ${new Date().toISOString()}
event: 'unavailable_holiday'
event: "unavailable_holiday"
authorId: ${get_bot_name_result.response.body[0].value}
authorFirstName: ""
authorLastName: ""
Expand All @@ -167,12 +169,12 @@ return_organization_is_not_available:
args:
url: "[#CHATBOT_RESQL]/insert-bot-message"
body:
messages:
-
messages:
-
chatId: ${chatId}
content: 'Bürokratt on hetkel väljaspool tööaega, palun jäta oma kontaktandmed ja võtame Sinuga esimesel võimalusel ühendust'
content: "Bürokratt on hetkel väljaspool tööaega, palun jäta oma kontaktandmed ja võtame Sinuga esimesel võimalusel ühendust"
authorTimestamp: ${new Date().toISOString()}
event: 'unavailable_organization'
event: "unavailable_organization"
authorId: ${get_bot_name_result.response.body[0].value}
authorFirstName: ""
authorLastName: ""
Expand All @@ -190,7 +192,7 @@ get_all_available_csas:
assign_available_csas:
assign:
available_csas: ${csas_res.response.body.length}
next: check_if_csas_are_available
next: check_if_csas_are_available

check_if_csas_are_available:
switch:
Expand All @@ -203,12 +205,12 @@ send_csas_not_available_message:
args:
url: "[#CHATBOT_RESQL]/insert-bot-message"
body:
messages:
-
messages:
-
chatId: ${chatId}
content: 'Hetkel nõustajad puuduvad, palun jätke oma kontaktandmed ja võtame Teiega esimesel võimalusel ühendust'
content: "Hetkel nõustajad puuduvad, palun jätke oma kontaktandmed ja võtame Teiega esimesel võimalusel ühendust"
authorTimestamp: ${new Date().toISOString()}
event: 'unavailable_csas'
event: "unavailable_csas"
authorId: ${get_bot_name_result.response.body[0].value}
authorFirstName: ""
authorLastName: ""
Expand All @@ -231,7 +233,7 @@ add_chat_id_to_queue_notification_node:
body:
id: ${chatId}
result: add_chat_id_to_queue_notification_node_res

extract_bot_responses:
assign:
botMsg: ${post_message_to_client_result.response.body}
Expand Down Expand Up @@ -260,12 +262,12 @@ check_if_call_service_result_is_ok:

return_ok:
status: 200
return: "Service called successfully"
next: end
return: "Service called successfully"
next: end

return_trigger_service_is_not_exist:
assign:
botMsg: "service_currently_unavailable"
botMsg: "service_currently_unavailable"

convert_bot_responses_to_messages:
call: http.post
Expand All @@ -274,15 +276,16 @@ convert_bot_responses_to_messages:
headers:
type: json
body:
data: {
"botMessages": "${botMsg}",
"chatId": "${chatId}",
"authorId": "${get_bot_name_result.response.body[0].value}",
"authorFirstName": "",
"authorLastName": "",
"authorTimestamp": "${new Date().toISOString()}",
"created": "${new Date().toISOString()}"
}
data:
{
"botMessages": "${botMsg}",
"chatId": "${chatId}",
"authorId": "${get_bot_name_result.response.body[0].value}",
"authorFirstName": "",
"authorLastName": "",
"authorTimestamp": "${new Date().toISOString()}",
"created": "${new Date().toISOString()}",
}
result: converted_messages_res
next: add_bot_message_to_db

Expand All @@ -293,15 +296,16 @@ convert_fallback_bot_responses_to_messages:
headers:
type: json
body:
data: {
"botMessages": "${fallback_bot_result.response.body.response}",
"chatId": "${chatId}",
"authorId": "${get_bot_name_result.response.body[0].value}",
"authorFirstName": "",
"authorLastName": "",
"authorTimestamp": "${new Date().toISOString()}",
"created": "${new Date().toISOString()}"
}
data:
{
"botMessages": "${fallback_bot_result.response.body.response}",
"chatId": "${chatId}",
"authorId": "${get_bot_name_result.response.body[0].value}",
"authorFirstName": "",
"authorLastName": "",
"authorTimestamp": "${new Date().toISOString()}",
"created": "${new Date().toISOString()}",
}
result: converted_messages_res
next: add_bot_message_to_db

Expand All @@ -316,38 +320,38 @@ add_bot_message_to_db:

return_is_holiday:
status: 200
return: "Today is a national holiday"
next: end
return: "Today is a national holiday"
next: end

return_organization_is_not_available_res:
status: 200
return: "Organization is not available"
return: "Organization is not available"
next: end

return_csa_is_not_available:
status: 200
return: "CSA's are not available"
return: "CSA's are not available"
next: end

return_message_sent:
status: 200
return: "Message Sent Successfully"
next: end
next: end

return_chat_does_not_belong_to_bot:
status: 200
return: "Chat does not belong to bot"
next: end
next: end

return_bot_is_not_active:
status: 200
return: "Bot is not active"
next: end
next: end

return_bad_request:
status: 400
return: "Bad Request"
next: end
next: end

return_incorrect_request:
status: 400
Expand Down
4 changes: 3 additions & 1 deletion GUI/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default defineConfig({
},
server: {
headers: {
'Content-Security-Policy': process.env.REACT_APP_CSP,
...(process.env.REACT_APP_CSP && {
'Content-Security-Policy': process.env.REACT_APP_CSP,
}),
},
},
resolve: {
Expand Down
3 changes: 3 additions & 0 deletions constants.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ CHATBOT_OPENSEARCH=http://opensearch-node:9200
CHATBOT_NOTIFICATIONS=http://notifications-node:4040
CHATBOT_NGINX=http://nginx-node:80
CHATBOT_BOT=http://171.22.247.37:5005
CHATBOT_EXTERNAL_BOT_URL=http://bot:5005
CHATBOT_EXTERNAL_API_KEY=local-api-key
CHATBOT_EXTERNAL_KEY=local-key
DOMAIN=localhost
TRAINING_RESQL=http://resql-training:8083
SERVICE_RUUTER_PUBLIC=http://ruuter-public:8086

0 comments on commit eab97d7

Please sign in to comment.