Skip to content

This project is an AI assistant built using Chainlit and the OpenAI Agent SDK, powered by Google Gemini models. It supports real-time streaming responses (just like ChatGPT) and remembers previous messages(history/memory) to keep the conversation flowing naturally.

Notifications You must be signed in to change notification settings

waheed444/chainlit-memory-stream-agent

Repository files navigation

Chainlit Powered Memory Streaming Agent 🤖

GitHub stars GitHub forks Python Version Chainlit Fork Star

This project is an AI assistant built using Chainlit and the OpenAI Agent SDK, powered by Google Gemini models. It supports real-time streaming responses (just like ChatGPT) and remembers previous messages(history/memory) to keep the conversation flowing naturally. You can use it to build your own smart and responsive chatbot.

Prerequisites ✅

Before running this project, ensure you have the following tools, libraries, and API keys properly configured:

Tool / Library Description
🐍 Python 3.9+ Required for running the application and libraries
🧬 Chainlit Framework for building conversational UIs with LLMs
🧠 OpenAI Agent SDK Enables agent orchestration and streaming capabilities
🌐 Git Version control for cloning and managing the project repository
🔑 Google Gemini API Get API Key for Gemini models
🔑 OpenAI API Key Get API Key for streaming
📦 dotenv For managing environment variables securely
🧪 VS Code Recommended code editor for development

Features ✨

  • 🔄 Real-time Token Streaming: Experience the fluidity of ChatGPT-like responses.
  • 🧠 Persistent Memory: Maintain context across your conversations, ensuring your AI assistant remembers previous interactions.
  • 🔗 Chainlit Integration: Leverage Chainlit's ease of use for rapid UI development and deployment.
  • 🤖 Gemini Power: Utilize the cutting-edge capabilities of the gemini-2.0-flash model.
  • 🧰 OpenAI Agent SDK Integration: Benefit from the robust features and flexibility of the OpenAI Agent SDK.
  • 🔐 Secure API Key Management: Safely manage your API keys using a .env file.
  • 🚀 Developer-Friendly Codebase: A modular and well-structured Python codebase, making it easy to extend and customize.

⚙️ Installation Instructions

  1. Clone the Repository:

    git clone https://github.com/waheed444/chainlit-memory-stream-agent.git
    cd chainlit-memory-stream-agent
  2. Create and Activate a Virtual Environment:

    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  3. Install dependencies:

pip install openai-agents chainlit
       # for UV User's
uv add openai-agents chainlit
  1. Configure API keys: Create a .env file in the root directory and add your API keys:
  • 📌 Make sure to store your API keys securely in a .env file in the root directory:

GEMINI_API_KEY = paste_your_gemini_api_key_here
               # OR
OPENAI_API_KEY = paste_your_openai_api_key_here
  1. Run the App:

    chainlit run agent.py

    (Note: You need to have chainlit installed. Install it via pip install chainlit if not already present.)

Usage Instructions 🗣️

Usage Examples

Start the Chat UI: Once Chainlit is running, open the local URL provided in your terminal and start chatting with your AI assistant.

Ask questions like:

Who was the founder of Pakistan?
Summarize the history of Python in 3 lines.
What’s the latest in AI this year?

Enjoy token-by-token responses with context-aware answers based on your memory/previous messages.

💡 You can customize the agent's behavior, memory strategy, or switch between Gemini and OpenAI models by modifying the app.py and stream.py files.

Contributing

We welcome contributions to improve this project! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature-name
  3. Make your changes and ensure they adhere to the project's coding style and best practices.
  4. Commit your changes: git commit -m "Add feature"
  5. Push to the branch: git push origin feature-name
  6. Submit a pull request with a clear description of your changes and their benefits. If you find any issues or want to improve this project, feel free to open a GitHub issue or submit a pull request.

This repo is only for learning and exploring new things, feel free to fork it, explore, or give suggestions!

Star ⭐ the repo if it helps you!


License

This project is licensed under the MIT License - see the LICENSE file for details.


🙌 Let's Connect

LinkedIn GitHub Gmail


About

This project is an AI assistant built using Chainlit and the OpenAI Agent SDK, powered by Google Gemini models. It supports real-time streaming responses (just like ChatGPT) and remembers previous messages(history/memory) to keep the conversation flowing naturally.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages