Welcome to the FastAPI Text Classification Template using GPT-4! This template is designed to help you quickly set up an API that can classify text items into categories using the power of GPT-4. Whether you're building a content categorization tool, a customer support automation system, or any other application that requires text classification, this template will get you started without the hassle of environment setup or deployment concerns.
To begin using this template, simply click on the "Start with this Template" button. This will set up the template in your Lazy builder interface, pre-populating the code and allowing you to customize it to your needs.
There are no environment secrets to set up for this template, as all necessary modules and functionalities are built-in within the Lazy platform. This means you can proceed without any additional configuration.
Once you have started with the template, you can test the functionality by pressing the "Test" button. This will deploy your application and launch the Lazy CLI. The CLI will prompt you for any required user input, if necessary.
For this template, user input through the CLI is not required as the API endpoints are designed to receive input through HTTP requests. Therefore, you can skip this section and move on to using the app.
After testing, Lazy will provide you with a dedicated server link to use the API. Additionally, since this template uses FastAPI, you will also receive a link to the automatically generated documentation for your API endpoints. This documentation will guide you on how to interact with the API, detailing the request formats and available endpoints.
If you need to integrate this API into an external service or frontend, you can use the server link provided by Lazy. Here's how you can make a sample request to the "/classify_single" endpoint:
import requests
# Replace 'your_server_link' with the actual server link provided by Lazy
url = 'your_server_link/classify_single'
# Sample data to classify
data = {
"items": [{"text": "Sample text to classify"}],
"categories": [{"name": "Category1"}, {"name": "Category2"}]
}
# Make a POST request to the API
response = requests.post(url, json=data)
# Print the response from the API
print(response.json())
And here's an example of what the response might look like:
[
{
"item": "Sample text to classify",
"category": "Category1"
}
]
Remember to replace 'your_server_link' with the actual link provided after deployment. Use the provided server link to integrate the API into your application or service as needed. If your integration requires specific scopes or code placement, ensure you follow the guidelines of the external tool you are integrating with.
By following these steps, you should be able to successfully set up and integrate the FastAPI Text Classification Template into your project. Happy building!