Git Product home page Git Product logo

chatstream's Introduction

chatstream for Shiny for Python

The chatstream package provides a Shiny for Python module for building AI chat applications. Please keep in mind that this is very much a work in progress, and the API is likely to change.

See this post on the Shiny blog to see some examples in action!

Chatstream currently supports the OpenAI API. To use this, you must have an OpenAI API key. You can get one from the OpenAI or from Azure's OpenAI Service. (Note that if you have use Azure, you will need to point the applications to the Azure endpoint instead of the default OpenAI endpoint.)

Installation

The chatstream package is not on PyPI, but can be installed with pip:

pip install chatstream@git+https://github.com/wch/chatstream.git

Alternatively, if you'd like to develop a local copy of the package, first clone the repository and then install it with pip:

cd chatstream
pip install -e .[dev]

Running examples

Before running any examples, you must set an environment variable named OPENAI_API_KEY with your OpenAI API key.

You can set the environment variable with the following command:

export OPENAI_API_KEY="<your_openai_api_key>"

Then run:

shiny run examples/basic/app.py --launch-browser

Some examples (like recipes) have a requirements.txt file. For those examples, first install the requirements, then run the application as normal:

pip install -r examples/recipes/requirements.txt
shiny run examples/recipes/app.py --launch-browser

FAQ

  • Does this work with Shinylive? It almost does. The openai package has dependencies which do not install on Pyodide, but chatstream currently has an openai_pyodide shim which uses the browser's fetch API. However, there is one more hurdle: the tiktoken package (which counts the number of tokens used by a piece of text) needs to be built to run on Pyodide.

  • Does this work with langchain? It currently does not. Note that most of the langchain interfaces do not support streaming responses, so instead of showing responses as each word comes in, there is a wait and then the entire response arrives at once.

chatstream's People

Contributors

wch avatar jcheng5 avatar

Stargazers

s.watanabe avatar

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.