Upload files to 'chatbot/userdetails'
Этот коммит содержится в:
@@ -0,0 +1,52 @@
|
|||||||
|
import requests
|
||||||
|
from flask import Flask, request, jsonify,render_template
|
||||||
|
from flask_cors import CORS
|
||||||
|
import time
|
||||||
|
import pandas as pd
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
CORS(app)
|
||||||
|
|
||||||
|
app.static_folder = 'static'
|
||||||
|
|
||||||
|
# Define the Rasa server URL
|
||||||
|
rasa_server_url = "http://localhost:5005/webhooks/rest/webhook"
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def home():
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/webhook', methods=['POST','GET'])
|
||||||
|
def webhook():
|
||||||
|
user_ip = request.remote_addr
|
||||||
|
print("user ip is :",user_ip)
|
||||||
|
message = request.json['message']
|
||||||
|
|
||||||
|
|
||||||
|
#recipient_id = request.json['recipient_id']
|
||||||
|
|
||||||
|
# Send the message to the Rasa server
|
||||||
|
rasa_response = requests.post(rasa_server_url, json={"message": message,"sender":user_ip}).json()
|
||||||
|
|
||||||
|
# Return the Rasa response as a JSON object
|
||||||
|
print(rasa_response)
|
||||||
|
if len(rasa_response)==0:
|
||||||
|
return jsonify([
|
||||||
|
{
|
||||||
|
"recipient_id": "default",
|
||||||
|
"text": "I'm sorry, I didn't understand that. Can you please rephrase?"
|
||||||
|
}])
|
||||||
|
|
||||||
|
else:
|
||||||
|
return jsonify(rasa_response)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/get")
|
||||||
|
def get_bot_response():
|
||||||
|
userText = request.args.get('msg')
|
||||||
|
return chatbot_response(userText)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0',port=5020)
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# The config recipe.
|
||||||
|
# https://rasa.com/docs/rasa/model-configuration/
|
||||||
|
recipe: default.v1
|
||||||
|
|
||||||
|
# The assistant project unique identifier
|
||||||
|
# This default value must be replaced with a unique assistant name within your deployment
|
||||||
|
assistant_id: 20230807-114046-drab-rectangle
|
||||||
|
|
||||||
|
# Configuration for Rasa NLU.
|
||||||
|
# https://rasa.com/docs/rasa/nlu/components/
|
||||||
|
language: en
|
||||||
|
|
||||||
|
pipeline: null
|
||||||
|
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
|
||||||
|
# # If you'd like to customize it, uncomment and adjust the pipeline.
|
||||||
|
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
|
||||||
|
# - name: WhitespaceTokenizer
|
||||||
|
# - name: RegexFeaturizer
|
||||||
|
# - name: LexicalSyntacticFeaturizer
|
||||||
|
# - name: CountVectorsFeaturizer
|
||||||
|
# - name: CountVectorsFeaturizer
|
||||||
|
# analyzer: char_wb
|
||||||
|
# min_ngram: 1
|
||||||
|
# max_ngram: 4
|
||||||
|
# - name: DIETClassifier
|
||||||
|
# epochs: 100
|
||||||
|
# constrain_similarities: true
|
||||||
|
# - name: EntitySynonymMapper
|
||||||
|
# - name: ResponseSelector
|
||||||
|
# epochs: 100
|
||||||
|
# constrain_similarities: true
|
||||||
|
# - name: FallbackClassifier
|
||||||
|
# threshold: 0.3
|
||||||
|
# ambiguity_threshold: 0.1
|
||||||
|
|
||||||
|
# Configuration for Rasa Core.
|
||||||
|
# https://rasa.com/docs/rasa/core/policies/
|
||||||
|
|
||||||
|
|
||||||
|
policies:
|
||||||
|
- name: RulePolicy
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# This file contains the credentials for the voice & chat platforms
|
||||||
|
# which your bot is using.
|
||||||
|
# https://rasa.com/docs/rasa/messaging-and-voice-channels
|
||||||
|
|
||||||
|
rest:
|
||||||
|
# # you don't need to provide anything here - this channel doesn't
|
||||||
|
# # require any credentials
|
||||||
|
|
||||||
|
|
||||||
|
#facebook:
|
||||||
|
# verify: "<verify>"
|
||||||
|
# secret: "<your secret>"
|
||||||
|
# page-access-token: "<your page access token>"
|
||||||
|
|
||||||
|
#slack:
|
||||||
|
# slack_token: "<your slack token>"
|
||||||
|
# slack_channel: "<the slack channel>"
|
||||||
|
# slack_signing_secret: "<your slack signing secret>"
|
||||||
|
|
||||||
|
#socketio:
|
||||||
|
# user_message_evt: <event name for user message>
|
||||||
|
# bot_message_evt: <event name for bot messages>
|
||||||
|
# session_persistence: <true/false>
|
||||||
|
|
||||||
|
#mattermost:
|
||||||
|
# url: "https://<mattermost instance>/api/v4"
|
||||||
|
# token: "<bot token>"
|
||||||
|
# webhook_url: "<callback URL>"
|
||||||
|
|
||||||
|
# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
|
||||||
|
# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
|
||||||
|
rasa:
|
||||||
|
url: "http://localhost:5002/api"
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
version: "3.1"
|
||||||
|
|
||||||
|
intents:
|
||||||
|
- greet
|
||||||
|
- goodbye
|
||||||
|
- affirm
|
||||||
|
- deny
|
||||||
|
- mood_great
|
||||||
|
- mood_unhappy
|
||||||
|
- bot_challenge
|
||||||
|
- request_names
|
||||||
|
|
||||||
|
entities:
|
||||||
|
- first_name
|
||||||
|
- last_name
|
||||||
|
- phone_num
|
||||||
|
- email_id
|
||||||
|
|
||||||
|
|
||||||
|
slots:
|
||||||
|
first_name:
|
||||||
|
type: text
|
||||||
|
influence_conversation: true
|
||||||
|
mappings:
|
||||||
|
- type: from_text
|
||||||
|
conditions:
|
||||||
|
- active_loop: name_form
|
||||||
|
requested_slot: first_name
|
||||||
|
last_name:
|
||||||
|
type: text
|
||||||
|
influence_conversation: true
|
||||||
|
mappings:
|
||||||
|
- type: from_text
|
||||||
|
conditions:
|
||||||
|
- active_loop: name_form
|
||||||
|
requested_slot: last_name
|
||||||
|
|
||||||
|
phone_num:
|
||||||
|
type: text
|
||||||
|
influence_conversation: true
|
||||||
|
mappings:
|
||||||
|
- type: from_text
|
||||||
|
conditions:
|
||||||
|
- active_loop: name_form
|
||||||
|
requested_slot: phone_num
|
||||||
|
email_id:
|
||||||
|
type: text
|
||||||
|
influence_conversation: true
|
||||||
|
mappings:
|
||||||
|
- type: from_text
|
||||||
|
conditions:
|
||||||
|
- active_loop: name_form
|
||||||
|
requested_slot: email_id
|
||||||
|
|
||||||
|
|
||||||
|
forms:
|
||||||
|
name_form:
|
||||||
|
required_slots:
|
||||||
|
- first_name
|
||||||
|
- last_name
|
||||||
|
- phone_num
|
||||||
|
- email_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
responses:
|
||||||
|
utter_greet:
|
||||||
|
- text: "Hey! How are you?"
|
||||||
|
|
||||||
|
utter_cheer_up:
|
||||||
|
- text: "Here is something to cheer you up:"
|
||||||
|
image: "https://i.imgur.com/nGF1K8f.jpg"
|
||||||
|
|
||||||
|
utter_did_that_help:
|
||||||
|
- text: "Did that help you?"
|
||||||
|
|
||||||
|
utter_happy:
|
||||||
|
- text: "Great, carry on!"
|
||||||
|
|
||||||
|
utter_goodbye:
|
||||||
|
- text: "Bye"
|
||||||
|
|
||||||
|
utter_iamabot:
|
||||||
|
- text: "I am a bot, powered by Rasa."
|
||||||
|
|
||||||
|
utter_ask_first_name:
|
||||||
|
- text: "What is your first name?"
|
||||||
|
|
||||||
|
utter_ask_last_name:
|
||||||
|
- text: "What is your last name?"
|
||||||
|
|
||||||
|
utter_ask_phone_num:
|
||||||
|
- text: "What is your phone number?"
|
||||||
|
|
||||||
|
utter_ask_email_id:
|
||||||
|
- text: "What is your email id?"
|
||||||
|
|
||||||
|
utter_submit:
|
||||||
|
- text: Ok. Thanks!
|
||||||
|
utter_slots_values:
|
||||||
|
- text: I will remember that your name is {first_name} {last_name} number {phone_num} and id is {email_id}!
|
||||||
|
|
||||||
|
|
||||||
|
actions:
|
||||||
|
- utter_slots_values
|
||||||
|
- utter_submit
|
||||||
|
- get_slot_data
|
||||||
|
- slots_to_clear
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
session_config:
|
||||||
|
session_expiration_time: 60
|
||||||
|
carry_over_slots_to_new_session: true
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# This file contains the different endpoints your bot can use.
|
||||||
|
|
||||||
|
# Server where the models are pulled from.
|
||||||
|
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
|
||||||
|
|
||||||
|
#models:
|
||||||
|
# url: http://my-server.com/models/default_core@latest
|
||||||
|
# wait_time_between_pulls: 10 # [optional](default: 100)
|
||||||
|
|
||||||
|
# Server which runs your custom actions.
|
||||||
|
# https://rasa.com/docs/rasa/custom-actions
|
||||||
|
|
||||||
|
action_endpoint:
|
||||||
|
url: "http://localhost:5055/webhook"
|
||||||
|
|
||||||
|
# Tracker store which is used to store the conversations.
|
||||||
|
# By default the conversations are stored in memory.
|
||||||
|
# https://rasa.com/docs/rasa/tracker-stores
|
||||||
|
|
||||||
|
#tracker_store:
|
||||||
|
# type: redis
|
||||||
|
# url: <host of the redis instance, e.g. localhost>
|
||||||
|
# port: <port of your redis instance, usually 6379>
|
||||||
|
# db: <number of your database within redis, e.g. 0>
|
||||||
|
# password: <password used for authentication>
|
||||||
|
# use_ssl: <whether or not the communication is encrypted, default false>
|
||||||
|
|
||||||
|
#tracker_store:
|
||||||
|
# type: mongod
|
||||||
|
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
|
||||||
|
# db: <name of the db within your mongo instance, e.g. rasa>
|
||||||
|
# username: <username used for authentication>
|
||||||
|
# password: <password used for authentication>
|
||||||
|
|
||||||
|
# Event broker which all conversation events should be streamed to.
|
||||||
|
# https://rasa.com/docs/rasa/event-brokers
|
||||||
|
|
||||||
|
#event_broker:
|
||||||
|
# url: localhost
|
||||||
|
# username: username
|
||||||
|
# password: password
|
||||||
|
# queue: queue
|
||||||
Ссылка в новой задаче
Block a user