Skip to content

Latest commit

 

History

History
81 lines (55 loc) · 3.75 KB

README.md

File metadata and controls

81 lines (55 loc) · 3.75 KB

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.