Comments (4)
where are you setting variable current_speaker
to non None value?
from chatbot.
In my main function, let me give you an example. I tried to reduce my code as far as possible. I do not use any classes and I double checked that current_speaker is set via prints. It seems that it is once registered in the function iam and never changed from there on.
current_speaker = None
chat = Chat(DIALOG_TEMPLATE)
@register_call("iam")
def iam(name, session_id = "general"):
if current_speaker == None:
return "Nice to meet you " + name
else:
return "I already know you " + name
def main():
current_speaker = "Nick"
output = chat.respond("My name is Nick.")
if __name__ == '__main__':
main()
from chatbot.
your variable current_speaker
is a local variable in main
function which will not be accessible from iam
function to make current code work you have to add global current_speaker
at beginning of main
function.
from chatbot.
if you are trying to do it for multiple users for each user create a new session using start_new_session(session_id, topic)
function and call as followers respond("My name is Nick.", session_id)
where session_id
can be any unique id identifier that can identify the current speaker.
from chatbot.
Related Issues (20)
- How to change the name of my chatbot HOT 5
- Middleware for handling chatbot response? HOT 5
- Where is Chat, register_call functions? HOT 2
- Execution HOT 9
- Add examples for features in template files HOT 2
- Can not call function without parameters HOT 1
- Can not avoid "default" answers from default.template HOT 3
- Get confidence score for selected answer HOT 4
- Load all templates from a folder HOT 5
- Access variables from python code HOT 1
- Is the installation from PIP up to date?
- A more detailed explanation of Topic based group,Learn HOT 3
- How i can get the text of the response of the bot? HOT 3
- Any more details document? HOT 2
- Learning by chatting HOT 7
- Chat not found HOT 1
- HI HOT 1
- Plugin System HOT 1
- conditional Chatbot response
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatbot.