# AI Assistant

## Ask a question to JSMon AI about a JavaScript file

> Ask a question about a specific JavaScript file analyzed and uploaded via JSMon. \
> This uses Google Gemini AI to generate the answer and tracks conversations.<br>

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/ask-jsmon":{"post":{"summary":"Ask a question to JSMon AI about a JavaScript file","description":"Ask a question about a specific JavaScript file analyzed and uploaded via JSMon. \nThis uses Google Gemini AI to generate the answer and tracks conversations.\n","tags":["AI Assistant"],"parameters":[{"in":"query","name":"wkspId","required":true,"schema":{"type":"string"},"description":"Workspace ID the user belongs to."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsmonId","question","type"],"properties":{"jsmonId":{"type":"string","description":"JSMon ID corresponding to the JS file stored in S3."},"question":{"type":"string","description":"The question to ask about the JavaScript file."},"type":{"type":"string","enum":["file"],"description":"Type of input. Only 'file' is currently supported."},"conversationName":{"type":"string","description":"Optional name of the conversation."},"startNewConversation":{"type":"boolean","default":false,"description":"Whether to start a new conversation thread."}}}}}},"responses":{"200":{"description":"AI-generated response from Gemini","content":{"application/json":{"schema":{"type":"object","properties":{"response":{"type":"string","description":"The AI-generated answer to the question."}}}}}},"400":{"description":"Bad Request (invalid input or API usage exceeded)"},"403":{"description":"Forbidden (unauthorized access to workspace)"},"404":{"description":"Not Found (JSMon result not found)"},"500":{"description":"Internal Server Error"}}}}}}
```

## Get random prompt suggestions

> Returns 3 random prompt suggestions from the database

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/v2/promptSuggestions":{"get":{"summary":"Get random prompt suggestions","description":"Returns 3 random prompt suggestions from the database","tags":["AI Assistant"],"responses":{"200":{"description":"Successfully retrieved prompt suggestions"}}}}}}
```

## Generate prompt suggestions based on question and response

> Generates 3 relevant follow-up questions based on the original question and its answer

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/v2/generatePromptSuggestions":{"post":{"summary":"Generate prompt suggestions based on question and response","description":"Generates 3 relevant follow-up questions based on the original question and its answer","tags":["AI Assistant"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["question","geminiResponse"],"properties":{"question":{"type":"string","description":"The original question asked"},"geminiResponse":{"type":"string","description":"The response from Gemini"}}}}}},"responses":{"200":{"description":"Successfully generated prompt suggestions","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"suggestions":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"Missing required fields"},"500":{"description":"Internal server error"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledge.jsmon.sh/api-reference/reference/ai-assistant.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
