Code Monkey home page Code Monkey logo

python-sample-apps-with-aiaas-apis's Introduction

python-sample-apps-with-AIaaS-apis

Table of Contents

Summary

Sample apps utilizing AI as a Service (primarily OpenAI) Web APIs.

Reference

Features

  • Chat bot sample app utilizing gpt-3.5-turbo or gpt-4-turbo model
  • Image generator sample app utilizing dall-e-2 or dall-e-3 model
  • Speech generator sample app utilizing tts-1 or tts-1-hd model

Getting started

Preconditions

Starting applications


Chat bot

Install pip dependencies:

cd samples/chat-bot
pip install -r requirements.txt

If user content does not consist of multiple new lines, run:

python chat_bot.py --system <System content here. Can be set to ''> --user <User content here> --model <gpt-3.5-turbo, gpt-4-turbo>

# User content with multiple new lines -> Update the content in the [user-content.txt file](samples/chat-bot/assets/user-content.txt) and run
python chat_bot.py --system <System content here. Can be set to ''> --model <gpt-3.5-turbo, gpt-4-turbo>

Update the content in the user-content.txt file if user content consists of multiple new lines, run:

python chat_bot.py --system <System content here. Can be set to ''> --model <gpt-3.5-turbo, gpt-4-turbo>

NOTE: You might need to change your billing plan, if you encounter the error openai.RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}


Image generator

Install pip dependencies and run application:

cd samples/image-generator
pip install -r requirements.txt
python image_generator.py --model <dall-e-2, dall-e-3> --prompt "<user content>" --size <size of the image to be generated, e.g. 1024x1024>
# Checkout link of `Generated image URL` in a browser of choice

NOTE: "When using DALL·E 3, images can have a size of 1024x1024, 1024x1792 or 1792x1024 pixels."


Speech generator

cd samples/speech-generator
pip install -r requirements.txt
python speech_generator.py --model tts-1-hd --voice alloy --input "Hello, how are you today?" --output output/hello.mp3

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.