gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.08k stars 4.44k forks source link

Error while running python from laravel(PHP) #590

Closed shashigharti closed 7 years ago

shashigharti commented 7 years ago

I am trying to execute chatterbot from PHP and not getting the expected result. I am using python3.7 and chatterbot 0.5.5

from chatterbot import ChatBot import sys import requests

bot = ChatBot('Agri', storage_adapter='chatterbot.storage.MongoDatabaseAdapter', logic_adapters=[ "chatterbot.logic.MathematicalEvaluation", "chatterbot.logic.BestMatch" ], output_adapter="chatterbot.output.TerminalAdapter", database='test1' ) response = bot.get_response(sys.argv[1]) print(response)

The response is not sent back to PHP function:

\Log::info("$cmd $message"); $response = exec("python3 customchat.py $message"); \Log::info($response);

gunthercox commented 7 years ago

Hi @shashigharti, all of the parameters you're passing to ChatBot appear to be correct.

You said that you are not getting the expected result. Are you getting any result? If so, what is the result you are getting?

shashigharti commented 7 years ago

Hi @gunthercox

Thanks for the quick response. I wasn't getting any errors only an empty result so couldn't debug. After adding debug code:

exec("$cmd $message 2>&1", $retArr, $retVal);

I was able to figure out the issue. The issue was while the function call was made from the POST method(web) nltk was being downloaded in /var/www directory and there was a permission error. The problem is solved.

Thanks for your quick response

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.