Giter Site home page Giter Site logo

tkhongsap / gen-ai-utils Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 12 KB

A collection of utility scripts and helper functions for integrating and managing generative AI APIs, including OpenAI, Anthropic, and others. Streamline your AI projects with reusable components and examples.

Python 69.28% Jupyter Notebook 30.51% Procfile 0.21%

gen-ai-utils's Introduction

๐Ÿง  Gen-AI Utils

A comprehensive collection of utility scripts and helper functions designed to streamline your work with various generative AI APIs, including OpenAI, Anthropic, and others. This repository provides reusable components and examples that make it easy to integrate and manage generative AI capabilities in your projects.

๐Ÿš€ Features

  • ๐Ÿ› ๏ธ Generative AI Utilities:

    • Unified scripts for interacting with multiple generative AI APIs, such as OpenAI and Anthropic.
    • Includes functions for managing files, chat interactions, and vector store operations.
    • Customizable scripts for generating responses, processing prompts, and handling API-specific tasks.
  • ๐Ÿ”ง Common Utilities:

    • Environment management, logging, and request handling utilities that can be shared across different AI APIs.
    • Custom CSS for enhancing the appearance of Streamlit applications, making your interfaces more user-friendly and visually appealing.

๐Ÿ“ฆ Installation

To get started with these utilities, clone the repository and install the necessary dependencies:

git clone https://github.com/yourusername/gen-ai-utils.git
cd gen-ai-utils
pip install -r requirements.txt

Make sure to set up your environment variables, particularly API keys for the generative AI services you're using. You can use a .env file to securely manage these variables.

๐Ÿ“ Directory Structure

The repository is organized to support multiple AI APIs, with a clear separation of utilities and examples:

gen-ai-utils/
โ”‚
โ”œโ”€โ”€ app-streamlit.py                       # Example Streamlit app demonstrating usage
โ”œโ”€โ”€ generative_ai/
โ”‚   โ”œโ”€โ”€ openai/
โ”‚   โ”‚   โ”œโ”€โ”€ batch-update-vector-store-files.ipynb   # Jupyter notebook for OpenAI vector store batch updates
โ”‚   โ”‚   โ”œโ”€โ”€ delete_vector_store_files.ipynb         # Jupyter notebook for OpenAI vector store file deletion
โ”‚   โ”‚   โ”œโ”€โ”€ openai_assistant_response.py       # Script for generating responses using OpenAI Assistant API
โ”‚   โ”‚   โ”œโ”€โ”€ openai_utils.py                    # Utility functions for interacting with OpenAI API
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ anthropic/
โ”‚   โ”‚   โ””โ”€โ”€ anthropic_utils.py                 # Placeholder for Anthropic-specific utilities
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ gemini/                                # Placeholder for Gemini API utilities
โ”‚   โ”œโ”€โ”€ llama/                                 # Placeholder for LLaMA API utilities
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ custom_css_main_page.py            # Custom CSS for the main page styling
โ”‚   โ”œโ”€โ”€ custom_css_banner.py               # Custom CSS for the banner
โ”‚   โ”œโ”€โ”€ message_utils.py                   # Utility functions for formatting and displaying messages
โ”‚
โ”œโ”€โ”€ .gitignore                             # Git ignore file
โ”œโ”€โ”€ LICENSE                                # License for the repository
โ”œโ”€โ”€ README.md                              # This file
โ”œโ”€โ”€ requirements.txt                       # Python dependencies
โ””โ”€โ”€ .env.example                           # Example environment variables file

โš™๏ธ Usage

Generative AI Utilities

๐Ÿ’ฌ Generating a Response

To generate a response using a generative AI API (e.g., OpenAI):

from generative_ai.openai.openai_utils import generate_assistant_response

# Generate a response using OpenAI's Assistant API
response = generate_assistant_response("What's the weather today?", "your_assistant_id")
print(response)

๐Ÿ—ƒ๏ธ Managing Vector Stores

For managing vector stores with OpenAI:

  • Batch Update: Use batch-update-vector-store-files.ipynb to update multiple files in a vector store.
  • File Deletion: Use delete_vector_store_files.ipynb to delete files from a vector store.

๐ŸŒ Streamlit Example

Run the example Streamlit app app-streamlit.py to see how these utilities can be integrated into a web application:

streamlit run app-streamlit.py

The app showcases chat interactions using OpenAI's API, enhanced with custom CSS and message formatting utilities.

๐ŸŽจ Common Utilities

  • Custom CSS: Use custom_css_main_page.py and custom_css_banner.py to style your Streamlit apps.
  • Message Formatting: Use message_utils.py for consistent formatting and display of chat messages.

๐Ÿค Contributing

Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines on how to contribute to this project.

๐Ÿ“œ License

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

๐Ÿ“ฌ Contact

For any questions or suggestions, feel free to open an issue or contact the repository owner.

gen-ai-utils's People

Contributors

tkhongsap avatar

Watchers

 avatar Kostas Georgiou 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.