jswope00 / AI-MicroApp-Template-Completion

This is a template for an AI Micro-app that allows you to build an AI-powered app like configuring a form.
MIT License
3 stars 0 forks source link

AI MicroApp (Completion)

Overview

This AI MicroApp template is a simple Streamlit application that demonstrates how to integrate AI models with a web interface using Streamlit. It means that you can build and share AI "MicroApps" as simply as building a form.

It works with the Completion API and similar. Meaning, it is a "one-shot" request and there is no memory of a conversation like with a chatbot. It is most suitable for one-off requests where prompting is important. For example, "Write me MCQs from this content..." or "Generate a storyboard based on these learning objectives..."

It also doesn't store data anywhere except for some storage required in the local browser which is cleared after the session ends.

Prerequisites

Local Setup Instructions

1. Clone the repository

Navigate to a location where you'd like to run this app from, and clone the repo:

git clone https://github.com/jswope00/AI-MicroApp-Template-Completion.git

2. Create a Virtual Environment

To create a virtual environment, navigate to your project directory in the terminal:

cd AI-MicroApp-Template-Completion

It's recommended to isolate the project's dependencies using a virtual environment. You can utilize tools like venv or virtualenv to achieve this. Refer to official documentation for specific commands based on your chosen tool. Here is the command from a mac shell:

python3 -m venv venv

Finally, activate your virtual environment:

source venv/bin/activate

3. Install Requirements

Activate your virtual environment and install the required packages using pip:

pip3 install -r requirements.txt

3. Add your API key(s):

Create a file named .env in your project's root directory. Paste your API key(s) inside the file. See .env_sample file for required format.

Running the App

Running Locally

Navigate to your project directory in the terminal and execute the following command to launch the Streamlit app:

streamlit run main.py

This will open the Birthday App in your web browser, typically at http://localhost:8501.

Running a Web App

This app is built to be hosted on Streamlit and can be deployed with Streamlit's 3-step deployment process:

  1. Put your app in a public GitHub repo (and make sure it has a requirements.txt!)
  2. Sign into share.streamlit.io
  3. Click 'Deploy an app' and then paste in your GitHub URL

Streamlit is a platform for hosting and sharing web apps. Community (public) apps are free to host. In addition, this template is built using only temporary local storage and no database, for ease of setup and data privacy.

Deployment outside of Streamlit is certainly possible but outside the scope of this README.

Explanation

The app leverages Streamlit to create a user interface and OpenAI's API for interacting with a large language model. Here's a breakdown of the key functionalities:

Customization

The code includes sections for various app aspects you can customize:

Feel free to experiment with these configurations to tailor the app's behavior and appearance to your preferences.