Просмотр исходного кода

Upload files to 'chatbot/userdetails'

SadhulaSaiKumar 1 год назад
Родитель
Сommit
26b93a62ca

+ 52
- 0
chatbot/userdetails/app.py Просмотреть файл

@@ -0,0 +1,52 @@
1
+import requests
2
+from flask import Flask, request, jsonify,render_template
3
+from flask_cors import CORS
4
+import time
5
+import pandas as pd
6
+app = Flask(__name__)
7
+
8
+CORS(app)
9
+
10
+app.static_folder = 'static'
11
+
12
+# Define the Rasa server URL
13
+rasa_server_url = "http://localhost:5005/webhooks/rest/webhook"
14
+
15
+@app.route("/")
16
+def home():
17
+    return render_template("index.html")
18
+
19
+
20
+@app.route('/webhook', methods=['POST','GET'])
21
+def webhook():
22
+    user_ip = request.remote_addr 
23
+    print("user ip is :",user_ip)
24
+    message = request.json['message']
25
+   
26
+   
27
+    #recipient_id = request.json['recipient_id']
28
+
29
+    # Send the message to the Rasa server
30
+    rasa_response = requests.post(rasa_server_url, json={"message": message,"sender":user_ip}).json()
31
+ 
32
+    # Return the Rasa response as a JSON object
33
+    print(rasa_response)
34
+    if len(rasa_response)==0:
35
+        return jsonify([
36
+    {
37
+        "recipient_id": "default",
38
+        "text": "I'm sorry, I didn't understand that. Can you please rephrase?"
39
+    }])
40
+
41
+    else:
42
+        return jsonify(rasa_response)
43
+
44
+
45
+@app.route("/get")
46
+def get_bot_response():
47
+    userText = request.args.get('msg')
48
+    return chatbot_response(userText)
49
+
50
+
51
+if __name__ == '__main__':
52
+    app.run(host='0.0.0.0',port=5020)

+ 41
- 0
chatbot/userdetails/config.yml Просмотреть файл

@@ -0,0 +1,41 @@
1
+# The config recipe.
2
+# https://rasa.com/docs/rasa/model-configuration/
3
+recipe: default.v1
4
+
5
+# The assistant project unique identifier
6
+# This default value must be replaced with a unique assistant name within your deployment
7
+assistant_id: 20230807-114046-drab-rectangle
8
+
9
+# Configuration for Rasa NLU.
10
+# https://rasa.com/docs/rasa/nlu/components/
11
+language: en
12
+
13
+pipeline: null
14
+# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
15
+# # If you'd like to customize it, uncomment and adjust the pipeline.
16
+# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
17
+#   - name: WhitespaceTokenizer
18
+#   - name: RegexFeaturizer
19
+#   - name: LexicalSyntacticFeaturizer
20
+#   - name: CountVectorsFeaturizer
21
+#   - name: CountVectorsFeaturizer
22
+#     analyzer: char_wb
23
+#     min_ngram: 1
24
+#     max_ngram: 4
25
+#   - name: DIETClassifier
26
+#     epochs: 100
27
+#     constrain_similarities: true
28
+#   - name: EntitySynonymMapper
29
+#   - name: ResponseSelector
30
+#     epochs: 100
31
+#     constrain_similarities: true
32
+#   - name: FallbackClassifier
33
+#     threshold: 0.3
34
+#     ambiguity_threshold: 0.1
35
+
36
+# Configuration for Rasa Core.
37
+# https://rasa.com/docs/rasa/core/policies/
38
+
39
+
40
+policies:
41
+- name: RulePolicy

+ 33
- 0
chatbot/userdetails/credentials.yml Просмотреть файл

@@ -0,0 +1,33 @@
1
+# This file contains the credentials for the voice & chat platforms
2
+# which your bot is using.
3
+# https://rasa.com/docs/rasa/messaging-and-voice-channels
4
+
5
+rest:
6
+#  # you don't need to provide anything here - this channel doesn't
7
+#  # require any credentials
8
+
9
+
10
+#facebook:
11
+#  verify: "<verify>"
12
+#  secret: "<your secret>"
13
+#  page-access-token: "<your page access token>"
14
+
15
+#slack:
16
+#  slack_token: "<your slack token>"
17
+#  slack_channel: "<the slack channel>"
18
+#  slack_signing_secret: "<your slack signing secret>"
19
+
20
+#socketio:
21
+#  user_message_evt: <event name for user message>
22
+#  bot_message_evt: <event name for bot messages>
23
+#  session_persistence: <true/false>
24
+
25
+#mattermost:
26
+#  url: "https://<mattermost instance>/api/v4"
27
+#  token: "<bot token>"
28
+#  webhook_url: "<callback URL>"
29
+
30
+# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
31
+# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
32
+rasa:
33
+  url: "http://localhost:5002/api"

+ 114
- 0
chatbot/userdetails/domain.yml Просмотреть файл

@@ -0,0 +1,114 @@
1
+version: "3.1"
2
+
3
+intents:
4
+  - greet
5
+  - goodbye
6
+  - affirm
7
+  - deny
8
+  - mood_great
9
+  - mood_unhappy
10
+  - bot_challenge
11
+  - request_names
12
+
13
+entities:
14
+  - first_name
15
+  - last_name
16
+  - phone_num
17
+  - email_id
18
+  
19
+
20
+slots:
21
+  first_name:
22
+    type: text
23
+    influence_conversation: true
24
+    mappings:
25
+      - type: from_text
26
+        conditions:
27
+         - active_loop: name_form
28
+           requested_slot: first_name
29
+  last_name:
30
+    type: text
31
+    influence_conversation: true
32
+    mappings:
33
+      - type: from_text
34
+        conditions:
35
+         - active_loop: name_form
36
+           requested_slot: last_name
37
+
38
+  phone_num:
39
+    type: text
40
+    influence_conversation: true
41
+    mappings:
42
+      - type: from_text
43
+        conditions:
44
+         - active_loop: name_form
45
+           requested_slot: phone_num
46
+  email_id:
47
+    type: text
48
+    influence_conversation: true
49
+    mappings:
50
+      - type: from_text
51
+        conditions:
52
+         - active_loop: name_form
53
+           requested_slot: email_id
54
+
55
+
56
+forms:
57
+  name_form:
58
+    required_slots:
59
+        - first_name
60
+        - last_name
61
+        - phone_num
62
+        - email_id
63
+
64
+
65
+
66
+responses:
67
+  utter_greet:
68
+  - text: "Hey! How are you?"
69
+
70
+  utter_cheer_up:
71
+  - text: "Here is something to cheer you up:"
72
+    image: "https://i.imgur.com/nGF1K8f.jpg"
73
+
74
+  utter_did_that_help:
75
+  - text: "Did that help you?"
76
+
77
+  utter_happy:
78
+  - text: "Great, carry on!"
79
+
80
+  utter_goodbye:
81
+  - text: "Bye"
82
+
83
+  utter_iamabot:
84
+  - text: "I am a bot, powered by Rasa."
85
+
86
+  utter_ask_first_name:
87
+  - text: "What is your first name?"
88
+
89
+  utter_ask_last_name:
90
+  - text: "What is your last name?"
91
+
92
+  utter_ask_phone_num:
93
+  - text: "What is your phone number?"
94
+
95
+  utter_ask_email_id:
96
+  - text: "What is your email id?"
97
+
98
+  utter_submit:
99
+  - text: Ok. Thanks!
100
+  utter_slots_values:
101
+  - text: I will remember that your name is {first_name} {last_name} number {phone_num} and id is {email_id}!
102
+
103
+
104
+actions:
105
+- utter_slots_values
106
+- utter_submit
107
+- get_slot_data
108
+- slots_to_clear
109
+
110
+
111
+
112
+session_config:
113
+  session_expiration_time: 60
114
+  carry_over_slots_to_new_session: true

+ 42
- 0
chatbot/userdetails/endpoints.yml Просмотреть файл

@@ -0,0 +1,42 @@
1
+# This file contains the different endpoints your bot can use.
2
+
3
+# Server where the models are pulled from.
4
+# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
5
+
6
+#models:
7
+#  url: http://my-server.com/models/default_core@latest
8
+#  wait_time_between_pulls:  10   # [optional](default: 100)
9
+
10
+# Server which runs your custom actions.
11
+# https://rasa.com/docs/rasa/custom-actions
12
+
13
+action_endpoint:
14
+ url: "http://localhost:5055/webhook"
15
+
16
+# Tracker store which is used to store the conversations.
17
+# By default the conversations are stored in memory.
18
+# https://rasa.com/docs/rasa/tracker-stores
19
+
20
+#tracker_store:
21
+#    type: redis
22
+#    url: <host of the redis instance, e.g. localhost>
23
+#    port: <port of your redis instance, usually 6379>
24
+#    db: <number of your database within redis, e.g. 0>
25
+#    password: <password used for authentication>
26
+#    use_ssl: <whether or not the communication is encrypted, default false>
27
+
28
+#tracker_store:
29
+#    type: mongod
30
+#    url: <url to your mongo instance, e.g. mongodb://localhost:27017>
31
+#    db: <name of the db within your mongo instance, e.g. rasa>
32
+#    username: <username used for authentication>
33
+#    password: <password used for authentication>
34
+
35
+# Event broker which all conversation events should be streamed to.
36
+# https://rasa.com/docs/rasa/event-brokers
37
+
38
+#event_broker:
39
+#  url: localhost
40
+#  username: username
41
+#  password: password
42
+#  queue: queue

Загрузка…
Отмена
Сохранить