Code Monkey home page Code Monkey logo

tuna-asyncio's Introduction

Tuna-ASyncio

Tuna-ASyncio is a Python project that generates questions and sarcastic answers based on provided text chunks using the OpenAI API. It utilizes asyncio for asynchronous processing and implements rate limiting mechanisms to ensure compliance with API usage limits.

Features

  • Generates a specified number of questions and sarcastic answers from text chunks
  • Supports custom prompts and response formats for the OpenAI API
  • Implements token bucket algorithm for rate limiting
  • Uses asyncio for efficient asynchronous processing
  • Handles API request retries and backoff mechanisms
  • Outputs the generated questions and answers to a CSV file

Prerequisites

  • Python 3.7 or higher
  • OpenAI API key (set as an environment variable OPENAI_API_KEY)

Installation

  1. Clone the repository:
git clone https://github.com/cypheroxide/Tuna-ASyncio.git
  1. Navigate to the project directory:
cd Tuna-ASyncio
  1. Install the required dependencies:
pip install -r requirements.txt

Usage

  1. Prepare a CSV file containing text chunks with the following columns: ChunkIDs, ChunkTexts.

  2. Run the main.py script with the path to your CSV file as an argument:

python main.py chunks.csv

This will generate an output.csv file containing the questions, answers, and related information.

Customization

You can customize various aspects of the question and answer generation process by modifying the following variables in main.py:

  • custom_system_message: The system message for the OpenAI API prompt.
  • custom_json_format: The desired format for the response JSON.
  • num_triplets: The number of questions and answers to generate.
  • custom_prompt_prefix: The custom prefix for the OpenAI API prompt.
  • model_choice: The OpenAI model to be used.
  • num_chunks: The number of text chunks to consider for generating questions and answers.

Project Structure

  • main.py: The main script that orchestrates the question and answer generation process.
  • format.py: A utility script for converting a DataFrame to a JSONL format.
  • chunks.csv: A sample input CSV file containing text chunks.
  • output.csv: The output file containing the generated questions and answers (created after running main.py).
  • poetry.lock and pyproject.toml: Files used for dependency management with Poetry.

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Acknowledgments

This project makes use of the following libraries:

tuna-asyncio's People

Contributors

cypheroxide avatar

Watchers

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