Neural-Chatbot icon indicating copy to clipboard operation
Neural-Chatbot copied to clipboard

able to get reply from the train.py,but the response is not corresponding to the input that i type in ?

Open akhilgentoo opened this issue 8 years ago • 0 comments

have made changes to your server.py file

from flask import Flask, render_template, jsonify from time import sleep from flask import request import sys sys.path.append('/home/labs/Documents/Neural-Chatbot-master/src/utils') sys.path.append('/home/labs/Documents/Neural-Chatbot-master/src/model') from sampling import Sampler from models import seq2seq, seq2seq_attention import json

from config_utils import settings app = Flask(name)

@app.route('/') def index_page(): return render_template('index.html')

@app.route('/respond', methods=['POST']) def respond():

sequence_length = settings.model.sequence_length
	vocabulary_size = settings.model.vocabulary_size
	hidden_size = settings.model.hidden_size
	print ('Creating model with configuration: {0}'.format(settings.model))

	model = seq2seq_attention(sequence_length, vocabulary_size, hidden_size)
	print ('Loading model weights from {0}'.format(settings.model.weights_path))
	model.load_weights('/home/infinitylabs/Documents/Neural-Chatbot-master/models/seq2seq_weights.h5')

	vocabulary_file = settings.data.vocabulary_path
	with open(vocabulary_file, 'r') as handle:
    	vocabulary = json.load(handle)

	sampler = Sampler(model, vocabulary, sequence_length)
question = request.form['message']
    response = sampler.respond(question, greedy=True)
    print (response)
    for t in (.7, .8, .9):
        response = sampler.respond(question, temperature=True)
        print (response)

	    	
return jsonify({ 'response': response })

if name == 'main': app.run(port=8000)

akhilgentoo avatar Aug 22 '17 12:08 akhilgentoo