GithubHelp home page GithubHelp logo

Comments (4)

pierredavidbelanger avatar pierredavidbelanger commented on July 18, 2024

I hope I understand you question.

This library already supports being used by many concurrent users.

After creating a bot:

$factory = new ChatterBotFactory();
$bot = $factory->create(ChatterBotType::CLEVERBOT);

You just have to create a session per user (and serialize it into the session to be reused in each request of this user):

$botsession = $bot->createSession();

Here is something I wrote about this some time ago:
https://code.google.com/p/chatter-bot-api/issues/detail?id=3#c5

from chatter-bot-api.

skorotkiewicz avatar skorotkiewicz commented on July 18, 2024

I was concerned about something similar

function cleverbot($s,$userid) {
    require 'cleverbot.php';
    $factory = new ChatterBotFactory();

    $bot1 = $factory->create(ChatterBotType::CLEVERBOT);
    if ( file_exists('user' . $userid. '-cookie.txt') ) {
         $bot1session = $bot1->LoadSession('user' . $userid. '-cookie.txt');
    } else {
         $bot1session = $bot1->createSession('user' . $userid. '-cookie.txt');
    }
    $s = $bot1session->think($s);
    return $s;
}

from chatter-bot-api.

pierredavidbelanger avatar pierredavidbelanger commented on July 18, 2024

The logic is almost fine, just do something like this:

function cleverbot($s,$userid) {
    require 'cleverbot.php';
    $factory = new ChatterBotFactory();
    $bot1 = $factory->create(ChatterBotType::CLEVERBOT);
    if ( file_exists('user' . $userid. '-cookie.txt') ) {
         $bot1session = ...unserialize content of file 'user' . $userid. '-cookie.txt'
    } else {
         $bot1session = $bot1->createSession('user' . $userid. '-cookie.txt');
    }
    $s = $bot1session->think($s);
    ...serialize $bot1session into file 'user' . $userid. '-cookie.txt'
    return $s;
}

from chatter-bot-api.

skorotkiewicz avatar skorotkiewicz commented on July 18, 2024

Thanks, it works. :)

from chatter-bot-api.

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.