- Example Workflow for the IRIS API Interface Generator
- Step 1: Paste the API Documentation
- Step 2: Generate the Form
- Step 3: Submit the Query
- Instructional Guide
- IRIS API Interface Generator
- Introduction
- Quickstart
- Application Overview
- Backend
- Frontend
- Styles
- Iris-Bloom: Docker Workflow Script
- License
Below is a step-by-step guide on how to use the IRIS API Interface Generator. This example showcases a basic API query scenario, from pasting the API documentation to submitting a query and viewing the responses.
In this step, the user copies the API documentation into the provided textarea. This documentation will be processed to generate a query form.
After pasting the API documentation, the user clicks the "Generate Form" button. The tool processes the documentation and generates a form based on the parameters provided in the API documentation.
Once the form is generated, the user can fill in the required fields and click the "Submit Query" button to send the request to the API. The response from the API will be displayed below the form.
The application includes an instructional guide that provides detailed steps on how to use the IRIS API Interface Generator. This guide can be toggled for visibility during the usage of the application.
The IRIS API Interface Generator is a powerful application that allows users to interact with third-party APIs by generating dynamic forms based on the APIs' documentation. By simply pasting the API documentation into the tool, users can create custom query forms that enable them to send requests directly to the API and receive responses, all without manual coding.
- Dynamic Form Generation: Automatically generates user-friendly forms from pasted API documentation.
- Direct API Interaction: Allows submission of queries directly to third-party APIs using the generated forms.
- Response Display and Saving: Displays API responses and provides options to save them for future reference.
- Instructional Guide: Includes an in-app instructional component to assist users.
- Modern UI: Built with Vue.js and styled with Tailwind CSS for a responsive and intuitive interface.
-
Clone the Repository:
git clone https://github.com/mindfulcoder49/iris-api-interface-generator cd iris-api-interface-generator
-
Create a
.env
File:-
Place it in the root directory with your Docker file.
-
Add your
OPENAI_API_KEY
.OPENAI_API_KEY=sk-your-openai-api-key
-
-
Run
docker-compose build
:- The Docker file and
entrypoint.sh
script will handle the rest of the installation and migration.
- The Docker file and
-
Change Permissions on the Repository Folder:
-
To allow the Docker container's internal users to write to the repository directory, set full permissions.
chmod -R 777 ..
-
-
Run
docker-compose up
:- This will start the application.
-
Access the Application:
- Frontend:
http://localhost:53795/django
- Frontend:
The application enables users to:
- Paste API Documentation: Input API documentation into a text area.
- Generate Dynamic Forms: Create forms based on the API documentation using OpenAI's GPT-4.
- Submit Queries: Fill out the generated forms to send requests directly to third-party APIs.
- View and Save Responses: Display the API responses and provide options to save them.
The user interface includes:
- API Documentation Input: A textarea to paste the API documentation.
- Generate Form Button: Initiates the form generation process.
- Generated Query Form: A dynamic form created based on the API documentation.
- Submit Query Button: Sends the filled form data to the third-party API.
- Responses Section: Displays API responses with an option to save them.
- Instructional Component: Provides a guide on how to use the application.
- Description: Paste your API documentation (e.g., Swagger specs, OpenAPI definitions) into the provided textarea.
- Description: Click this button to generate a dynamic form based on the pasted API documentation.
- Description: Fill out the dynamically generated form fields that correspond to the API's parameters.
- Description: After completing the form, click this button to submit your query directly to the third-party API.
- Description: View the API's response in this section. You can also save the response for future reference by clicking the "Save Response" button.
- OpenAI API Key: Ensure your OpenAI API key is correctly set in the
.env
file. - CSRF Tokens: The application uses CSRF tokens for security. Ensure that the CSRF token is included in your requests.
- API Rate Limits: Be mindful of any rate limits imposed by the third-party APIs and OpenAI.
Description:
- Receives the API documentation from the frontend.
- Uses OpenAI's GPT-4 to parse the documentation and generate form fields and the base URL.
- Returns the form fields and base URL to the frontend for form rendering.
Key Points:
- Validates that the prompt (API documentation) is provided.
- Uses OpenAI's function calling feature to extract necessary information.
- Handles exceptions and returns appropriate error messages.
Description:
- Receives the base URL and form data from the frontend.
- Makes a GET request to the third-party API using the provided data.
- Returns the API's response to the frontend.
Key Points:
- Validates that both
base_url
andform_data
are provided. - Uses the
requests
library to interact with the third-party API. - Handles HTTP errors and exceptions, providing meaningful error messages.
Description:
- Saves the API response to the database for future reference.
- Returns a success message upon successful save.
Key Points:
- Utilizes Django REST Framework serializers for data validation.
- Ensures data integrity and handles validation errors.
- Django: The web framework used for the backend.
- Django REST Framework: Facilitates the creation of RESTful APIs.
- OpenAI Python Library: For interacting with OpenAI's GPT-4 model.
- Requests: For making HTTP requests to third-party APIs.
- JSON: For handling JSON data serialization and deserialization.
- VueCookies: For managing cookies, specifically for CSRF tokens.
- Main Component: Manages the API documentation input, form generation, query submission, and response display.
- Instructional Component: Provides step-by-step instructions on how to use the application.
- Dynamic Form Rendering: Generates form fields based on the API documentation.
- Response Handling: Displays responses from the third-party API and allows users to save them.
- Instructional Guide: Users can toggle the visibility of instructions for assistance.
- Header: Displays the application title: "API Documentation Query".
- API Documentation Input: A textarea for users to paste their API documentation.
- Generate Form Button: Triggers the generation of the dynamic form.
- Generated Query Form: The form generated based on the API documentation.
- Submit Query Button: Sends the filled form data to the backend.
- Responses Section: Shows the API responses with options to save them.
- Instructional Component: An optional section providing usage instructions.
- apiDocumentation: Stores the pasted API documentation.
- generatedFormFields: Holds the form fields generated from the API documentation.
- baseUrl: Stores the base URL extracted from the API documentation.
- responses: An array of responses received from the API.
- isGeneratingForm: A boolean indicating if the form is being generated.
- submitApiDocumentation(): Sends the API documentation to the backend to generate the form.
- submitQueryFromGeneratedForm(): Submits the form data to the backend, which then queries the third-party API.
- saveResponse(index): Saves a specific response to the database.
- clearDocumentation(): Clears the API documentation input field.
- hideInstructions() / showInstructionsFunc(): Toggles the visibility of the instructional component.
- Tailwind CSS: Utilized for styling the application, ensuring a modern and responsive user interface.
Here's a README.md
section for your iris-bloom
script:
iris-bloom
is a lightweight command-line tool inspired by Laravel Sail, designed to simplify the development process when working with Django, Vue, and IRIS within Docker. It automates common Docker commands and integrates them with your Django, Vue.js, and IRIS environment for easier management.
- Ensure
docker-compose
is installed and properly configured in your environment. - Define your services in the
docker-compose.yml
file (ensure the service name aligns with theSERVICE_NAME
in the script).
The following commands can be used to manage your Docker environment efficiently:
./iris-bloom start-iris
Starts the IRIS service within the Docker container by executing the start-iris.sh
script inside the container.
./iris-bloom restart-iris
Restarts the IRIS service using the restart-iris.sh
script.
./iris-bloom install-python-deps
Installs Python dependencies inside the container by executing the install-python-deps.sh
script.
./iris-bloom reload-production
Reloads the production environment by running the reload-production.sh
script.
./iris-bloom build-frontend
Builds the frontend (Vue.js) using the build-frontend.sh
script.
./iris-bloom reinstall-frontend
Reinstalls the frontend dependencies and rebuilds the project.
./iris-bloom django-build
Builds the Django application using the django-build.sh
script.
./iris-bloom django-manage <command>
Executes Django management commands inside the container (e.g., ./iris-bloom django-manage migrate
).
./iris-bloom build
Builds the Docker container using docker-compose build
.
./iris-bloom rebuild
Rebuilds the Docker container from scratch, bypassing the cache.
./iris-bloom start
Starts the container in detached mode using docker-compose up
.
./iris-bloom stop
Stops the running container.
./iris-bloom restart
Restarts the container.
./iris-bloom delete
Stops and removes the container.
You can modify the SERVICE_NAME
and APP_ROOT
in the script to suit your Docker Compose setup and the location of your application scripts.
# Step 1: Build the container
./iris-bloom build
# Step 2: Start the container
./iris-bloom start
# Step 3: Install Python dependencies
./iris-bloom install-python-deps
# Step 4: Build the frontend
./iris-bloom build-frontend
# Step 5: Run Django management commands
./iris-bloom django-manage migrate
- If your services are not responding, ensure the container is running by executing
docker-compose ps
. - Check if the service names in your
docker-compose.yml
match theSERVICE_NAME
variable in the script.
The iris-bloom
script is designed to streamline development tasks, allowing you to focus on coding rather than manual container management.
This project is licensed under the MIT License. See the LICENSE file for details.