QuickStart App
QuickStartApp Documentation
This document provides an overview of the QuickStartApp, a Streamlit-based application that leverages the WorqHat AI API to generate insightful and concise responses based on user-provided input. The app is designed to provide quick and informative content generation, enhancing productivity by utilizing AI-powered responses and it is very quick and easy to make
Purpose
The QuickStartApp is intended to help users quickly obtain concise answers to their questions by sending input text to the WorqHat AI API, which processes the request and returns a JSON response. The application extracts the relevant content from this response and displays it to the user in a clear and organized manner.
Key Features
Text Input: Users can input any text or question they need a response to, such as inquiries related to coding advice, learning strategies, or other topics of interest.
AI-Powered Response: The WorqHat AI API processes the input and generates a response based on the specified question and training data, delivering concise and accurate answers.
Error Handling: The app includes comprehensive error handling for API responses, ensuring that users are notified in case of HTTP errors, request failures, or JSON parsing issues.
User-Friendly Interface: The application is built using Streamlit, providing an intuitive and easy-to-use interface where users can submit their input text and review AI-generated responses.
Benefits
Quick Content Generation: Get AI-generated responses in seconds by simply inputting a question or text. The app automatically sends the request to the WorqHat API and returns the answer.
Improve Productivity: Automate the process of generating concise and informative answers, enabling you to focus on more complex tasks.
Customizable Responses: The AI-generated responses can be tailored based on the input text and training data, allowing you to obtain content relevant to your needs.
Error-Free Processing: The app handles API call failures and JSON errors, ensuring smooth user interaction even when issues arise.
Easy to Build: This app is straightforward to understand and implement, providing hands-on experience for beginners in API calls and app development.
How It Works
Text Input: Users enter a question or text into the input field provided by the Streamlit form.
API Call: Upon submission, the app sends the input text to the WorqHat AI API for analysis. The API call includes a predefined payload that requests a concise and informative response.
Response Parsing: The API returns a JSON response. The app parses this response to extract the answer.
Display Result: The application presents the generated response in a user-friendly format using Streamlit’s
st.info()
function, ensuring the output is easy to review and understand.
Procedure to Follow
WorqHat API Key: Obtain a WorqHat API key by signing up at the WorqHat API Signup Page. Enter your API key in the provided input field on the sidebar.
Enter Text: Input any question or text that you want the WorqHat AI to analyze.
Submit Query: After entering the text, click the "Submit" button. Ensure your API key starts with 'sk-' before submitting the form to avoid warnings.
Receive Response: The application will send the request to the WorqHat API, receive the response, and display the answer in an info box on the screen.
Example Code Snippet
Here’s the core function that handles the API call:
def generate_response(input_text):
url = "https://api.worqhat.com/api/ai/content/v4"
payload = {
"question": input_text,
"training_data": "Provide a concise and informative response to the question. put the key as answer",
"response_type": "json",
"model": "aicon-v4-nano-160824",
}
headers = {
"Authorization": f"Bearer {worqhat_api_key}",
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
response_data = response.json()
content = response_data['content']
content_json = json.loads(content)
response_text = content_json['answer']
st.info(response_text)
except requests.exceptions.HTTPError as http_err:
st.error(f"HTTP error occurred: {http_err}")
except requests.exceptions.RequestException as req_err:
st.error(f"Request error occurred: {req_err}")
except ValueError as json_err:
st.error(f"JSON decode error: {json_err}")
st.write("Response content:", response.text)
This function processes the API request, extracts the relevant answer from the JSON response, and displays it using Streamlit.
Conclusion
The QuickStartApp is a powerful tool that simplifies content generation by utilizing WorqHat's AI capabilities. It helps users get quick and concise responses to their queries, boosting productivity and streamlining the process of obtaining information.
EndNote
Let QuickStartApp assist you in generating quick, AI-powered answers to your questions, saving you time and effort in content creation. The intuitive design and seamless API integration make it an ideal tool for anyone looking to leverage the power of AI for content generation.
Try it Yourself
Explore the QuickStartApp at Streamlit App Page.
Check out the Code on GitHub: WorqHat GitHub Repository.