Skip to content

Commit

Permalink
Docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Kumaravel committed Jul 18, 2023
1 parent 16d74e9 commit 56a408f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ The following API endpoints are available:
| HTTP Verbs | Endpoints | Action |
| --- | --- | --- |
| POST | /api/ask | To query with OpenAI |
| POST | /api/ask/description | To get description for given title |
| POST | /api/ask/keywords | To get keywords for given title |
| POST | /api/ask/toc | To generated TOC for given title |
| POST | /api/ask/images | To generated images for given title |
| POST | /api/fetch | To query with OpenAI |
| POST | /api/fetch/description | To get description for given title |
| POST | /api/fetch/keywords | To get keywords for given title |
| POST | /api/fetch/topics | To generated topics or table of contents for given title |
| POST | /api/fetch/images | To generated images for given title |
46 changes: 23 additions & 23 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const { ask, image } = require('./openai');

/**
* @swagger
* /api/ask:
* /api/fetch:
* post:
* summary: Ask OpenAI
* summary: Query OpenAI
* tags:
* - Course
* requestBody:
Expand All @@ -15,7 +15,7 @@ const { ask, image } = require('./openai');
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AskRequest'
* $ref: '#/components/schemas/FetchRequest'
* responses:
* 201:
* description: Response generated successfully
Expand All @@ -27,13 +27,13 @@ const { ask, image } = require('./openai');
* description: Error while fetching data
* components:
* schemas:
* AskRequest:
* FetchRequest:
* type: object
* properties:
* query:
* type: string
*/
router.post('/ask', async (req, res) => {
router.post('/fetch', async (req, res) => {
try {
if (!req['body']['query']) return res.status(400).json({ error: 'Query is mandatory' });
let { query } = req.body;
Expand All @@ -59,7 +59,7 @@ router.post('/ask', async (req, res) => {

/**
* @swagger
* /api/ask/description:
* /api/fetch/description:
* post:
* summary: Generate description for given title
* tags:
Expand All @@ -70,7 +70,7 @@ router.post('/ask', async (req, res) => {
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AskDescriptionRequest'
* $ref: '#/components/schemas/FetchDescriptionRequest'
* responses:
* 201:
* description: Description generated successfully
Expand All @@ -82,13 +82,13 @@ router.post('/ask', async (req, res) => {
* description: Error while fetching data
* components:
* schemas:
* AskDescriptionRequest:
* FetchDescriptionRequest:
* type: object
* properties:
* query:
* type: string
*/
router.post('/ask/description', async (req, res) => {
router.post('/fetch/description', async (req, res) => {
if (!req['body']['query']) return res.status(400).json({ error: 'Query is mandatory' });
let { query } = req.body;
query = 'generate brief description on ' + query;
Expand All @@ -110,7 +110,7 @@ router.post('/ask/description', async (req, res) => {

/**
* @swagger
* /api/ask/keywords:
* /api/fetch/keywords:
* post:
* summary: Generate keywords for given title
* tags:
Expand All @@ -121,7 +121,7 @@ router.post('/ask/description', async (req, res) => {
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AskKeywordsRequest'
* $ref: '#/components/schemas/FetchKeywordsRequest'
* responses:
* 201:
* description: Tags generated successfully
Expand All @@ -133,13 +133,13 @@ router.post('/ask/description', async (req, res) => {
* description: Error while fetching data
* components:
* schemas:
* AskKeywordsRequest:
* FetchKeywordsRequest:
* type: object
* properties:
* query:
* type: string
*/
router.post('/ask/keywords', async (req, res) => {
router.post('/fetch/keywords', async (req, res) => {
if (!req['body']['query']) return res.status(400).json({ error: 'Query is mandatory' });
let { query } = req.body;
query = 'generate comma separated keywords for topic ' + query;
Expand All @@ -162,9 +162,9 @@ router.post('/ask/keywords', async (req, res) => {

/**
* @swagger
* /api/ask/toc:
* /api/fetch/topics:
* post:
* summary: Generate toc for given title
* summary: Generate topics (TOC) for given title
* tags:
* - Course
* requestBody:
Expand All @@ -173,7 +173,7 @@ router.post('/ask/keywords', async (req, res) => {
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AskTOCRequest'
* $ref: '#/components/schemas/FetchTOCRequest'
* responses:
* 201:
* description: TOC generated successfully
Expand All @@ -185,13 +185,13 @@ router.post('/ask/keywords', async (req, res) => {
* description: Error while fetching data
* components:
* schemas:
* AskTOCRequest:
* FetchTOCRequest:
* type: object
* properties:
* query:
* type: string
*/
router.post('/ask/toc', async (req, res) => {
router.post('/fetch/topics', async (req, res) => {
if (!req['body']['query']) return res.status(400).json({ error: 'Query is mandatory' });
let { query } = req.body;
query = 'generate chapter titles for textbook ' + query + ' in the form of ordered list using number format';
Expand Down Expand Up @@ -228,7 +228,7 @@ router.post('/ask/toc', async (req, res) => {

/**
* @swagger
* /api/ask/images:
* /api/fetch/images:
* post:
* summary: Generate image for given prompt
* tags:
Expand All @@ -239,7 +239,7 @@ router.post('/ask/toc', async (req, res) => {
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/AskImageRequest'
* $ref: '#/components/schemas/FetchImageRequest'
* responses:
* 201:
* description: Image generated successfully
Expand All @@ -251,16 +251,16 @@ router.post('/ask/toc', async (req, res) => {
* description: Error while fetching data
* components:
* schemas:
* AskImageRequest:
* FetchImageRequest:
* type: object
* properties:
* query:
* type: string
*/
router.post('/ask/images', async (req, res) => {
router.post('/fetch/images', async (req, res) => {
if (!req['body']['query']) return res.status(400).json({ error: 'Query is mandatory' });
let { query } = req.body;
query = 'can you generate cover image for english article about ' + query;
query = 'cover of a ' + query;
await image(query)
.then((answer) => {
if (answer) {
Expand Down

0 comments on commit 56a408f

Please sign in to comment.