def createStory(): content = request.get_json(silent=True) story = Story() story.storyName = content.get("storyName") story.intentName = content.get("intentName") story.speechResponse = content.get("speechResponse") if content.get("apiTrigger") is True: story.apiTrigger = True apiDetails = ApiDetails() isJson = content.get("apiDetails").get("isJson") apiDetails.isJson = isJson if isJson: apiDetails.jsonData = content.get("apiDetails").get("jsonData") apiDetails.url = content.get("apiDetails").get("url") apiDetails.requestType = content.get("apiDetails").get("requestType") story.apiDetails = apiDetails else: story.apiTrigger = False if content.get("parameters"): for param in content.get("parameters"): parameter = Parameter() update_document(parameter,param) story.parameters.append(parameter) try: story.save() except Exception as e: return buildResponse.buildJson({"error": str(e)}) return buildResponse.sentOk()
def createStory(): content = request.get_json(silent=True) story = Story() story.storyName = content.get("storyName") story.intentName = content.get("intentName") story.speechResponse = content.get("speechResponse") if content.get("apiTrigger") is True: story.apiTrigger = True apiDetails = ApiDetails() isJson = content.get("apiDetails").get("isJson") apiDetails.isJson = isJson if isJson: apiDetails.jsonData = content.get("apiDetails").get("jsonData") apiDetails.url = content.get("apiDetails").get("url") apiDetails.url = apiDetails.url.replace("?","") print(apiDetails.url) apiDetails.requestType = content.get("apiDetails").get("requestType") story.apiDetails = apiDetails else: story.apiTrigger = False if content.get("parameters"): for param in content.get("parameters"): parameter = Parameter() update_document(parameter, param) story.parameters.append(parameter) try: story.save() except Exception as e: return buildResponse.buildJson({"error": str(e)}) return buildResponse.sentOk()
def createStory(): if (session.__getattribute__('loginstat') == 'login'): content = request.get_json(silent=True) story = Story() story.storyName = content.get("storyName") story.intentName = content.get("intentName") story.speechResponse = content.get("speechResponse") story.botId=content.get("botId") if content.get("apiTrigger") is True: story.apiTrigger = True apiDetails = ApiDetails() isJson = content.get("apiDetails").get("isJson") isHeader= content.get("apiDetails").get("isHeader") print("Is header",isHeader) apiDetails.isJson = isJson apiDetails.isHeader=isHeader if isJson: apiDetails.jsonData = content.get("apiDetails").get("jsonData") if isHeader: print("Is header data",content.get("apiDetails").get("headerData")) apiDetails.headerData = content.get("apiDetails").get("headerData") apiDetails.url = content.get("apiDetails").get("url") apiDetails.requestType = content.get("apiDetails").get("requestType") story.apiDetails = apiDetails else: story.apiTrigger = False if content.get("parameters"): for param in content.get("parameters"): parameter = Parameter() update_document(parameter, param) story.parameters.append(parameter) story.save() print("Story Saved") return buildResponse.sentOk() else: return render_template('index.html')
from nltk.tag.perceptron import PerceptronTagger from nltk import word_tokenize from app.stories.models import Story, LabeledSentences, Parameter, ApiDetails from app.core.nlp import posTagAndLabel, posTagger, sentenceTokenize from app.core import nlp import ast # Load and initialize Perceptron tagger tagger = PerceptronTagger() UPLOAD_FOLDER = './UploadFiles' ALLOWED_EXTENSIONS = set(['csv']) connect("ChatBot", host="localhost", port=27017) apiDetails1 = ApiDetails(url='', requestType='GET') app = Flask(__name__) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS stories = Blueprint('stories_blueprint', __name__, url_prefix='/stories', template_folder='templates')