Giter Club home page Giter Club logo

chat-ai-samples's Introduction

Integrating Stream Chat with AI

Quick Links πŸ”—

Repo Overview 😎

This repo contains Stream's official sample projects demonstrating how Generative AI can be used in our Chat products. It includes sample backend servers for ChatGPT and Gemini, which can be used as a reference guide when using Gen AI with Stream.

Sample integrations in ReactJS, Android, and Flutter are located in the "frontends" directory, which also demonstrates working with and rendering real-time message chunks as they are sent from AI providers.

Projects/Packages πŸš€

  • Backend
    • ChatGPT Server: Node server that connects to both OpenAI and Stream chat to intercept and respond to messages in real time.
    • Gemini Server: Node server that connects Stream Chat with Gemini, allowing for sending, receiving, and replying to messages.
  • Frontend
    • React/NextJS: NextJs app, which interacts with ChatGPT and implements streaming responses.
    • Android: Jetpack Compose app written in Kotlin which integrates Google’s Gemini and our Jetpack Compose SDK. Please see the sub-directory for detailed getting started instructions.

How to Run πŸƒ

Setup environment variables

cp .env.example .env

Add following credentials to .env file:

  1. Stream Chat app api key and secret
  2. User ID and token
  3. OpenAI API key
  4. Or Gemini API key

Backend

To start the backend server, you can choose between ChatGPT and Gemini. The server will listen for messages and respond with AI-generated responses. You need to configure this server url as a webhook for your Stream Chat app.

cd server
yarn;

# Start ChatGPT server
yarn start:openai

# Or start Gemini server
yarn start:gemini

Configure Ngrok webhook

To expose the local server to the internet, you can use ngrok. Follow the instructions here to set up ngrok and configure the webhook URL for your Stream Chat app:

https://getstream.io/chat/docs/react/debugging_with_ngrok/

Frontend

cd react-chat
yarn; yarn start

AI Guides πŸ“š

These guides explore more of how AI can be used across our SDKs and products.

Contributing πŸ€”

  • How can I submit a sample app?
    • Apps submissions are always welcomed! πŸ₯³ Open a pr with a proper description and we'll review it as soon as possible
  • Spot a bug πŸ•· ?
    • We welcome code changes that improve the apps or fix a problem. Please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github.

chat-ai-samples's People

Contributors

vishalnarkhede avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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

Forkers

creativeedge

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.