Geological Survey Investigation Report Generation
This page demonstrates how to build a report generation app. The app allows users to upload their data and to use Action Table to compile essential information to generate the report.
Project setup
Before we start building, we are going to set up our Action Table. This is simple as clicking “New Action Table” in JamAIBase and then creating a “schema” inside the database.
Create a project
Click “New Action Table”.
Enter your project details.
Click “Create” to complete the Action Table setup.
Update the settings of the output column. Define the prompt message.
Add additional columns if necessary.
Building the app
Step 1: Set Up Your Environment
First, ensure you have Python installed on your system. Then, install Streamlit and other necessary libraries using pip:
Step 2: Initialize Your Streamlit App
Create a new Python file for your app, for example, borehole_analysis.py
.
Step 3: Import Required Libraries
Start by importing the necessary libraries in your Python script:
Step 4: Design the Sidebar for File Upload
Create a sidebar for user inputs. Add a file uploader in the sidebar to allow users to upload their Excel data.
Step 5: Load and Display the Data
Once the file is uploaded, read and display the data using pandas.
Step 6: Define Helper Functions for API Calls
Implement functions to interact with the database through API calls:
Function to Add a Row to the Database
Function to Retrieve Rows from the Database
Note that the latest row added to the database is always returned at the top of the list from the API.
Function to Get the Latest Row from the Database
Step 7: Add Button to Trigger API Calls
Add a button in Streamlit to trigger the API calls:
Step 8: Prepare the Report Template
Display the static content of the report at appropriate sections:
Display Action Table outputs dynamically to allow users to update the outputs:
Step 9: Add Interactivity
Powered by JamAI, users are capable to easily generate as many outputs as possible. Add interactive elements, such as buttons or sliders, to allow users to customize the analysis. For example, add a radio to select the most appropriate descriptiopn for the report:
Step 9: Add Button to download report
Add a button in Streamlit to download the report generated.
Step 10: Run Your Streamlit App
Save your script and run it using the Streamlit command in your terminal:
Step 11: Start Your App
Interact with the application by uploading data and using the button to trigger API calls. Verify that data is added and retrieved as expected.
Last updated