Quick Links ?
- Register to get an API key for Stream
- ReactJS Example
- ChatGPT Node Server
- Gemini Node Server
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
Add following credentials to .env
file:
- Stream Chat app api key and secret
- User ID and token
- OpenAI API key
- 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.
- Implementing ChatGPT with Stream Chat
- Build an AI Chat Android App With Google’s Generative AI
- Create LLM-powered Chatbot For Your Documentation
- Conversational AI Using Stream Chat, HuggingFace, and DialogGPT
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.