Giter Site home page Giter Site logo

Comments (4)

ahmadfaizalbh avatar ahmadfaizalbh commented on June 12, 2024

where are you setting variable current_speaker to non None value?

from chatbot.

padmalcom avatar padmalcom commented on June 12, 2024

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.

ahmadfaizalbh avatar ahmadfaizalbh commented on June 12, 2024

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.

ahmadfaizalbh avatar ahmadfaizalbh commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.