Git Product home page Git Product logo

php-pi-chat's Introduction

Pi chatbot client

License Latest Stable Version PHP version cURL extension required

This is an unofficial PHP client for Pi chatbot (from Inflection AI). It doesn't require authentication.

This package isn't actively maintained and may be unstable due to Inflection AI's Cloudflare configuration.

This package is stricly meant for educational purpose. Use at your own risks.

Installation

composer require maximerenou/pi-chat

Demo

Clone this repo, run composer install and run examples/chat.php to test it.

Prompt Demo

Usage

use MaximeRenou\PiChat\Client as PiChat;
use MaximeRenou\PiChat\Prompt;

$chatbot = new PiChat();

$conversation = $chatbot->createConversation();

// $answer - full answer
$answer = $conversation->ask(new Prompt("Hello World"));
Real-time / progressive answer

You may pass a function as second argument to get real-time progression:

// $current_answer - incomplete answer
// $tokens - last tokens received
$final_answer = $conversation->ask($prompt, function ($current_answer, $tokens) {
    echo $tokens;
});
Resume a conversation

If you want to resume a previous conversation, you can retrieve its identifiers:

// Get current identifiers
$identifiers = $conversation->getIdentifiers();

// ...
// Resume conversation with $identifiers parameter
$conversation = $chatbot->resumeConversation($identifiers);
Error handling

The code throws exceptions when it receives an error from Pi. You can therefore use a try/catch block to handle errors.


Disclaimer

This code is for educational purpose only. Using Pi outside pi.ai may violate Inflection AI terms.

php-pi-chat's People

Contributors

maximerenou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

php-pi-chat's Issues

Getting 403 Response

I ran this code, and I think pi.ai changed something, i'm getting a 403 response. I think getting a session and cookie mechanism has changed.

I also converted the code to python if anyone is interested.

getting 403

I think they are using cloudflare now. So it is not possible anymore to make api calls to their private api.

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.