Welcome to the template-based Text-to-Text Generation API! This API allows you to generate text based on provided prompts using a fine-tuned Large Language Model (LLM). Whether you're a developer, researcher, or business professional, this API can help you generate text using prompt engineering techniques for various applications such as content generation, chatbots, question-answering systems, and more.
Introduction to API
Our Text-to-Text Generation API is designed to provide high-quality text generation capabilities, leveraging advanced natural language processing techniques. This API is perfect for creating content, enhancing chatbot interactions, answering questions contextually, and much more.
Endpoint:
Method: POST
Parameters:
1. template (string, required):
- The prompt template serves as the guiding structure for generating the text. It acts as a blueprint, outlining the content and structure of the text to be generated.
- The template should contain placeholders enclosed in curly braces, indicating where dynamic content will be inserted. For example, "Generate text about '{topic}'" indicates that the word "topic" will be replaced with the actual topic provided during text generation.
2. input_list (list of strings, required):
- The input list specifies the variables or parameters required by the prompt template.
- Each element in the input list corresponds to a placeholder in the template. It provides a clear indication of the input data needed to generate the text.
- For example, if the template contains placeholders for "topic" and "audience", the input list would include these variables: ["topic", "audience"].
3. map_dict (dictionary, required):
- The map dictionary maps the input variables defined in the input list to their corresponding values.
- It ensures that the correct values are inserted into the template to generate the desired text output.
- Each key-value pair in the map dictionary associates an input variable (key) with its corresponding value (value).
- For example, if the input list includes "topic" and "audience", the map dictionary would specify the values for these variables: {"topic": "machine learning", "audience": "developers"}.
These parameters collectively provide the necessary instructions and data for the model to generate text based on the given prompt. They enable customization and control over the generated text, allowing users to tailor the output to their specific needs and requirements.
Python implementation code template
```import requests# API endpoint URLurl = "http://51.20.2.174:8000/generate"# Your API keyapi_key = "your_api_key_here" # Replace with the actual API key# Headers including the API keyheaders = {"Authorization": api_key,"Content-Type": "application/json"}# Payload for the requestpayload = {"template": "I am providing you a topic to write a blog on it. Topic='{topic}'","input_list": ["topic"],"map_dict": {"topic": "machine learning"}}# Sending the POST requestresponse = requests.post(url, headers=headers, json=payload)# Printing the responseif response.status_code == 200:print("Response JSON:", response.json())else:print("Failed to get a valid response. Status code:", response.status_code)print("Response JSON:", response.json())```
For Node.Js implementation code template
const axios = require('axios');// API endpoint URLconst url = "http://51.20.2.174:8000/generate";// Your API keyconst apiKey = "your_api_key_here"; // Replace with the actual API key// Headers including the API keyconst headers = {"Authorization": apiKey,"Content-Type": "application/json"};// Payload for the requestconst payload = {"template": "Write a persuasive advertisement for '{product}' targeting '{audience}'","input_list": ["product", "audience"],"map_dict": {"product": "electric car", "audience": "environmentally conscious consumers"}};// Sending the POST requestaxios.post(url, payload, { headers: headers }).then(response => {console.log("Response JSON:", response.data);}).catch(error => {if (error.response) {console.error("Failed to get a valid response. Status code:", error.response.status);console.error("Response JSON:", error.response.data);} else {console.error("Error:", error.message);}});
Example-1
```json{"template": "I am providing you a topic to write a blog on it. Topic='{topic}'","input_list": ["topic"],"map_dict": {"topic": "machine learning"}}```
Response
The API response will be a JSON object containing the generated text.
```json{"text": "\n\nMachine learning is a subfield of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed. It's a method of data analysis that automates analytical model building. It's based on the idea that systems can learn from data, identify patterns and make decisions with minimal human intervention.\n\nMachine learning algorithms are designed to analyze data, learn from it, and then make a determination or prediction about something new based on that data. There are several types of machine learning, including supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning.\n\nSupervised learning is a type of machine learning where the model is trained on a labeled dataset. This means that the data used to train the model has both input data and the correct output data. The model learns to map input data to output data, and once trained, it can make predictions about new data. Examples of supervised learning algorithms include linear regression, logistic regression, and support vector machines.\n\nUnsupervised learning is a type of machine learning where the model is trained on an unlabeled dataset. This means that the data used to train the model does not have any output data. The model learns to identify patterns and relationships in the data on its own. Examples of unsupervised learning algorithms include k-means clustering and principal component analysis.\n\nSemi-supervised learning is a type of machine learning that combines elements of supervised and unsupervised learning. It's used when there is a limited amount of labeled data available, and the model must learn from both labeled and unlabeled data. The model uses the labeled data to learn the correct output, and then uses the unlabeled data to refine its predictions.\n\nReinforcement learning is a type of machine learning where an agent learns to make decisions by taking actions in an environment to maximize its reward. The agent learns from its mistakes and successes, and adjusts its behavior accordingly. This type of learning is often used in robotics, gaming, and autonomous systems.\n\nMachine learning has a wide range of applications, including image and speech recognition, natural language processing, fraud detection, recommendation systems, and predictive maintenance. It's used in various industries, including healthcare, finance, retail, and manufacturing.\n\nIn conclusion, machine learning is a powerful tool for analyzing data and making predictions or determinations based on that data. It's a subfield of artificial intelligence that provides systems the ability to learn from data and improve from experience. There are several types of machine learning, including supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning. Machine learning has a wide range of applications and is used in various industries to improve efficiency, accuracy, and productivity."}```
Example-2
```json{"template": "Write a persuasive advertisement for '{product}' targeting '{audience}'","input_list": ["product", "audience"],"map_dict": {"product": "electric car", "audience": "environmentally conscious consumers"}}```
Response
```josn{"text": "\n\nDiscover the future of driving with our latest electric car, designed specifically for environmentally conscious consumers like you. Experience the perfect blend of innovation, sustainability, and performance. Our electric car not only reduces your carbon footprint but also offers unmatched efficiency and cutting-edge technology.\n\nWith zero emissions, you can drive confidently knowing you're contributing to a cleaner, greener planet. Enjoy the silent, smooth ride and impressive acceleration that electric power provides. Say goodbye to gas stations and hello to the convenience of home charging.\n\nOur electric car is packed with features to enhance your driving experience. From advanced safety systems to state-of-the-art infotainment, every detail is crafted to offer you the ultimate in comfort and convenience. Plus, with a range that takes you further on a single charge, your adventures are limitless.\n\nJoin the revolution in sustainable transportation. Drive the change you want to see in the world. Make the switch to our electric car and lead the way towards a brighter, cleaner future. Visit our website or your nearest dealer to learn more and take a test drive today.\n\nEmbrace the power of electric. Drive green, drive smart."}```
Efficiency Aspects and Comparison
Our API is optimized for efficiency and performance. It leverages state-of-the-art LLMs fine-tuned for specific tasks, ensuring quick and accurate text generation. Compared to traditional text generation methods, our API offers faster response times and higher-quality outputs due to its advanced model architecture and prompt engineering techniques.
Benefits of Using Our API
- Faster than any other AI API: We provide the fastest API response to your project.
- High-Quality Text Generation: Produce well-structured and contextually accurate text.
- Customization: Tailor text outputs to specific needs using templates and input parameters.
- Scalability: Handle a high volume of requests efficiently.
- Ease of Use: Simple API integration with clear documentation.
Service and Support
We offer comprehensive support to ensure smooth API integration and operation. Our dedicated support team is available to assist with any issues, questions, or customization needs.
Uptime Commitments
We guarantee an uptime of 99.9% for our API, ensuring reliable and consistent service availability.
API Restrictions
Users have a limit of approximately 3000 requests per day.
Use Cases
- Content Generation: Generate text for articles, stories, reports, and more.
- Chatbots: Enhance chatbot responses with dynamically generated text with context.
- Question Answering: Generate answers to user queries based on context.
About the Model
The model used in this API is a fine-tuned Large Language Model (LLM) trained on a diverse dataset. It leverages state-of-the-art natural language processing techniques to produce high-quality text output.
We hope this documentation provides a clear and comprehensive overview of our Text-to-Text Generation API. If you have any questions or need further assistance, please don't hesitate to contact our support team.
-
Ask for quotation
Get quote for by clicking
- Get Quote