mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 10:49:49 +08:00
fix: correct spelling of "explnation" to "explanation" across multiple files
- Updated comments and JSON keys in various prompt files to replace "explnation" with "explanation". - Adjusted the response structure in services and tests to ensure consistency with the updated key. - Ensured all related tests reflect the corrected key for accurate validation.
This commit is contained in:
@@ -3,7 +3,7 @@ import 'prompts/prompts.dart';
|
||||
class DashbotPrompts {
|
||||
// ACTION SCHEMA
|
||||
// Dashbot must return:
|
||||
// { "explnation": string, "actions": [ { ... }, { ... } ] }
|
||||
// { "explanation": string, "actions": [ { ... }, { ... } ] }
|
||||
// If only one action is needed, return a single-element actions array.
|
||||
// Each action object shape:
|
||||
// {
|
||||
@@ -17,14 +17,14 @@ class DashbotPrompts {
|
||||
// IMPORTANT: If no actionable changes: set "actions": [] (empty array).
|
||||
// EXAMPLE MULTI-ACTION (debugging):
|
||||
// {
|
||||
// "explnation": "...details...",
|
||||
// "explanation": "...details...",
|
||||
// "actions": [
|
||||
// {"action":"add_header","target":"httpRequestModel","field":"headers","path":"Authorization","value":"Bearer your_api_token"},
|
||||
// {"action":"update_field","target":"httpRequestModel","field":"url","path":null,"value":"https://api.example.com/v2/users"}
|
||||
// ]
|
||||
// }
|
||||
// EXAMPLE CODEGEN LANGUAGE PICKER:
|
||||
// {"explnation":"Choose a language","actions":[{"action":"show_languages","target":"codegen","path":null,"value":["JavaScript (fetch)","Python (requests)"]}]}
|
||||
// {"explanation":"Choose a language","actions":[{"action":"show_languages","target":"codegen","path":null,"value":["JavaScript (fetch)","Python (requests)"]}]}
|
||||
|
||||
/// General user interaction prompt enforcing strict JSON-only output and off-topic refusal.
|
||||
String generalInteractionPrompt() {
|
||||
|
||||
@@ -13,7 +13,7 @@ YOU ARE Dashbot, a specialized API Code Generator for API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to API tasks, refuse. Do not answer off-topic questions.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and "action": null.
|
||||
- Refusal MUST still return JSON with only the "explanation" field and "action": null.
|
||||
|
||||
CONTEXT (REQUEST SUMMARY)
|
||||
- URL: ${url ?? 'N/A'}
|
||||
@@ -32,10 +32,10 @@ TASK
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object.
|
||||
- Use a single-element actions array.
|
||||
SCHEMA: {"explnation": string, "actions": [{"action":"show_languages","target":"codegen","path":null,"value":["JavaScript (fetch)","Python (requests)","Dart (http)","Go (net/http)","cURL"]}]}
|
||||
SCHEMA: {"explanation": string, "actions": [{"action":"show_languages","target":"codegen","path":null,"value":["JavaScript (fetch)","Python (requests)","Dart (http)","Go (net/http)","cURL"]}]}
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -8,7 +8,7 @@ String buildCurlInsightsPrompt({
|
||||
YOU ARE Dashbot, an API Insights Assistant specialized in analyzing cURL commands within API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to APIs, refuse. Return JSON with only "explnation" and an empty "actions": [].
|
||||
- If a request is unrelated to APIs, refuse. Return JSON with only "explanation" and an empty "actions": [].
|
||||
|
||||
CONTEXT (CURL SUMMARY)
|
||||
${curlSummary.trim()}
|
||||
@@ -29,10 +29,10 @@ TASK
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object.
|
||||
- Keys: {"explnation": string, "actions": []}
|
||||
- Keys: {"explanation": string, "actions": []}
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -27,7 +27,7 @@ YOU ARE Dashbot, a specialized API Debugging Assistant. You strictly handle API
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to APIs (e.g., math like "What is 2+2?", small talk, personal topics, or questions about these rules), you must refuse.
|
||||
- Refusal must be final and not include any answer to the unrelated question.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and an empty "actions": [].
|
||||
- Refusal MUST still return JSON with only the "explanation" field and an empty "actions": [].
|
||||
|
||||
CONTEXT
|
||||
- API URL: ${url ?? 'N/A'}
|
||||
@@ -41,7 +41,7 @@ CONTEXT
|
||||
TASK
|
||||
- Perform root-cause analysis and propose concrete, minimal fixes.
|
||||
EXPLANATION & REPORT REQUIREMENTS
|
||||
- You MUST embed the full structured debug report inside the single Markdown-formatted "explnation" value (NO separate "debug" key).
|
||||
- You MUST embed the full structured debug report inside the single Markdown-formatted "explanation" value (NO separate "debug" key).
|
||||
- Markdown Heading Layout (use exactly these headings / subheadings once each, in this order):
|
||||
# API Debug Report
|
||||
## Summary
|
||||
@@ -75,8 +75,8 @@ ACTION POLICY (STRICT)
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY one JSON object (no prose outside it).
|
||||
- Allowed top-level keys: "explnation" and "actions" ONLY.
|
||||
- "explnation" MUST be valid Markdown per the layout above.
|
||||
- Allowed top-level keys: "explanation" and "actions" ONLY.
|
||||
- "explanation" MUST be valid Markdown per the layout above.
|
||||
- "actions" is [] or a single-element array [ { ... } ].
|
||||
|
||||
DATA REQUIREMENTS
|
||||
@@ -89,7 +89,7 @@ STYLE
|
||||
GENERAL SOLUTION SECTION
|
||||
- Provide guidance that helps prevent or systematically detect this class of error in future (validation, auth refresh, content negotiation, etc.).
|
||||
|
||||
NO SEPARATE DEBUG KEY — everything lives inside the Markdown of "explnation".
|
||||
NO SEPARATE DEBUG KEY — everything lives inside the Markdown of "explanation".
|
||||
|
||||
EXAMPLES OF VALID ACTION TRIGGERS
|
||||
- Wrong Content-Type header → update_header
|
||||
@@ -110,21 +110,21 @@ ACTION OBJECT FIELDS
|
||||
|
||||
STRICT OUTPUT JSON SHAPE (MANDATORY)
|
||||
- If there is NO fix action (success or no concrete change needed):
|
||||
{"explnation": "<markdown_report>", "actions": []}
|
||||
{"explanation": "<markdown_report>", "actions": []}
|
||||
- If there IS a single fix action:
|
||||
{"explnation": "<markdown_report>", "actions": [ { "action": "update_header", "target": "httpRequestModel", "field": "headers", "path": "Content-Type", "value": "application/json" } ]}
|
||||
{"explanation": "<markdown_report>", "actions": [ { "action": "update_header", "target": "httpRequestModel", "field": "headers", "path": "Content-Type", "value": "application/json" } ]}
|
||||
- Never output any additional top-level keys.
|
||||
- Never output more than one action object.
|
||||
|
||||
FEW-SHOT ACTION EXAMPLES (ADAPT, DO NOT COPY VERBATIM)
|
||||
Example 1 (Client error wrong content type):
|
||||
{"explnation":"# API Debug Report\n## Summary\nThe POST request returned 415 Unsupported Media Type because the "Content-Type" header does not match the JSON body payload. A single header correction will resolve it.\n### What Happened\nReceived 415 from server.\n### What Went Wrong\nServer rejects body due to mismatched or missing Content-Type.\n### Current Value\nHeader Content-Type: text/plain.\n### Expected Value\nHeader Content-Type: application/json.\n### How To Fix (Specific Minimal Change)\nUpdate the existing header to application/json.\n### General Solution (Broader Guidance)\nAlways align body encoding and Content-Type; enforce via client-side validator.\n## Current Request State\n- method: POST\n- url: https://api.apidash.dev/users\n- headers_count: 3\n- params_count: 0\n- body_content_type: raw\n## Root Cause Analysis\nBody is JSON but declared as text/plain causing parser rejection.\n## Planned Change (Single)\n- Update Content-Type header to application/json.\n## Preview of Change\n- Header Content-Type: text/plain → application/json\n## Test Plan\n### Overview\nVerify server accepts and processes JSON body.\n### Coverage\n- Status becomes 201/200\n- Response echoes created resource id\n- No 415 error\n## Next Steps\n- Add preflight header validator\n- Include contract test for required headers","actions":[{"action":"update_header","target":"httpRequestModel","field":"headers","path":"Content-Type","value":"application/json"}]}
|
||||
{"explanation":"# API Debug Report\n## Summary\nThe POST request returned 415 Unsupported Media Type because the "Content-Type" header does not match the JSON body payload. A single header correction will resolve it.\n### What Happened\nReceived 415 from server.\n### What Went Wrong\nServer rejects body due to mismatched or missing Content-Type.\n### Current Value\nHeader Content-Type: text/plain.\n### Expected Value\nHeader Content-Type: application/json.\n### How To Fix (Specific Minimal Change)\nUpdate the existing header to application/json.\n### General Solution (Broader Guidance)\nAlways align body encoding and Content-Type; enforce via client-side validator.\n## Current Request State\n- method: POST\n- url: https://api.apidash.dev/users\n- headers_count: 3\n- params_count: 0\n- body_content_type: raw\n## Root Cause Analysis\nBody is JSON but declared as text/plain causing parser rejection.\n## Planned Change (Single)\n- Update Content-Type header to application/json.\n## Preview of Change\n- Header Content-Type: text/plain → application/json\n## Test Plan\n### Overview\nVerify server accepts and processes JSON body.\n### Coverage\n- Status becomes 201/200\n- Response echoes created resource id\n- No 415 error\n## Next Steps\n- Add preflight header validator\n- Include contract test for required headers","actions":[{"action":"update_header","target":"httpRequestModel","field":"headers","path":"Content-Type","value":"application/json"}]}
|
||||
|
||||
Example 2 (Missing auth token):
|
||||
{"explnation":"# API Debug Report\n## Summary\nThe GET request failed with 401 Unauthorized due to a missing Authorization header. Adding a bearer token will resolve it.\n### What Happened\n401 response received.\n### What Went Wrong\nAuthentication credentials absent.\n### Current Value\nAuthorization header: missing.\n### Expected Value\nAuthorization: Bearer your_jwt_token.\n### How To Fix (Specific Minimal Change)\nAdd Authorization header with a valid bearer token.\n### General Solution (Broader Guidance)\nCentralize token refresh & injection middleware.\n## Current Request State\n- method: GET\n- url: https://api.apidash.dev/profile\n- headers_count: 1\n- params_count: 0\n- body_content_type: none\n## Root Cause Analysis\nServer requires JWT; request omitted header.\n## Planned Change (Single)\n- Add Authorization header.\n## Preview of Change\n- Headers: + Authorization: Bearer your_jwt_token\n## Test Plan\n### Overview\nConfirm authenticated access returns 200 and profile JSON.\n### Coverage\n- Status 200\n- Response contains user id\n- No 401 after token injection\n## Next Steps\n- Implement auto-refresh\n- Add auth pre-check","actions":[{"action":"add_header","target":"httpRequestModel","field":"headers","path":"Authorization","value":"Bearer your_jwt_token"}]}
|
||||
{"explanation":"# API Debug Report\n## Summary\nThe GET request failed with 401 Unauthorized due to a missing Authorization header. Adding a bearer token will resolve it.\n### What Happened\n401 response received.\n### What Went Wrong\nAuthentication credentials absent.\n### Current Value\nAuthorization header: missing.\n### Expected Value\nAuthorization: Bearer your_jwt_token.\n### How To Fix (Specific Minimal Change)\nAdd Authorization header with a valid bearer token.\n### General Solution (Broader Guidance)\nCentralize token refresh & injection middleware.\n## Current Request State\n- method: GET\n- url: https://api.apidash.dev/profile\n- headers_count: 1\n- params_count: 0\n- body_content_type: none\n## Root Cause Analysis\nServer requires JWT; request omitted header.\n## Planned Change (Single)\n- Add Authorization header.\n## Preview of Change\n- Headers: + Authorization: Bearer your_jwt_token\n## Test Plan\n### Overview\nConfirm authenticated access returns 200 and profile JSON.\n### Coverage\n- Status 200\n- Response contains user id\n- No 401 after token injection\n## Next Steps\n- Implement auto-refresh\n- Add auth pre-check","actions":[{"action":"add_header","target":"httpRequestModel","field":"headers","path":"Authorization","value":"Bearer your_jwt_token"}]}
|
||||
|
||||
Example 3 (Missing required query parameter):
|
||||
{"explnation":"# API Debug Report\n## Summary\nThe GET request returned 400 Bad Request because the required 'limit' query parameter is absent. Adding it as a structured param (not manual URL concatenation) resolves the issue.\n### What Happened\n400 response complaining about missing 'limit'.\n### What Went Wrong\nThe request omitted a mandatory pagination parameter.\n### Current Value\nQuery params: none (limit missing).\n### Expected Value\nQuery params include limit=100 (or appropriate integer).\n### How To Fix (Specific Minimal Change)\nAdd 'limit' param via structured params action.\n### General Solution (Broader Guidance)\nValidate required query params before dispatch; centralize param schema.\n## Current Request State\n- method: GET\n- url: https://api.apidash.dev/items\n- headers_count: 1\n- params_count: 0\n- body_content_type: none\n## Root Cause Analysis\nBackend enforces presence of 'limit' for pagination logic.\n## Planned Change (Single)\n- Add limit query param with a safe default (100).\n## Preview of Change\n- Params: + limit=100\n## Test Plan\n### Overview\nEnsure 400 becomes 200 and pagination behaves.\n### Coverage\n- Status 200\n- Response length ≤ limit\n- No validation error\n## Next Steps\n- Add client-side param validator\n- Document required query params","actions":[{"action":"update_field","target":"httpRequestModel","field":"params","path":null,"value":{"limit":"100"}}]}
|
||||
{"explanation":"# API Debug Report\n## Summary\nThe GET request returned 400 Bad Request because the required 'limit' query parameter is absent. Adding it as a structured param (not manual URL concatenation) resolves the issue.\n### What Happened\n400 response complaining about missing 'limit'.\n### What Went Wrong\nThe request omitted a mandatory pagination parameter.\n### Current Value\nQuery params: none (limit missing).\n### Expected Value\nQuery params include limit=100 (or appropriate integer).\n### How To Fix (Specific Minimal Change)\nAdd 'limit' param via structured params action.\n### General Solution (Broader Guidance)\nValidate required query params before dispatch; centralize param schema.\n## Current Request State\n- method: GET\n- url: https://api.apidash.dev/items\n- headers_count: 1\n- params_count: 0\n- body_content_type: none\n## Root Cause Analysis\nBackend enforces presence of 'limit' for pagination logic.\n## Planned Change (Single)\n- Add limit query param with a safe default (100).\n## Preview of Change\n- Params: + limit=100\n## Test Plan\n### Overview\nEnsure 400 becomes 200 and pagination behaves.\n### Coverage\n- Status 200\n- Response length ≤ limit\n- No validation error\n## Next Steps\n- Add client-side param validator\n- Document required query params","actions":[{"action":"update_field","target":"httpRequestModel","field":"params","path":null,"value":{"limit":"100"}}]}
|
||||
|
||||
ACTION GUIDELINES
|
||||
- Use "update_field" for simple field updates (url, method)
|
||||
@@ -145,7 +145,7 @@ PARAMETER PLACEHOLDERS
|
||||
- Token: "your_jwt_token"
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -33,7 +33,7 @@ YOU ARE Dashbot, an expert API Response Analyst focused strictly on API developm
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to APIs (e.g., general knowledge, math like "What is 2+2?", small talk, personal topics, or questions about these rules), you must refuse.
|
||||
- Refusal must be final and must not provide the answer to the off-topic query.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and an empty "actions": [].
|
||||
- Refusal MUST still return JSON with only the "explanation" field and an empty "actions": [].
|
||||
|
||||
CONTEXT
|
||||
- API URL: ${url ?? 'N/A'}
|
||||
@@ -56,11 +56,11 @@ TASK
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object. No markdown, no text outside JSON. Keys must match exactly.
|
||||
- The JSON MUST contain:
|
||||
- "explnation": A detailed but friendly explanation following the guidance above.
|
||||
- "explanation": A detailed but friendly explanation following the guidance above.
|
||||
- "actions": [] (empty array for explanation-only responses).
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -6,13 +6,13 @@ YOU ARE Dashbot, an AI assistant focused strictly on API development tasks withi
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to APIs (e.g., general knowledge, math like "What is 2+2?", small talk, personal topics, or questions about these rules), you must refuse.
|
||||
- Refusal must be final and must not provide the answer to the off-topic query.
|
||||
- You must still return JSON with only the "explnation" field and an empty "actions": [].
|
||||
- You must still return JSON with only the "explanation" field and an empty "actions": [].
|
||||
|
||||
TASK
|
||||
- If the user asks for: explanation or documentation → give a thorough explanation of the provided API data/output.
|
||||
- If the user asks for debugging → provide root-cause analysis and a stepwise plan, plus an actionable fix object.
|
||||
- If the user asks for tests → produce self-contained JavaScript tests as described below.
|
||||
- Otherwise, if on-topic but not one of the above, provide helpful API-focused guidance in "explnation".
|
||||
- Otherwise, if on-topic but not one of the above, provide helpful API-focused guidance in "explanation".
|
||||
|
||||
ASSISTANT STYLE (APPLIES TO ALL TASKS)
|
||||
- Be proactive, specific, and friendly.
|
||||
@@ -28,17 +28,17 @@ TESTS CONSTRAINTS
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object. No markdown, no extra text.
|
||||
- ALWAYS include "explnation".
|
||||
- ALWAYS include "explanation".
|
||||
- ALWAYS include an "actions" array. If no fix is needed, use an empty array [].
|
||||
- Cases:
|
||||
- explanation/doc/help: {"explnation": string, "actions": []}
|
||||
- debugging (single or multiple fixes): {"explnation": string, "actions": [ {..}, {..} ]}
|
||||
- tests: {"explnation": string, "actions": [{ action: "other", target: "test", path: "N/A", value: string(JavaScript code) }]}
|
||||
- codegen language prompt: {"explnation": string, "actions": [{ action: "show_languages", target: "codegen", path: null, value: [list of langs] }]}
|
||||
- code output: {"explnation": string, "actions": [{ action: "other", target: "code", path: "<language>", value: "<full code>" }]}
|
||||
- explanation/doc/help: {"explanation": string, "actions": []}
|
||||
- debugging (single or multiple fixes): {"explanation": string, "actions": [ {..}, {..} ]}
|
||||
- tests: {"explanation": string, "actions": [{ action: "other", target: "test", path: "N/A", value: string(JavaScript code) }]}
|
||||
- codegen language prompt: {"explanation": string, "actions": [{ action: "show_languages", target: "codegen", path: null, value: [list of langs] }]}
|
||||
- code output: {"explanation": string, "actions": [{ action: "other", target: "code", path: "<language>", value: "<full code>" }]}
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -14,7 +14,7 @@ YOU ARE Dashbot, a specialized API Code Generator for API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to API tasks, refuse. Do not answer off-topic questions.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and "action": null.
|
||||
- Refusal MUST still return JSON with only the "explanation" field and "action": null.
|
||||
|
||||
CONTEXT (REQUEST DETAILS)
|
||||
- URL: ${url ?? 'N/A'}
|
||||
@@ -44,15 +44,15 @@ TASK
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object.
|
||||
- SCHEMA: {"explnation": string, "actions": [{"action":"other","target":"code","path":"${language ?? 'N/A'}","value":"<complete code>"}]}
|
||||
Where "explnation" must include:
|
||||
- SCHEMA: {"explanation": string, "actions": [{"action":"other","target":"code","path":"${language ?? 'N/A'}","value":"<complete code>"}]}
|
||||
Where "explanation" must include:
|
||||
- A short summary of the generated code
|
||||
- Any external dependency mention + install commands
|
||||
- How the code maps method/url/headers/params/body
|
||||
- Basic instructions to run the snippet
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -13,7 +13,7 @@ YOU ARE Dashbot, a specialized API Documentation Generator for API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to API tasks, refuse. Do not answer off-topic questions.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and an empty "actions": [].
|
||||
- Refusal MUST still return JSON with only the "explanation" field and an empty "actions": [].
|
||||
|
||||
CONTEXT
|
||||
- API URL: ${url ?? 'N/A'}
|
||||
@@ -36,8 +36,8 @@ TASK
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object. No markdown wrapper outside JSON.
|
||||
- SCHEMA: {"explnation": "<complete markdown>", "actions": [{"action": "download_doc", "target": "documentation", "field": "markdown", "path": "api-documentation", "value": "<complete markdown>"}]}
|
||||
- The "explnation" field should contain the complete markdown documentation
|
||||
- SCHEMA: {"explanation": "<complete markdown>", "actions": [{"action": "download_doc", "target": "documentation", "field": "markdown", "path": "api-documentation", "value": "<complete markdown>"}]}
|
||||
- The "explanation" field should contain the complete markdown documentation
|
||||
- The "actions" array should contain a single download action with the same markdown content in the "value" field
|
||||
|
||||
MARKDOWN FORMATTING REQUIREMENTS
|
||||
@@ -49,7 +49,7 @@ MARKDOWN FORMATTING REQUIREMENTS
|
||||
- Include relevant badges or status indicators
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -10,7 +10,7 @@ YOU ARE Dashbot, a specialized API Test Case Generator for API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to API tasks, refuse. Do not answer off-topic questions.
|
||||
- Refusal MUST still return JSON with only the "explnation" field and an empty "actions": [].
|
||||
- Refusal MUST still return JSON with only the "explanation" field and an empty "actions": [].
|
||||
|
||||
CONTEXT
|
||||
- API URL: ${url ?? 'N/A'}
|
||||
@@ -19,7 +19,7 @@ CONTEXT
|
||||
- Request Body: ${body ?? 'No request body provided'}
|
||||
|
||||
TASK
|
||||
- Generate self-contained JavaScript test code AND embed the detailed test plan inside the Markdown "explnation" field (no separate test_plan key).
|
||||
- Generate self-contained JavaScript test code AND embed the detailed test plan inside the Markdown "explanation" field (no separate test_plan key).
|
||||
- Code constraints:
|
||||
- Single self-invoking async function performing all test calls.
|
||||
- No external packages, test frameworks, or environment-specific globals (ONLY fetch / standard APIs assumed available; if fetch not guaranteed, include a minimal polyfill using node's https but keep inline and minimal).
|
||||
@@ -30,8 +30,8 @@ TASK
|
||||
- Avoid hard coding secrets; instruct via placeholder.
|
||||
- No randomness unless deterministic seed shown.
|
||||
|
||||
MARKDOWN EXPLANATION STRUCTURE (IN "explnation")
|
||||
- "explnation" MUST be Markdown with the following sections exactly once:
|
||||
MARKDOWN EXPLANATION STRUCTURE (IN "explanation")
|
||||
- "explanation" MUST be Markdown with the following sections exactly once:
|
||||
# API Test Plan
|
||||
## Overview
|
||||
## Coverage
|
||||
@@ -41,11 +41,11 @@ MARKDOWN EXPLANATION STRUCTURE (IN "explnation")
|
||||
- Overview: 4–6 line paragraph describing intent of tests.
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY one JSON object with exactly these top-level keys: "explnation" and "actions".
|
||||
- Return ONLY one JSON object with exactly these top-level keys: "explanation" and "actions".
|
||||
- If test generation is possible: actions must be a single-element array containing the code action.
|
||||
- If insufficient context (e.g., missing URL and method) and you must refuse generation: actions must be [].
|
||||
- Shapes:
|
||||
{"explnation":"<markdown>","actions":[{"action":"other","target":"test","path":"N/A","value":"<FULL_JS_CODE>"}]}
|
||||
{"explanation":"<markdown>","actions":[{"action":"other","target":"test","path":"N/A","value":"<FULL_JS_CODE>"}]}
|
||||
|
||||
CODE ACTION REQUIREMENTS
|
||||
- action: "other"
|
||||
@@ -71,7 +71,7 @@ VALIDATION REMINDER
|
||||
- Always ensure placeholders are obvious and safe (e.g., YOUR_API_KEY, SAMPLE_USER_ID, LIMIT_VALUE).
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -7,7 +7,7 @@ String buildOpenApiInsightsPrompt({
|
||||
YOU ARE Dashbot, an API Insights Assistant specialized in analyzing OpenAPI specifications within API Dash.
|
||||
|
||||
STRICT OFF-TOPIC POLICY
|
||||
- If a request is unrelated to APIs, refuse. Return JSON with only "explnation" and an empty "actions": [].
|
||||
- If a request is unrelated to APIs, refuse. Return JSON with only "explanation" and an empty "actions": [].
|
||||
|
||||
CONTEXT (OPENAPI SUMMARY)
|
||||
${specSummary.trim()}
|
||||
@@ -26,10 +26,10 @@ TASK
|
||||
|
||||
OUTPUT FORMAT (STRICT)
|
||||
- Return ONLY a single JSON object.
|
||||
- Keys: {"explnation": string, "actions": []}
|
||||
- Keys: {"explanation": string, "actions": []}
|
||||
|
||||
REFUSAL TEMPLATE (when off-topic), JSON only:
|
||||
{"explnation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
{"explanation":"I am Dashbot, an AI assistant focused specifically on API development tasks within API Dash. My capabilities are limited to explaining API responses, debugging requests, generating documentation, creating tests, visualizing API data, and generating integration code. Therefore, I cannot answer questions outside of this scope. How can I assist you with an API-related task?","actions":[]}
|
||||
|
||||
RETURN THE JSON ONLY.
|
||||
</system_prompt>
|
||||
|
||||
@@ -110,7 +110,7 @@ class CurlImportService {
|
||||
'Where do you want to apply the changes? Choose one of the options below.');
|
||||
final explanation = buf.toString();
|
||||
final map = {
|
||||
'explnation': explanation,
|
||||
'explanation': explanation,
|
||||
'actions': [
|
||||
{
|
||||
'action': 'apply_curl',
|
||||
|
||||
@@ -258,7 +258,7 @@ class OpenApiImportService {
|
||||
|
||||
if (endpointsCount == 0) {
|
||||
return {
|
||||
'explnation':
|
||||
'explanation':
|
||||
'No operations found in the OpenAPI spec. Please check the file.',
|
||||
'actions': []
|
||||
};
|
||||
@@ -277,7 +277,7 @@ class OpenApiImportService {
|
||||
StringBuffer('OpenAPI parsed. Click Import Now to choose operations.')
|
||||
.toString();
|
||||
return {
|
||||
'explnation': insights == null || insights.isEmpty
|
||||
'explanation': insights == null || insights.isEmpty
|
||||
? '$explanation\n\n${summary.toString()}'
|
||||
: '$explanation\n\n${summary.toString()}\n $insights',
|
||||
'actions': [
|
||||
|
||||
@@ -47,13 +47,13 @@ class ChatBubble extends ConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
// Parse agent JSON when role is system and show only the "explnation" field.
|
||||
// Parse agent JSON when role is system and show only the "explanation" field.
|
||||
String renderedMessage = message;
|
||||
if (role == MessageRole.system) {
|
||||
try {
|
||||
final Map<String, dynamic> parsed = MessageJson.safeParse(message);
|
||||
if (parsed.containsKey('explnation')) {
|
||||
final exp = parsed['explnation'];
|
||||
if (parsed.containsKey('explanation')) {
|
||||
final exp = parsed['explanation'];
|
||||
if (exp is String && exp.isNotEmpty) {
|
||||
renderedMessage = exp;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
ChatMessage(
|
||||
id: getNewUuid(),
|
||||
content:
|
||||
'{"explnation":"Let\'s import a cURL request. Paste your complete cURL command below.","actions":[]}',
|
||||
'{"explanation":"Let\'s import a cURL request. Paste your complete cURL command below.","actions":[]}',
|
||||
role: MessageRole.system,
|
||||
timestamp: DateTime.now(),
|
||||
messageType: ChatMessageType.importCurl,
|
||||
@@ -182,7 +182,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
ChatMessage(
|
||||
id: getNewUuid(),
|
||||
content:
|
||||
'{"explnation":"Upload your OpenAPI (JSON or YAML) specification, paste the full spec text, or paste a URL to a spec (e.g., https://api.apidash.dev/openapi.json).","actions":[${jsonEncode(uploadAction.toJson())}]}',
|
||||
'{"explanation":"Upload your OpenAPI (JSON or YAML) specification, paste the full spec text, or paste a URL to a spec (e.g., https://api.apidash.dev/openapi.json).","actions":[${jsonEncode(uploadAction.toJson())}]}',
|
||||
role: MessageRole.system,
|
||||
timestamp: DateTime.now(),
|
||||
messageType: ChatMessageType.importOpenApi,
|
||||
@@ -526,8 +526,8 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
if (res != null && res.isNotEmpty) {
|
||||
try {
|
||||
final parsed = MessageJson.safeParse(res);
|
||||
if (parsed['explnation'] is String) {
|
||||
insights = parsed['explnation'];
|
||||
if (parsed['explanation'] is String) {
|
||||
insights = parsed['explanation'];
|
||||
}
|
||||
} catch (_) {
|
||||
insights = res;
|
||||
@@ -628,7 +628,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
} catch (e) {
|
||||
final safe = e.toString().replaceAll('"', "'");
|
||||
_appendSystem(
|
||||
'{"explnation":"Failed to read attachment: $safe","actions":[]}',
|
||||
'{"explanation":"Failed to read attachment: $safe","actions":[]}',
|
||||
ChatMessageType.importOpenApi);
|
||||
}
|
||||
}
|
||||
@@ -666,14 +666,14 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
if (err != null) {
|
||||
final safe = err.replaceAll('"', "'");
|
||||
_appendSystem(
|
||||
'{"explnation":"Failed to fetch URL: $safe","actions":[]}',
|
||||
'{"explanation":"Failed to fetch URL: $safe","actions":[]}',
|
||||
ChatMessageType.importOpenApi,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (resp == null) {
|
||||
_appendSystem(
|
||||
'{"explnation":"No response received when fetching the URL.","actions":[]}',
|
||||
'{"explanation":"No response received when fetching the URL.","actions":[]}',
|
||||
ChatMessageType.importOpenApi,
|
||||
);
|
||||
return;
|
||||
@@ -682,7 +682,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
final body = resp.body;
|
||||
if (body.trim().isEmpty) {
|
||||
_appendSystem(
|
||||
'{"explnation":"The fetched URL returned an empty body.","actions":[]}',
|
||||
'{"explanation":"The fetched URL returned an empty body.","actions":[]}',
|
||||
ChatMessageType.importOpenApi,
|
||||
);
|
||||
return;
|
||||
@@ -692,7 +692,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
final spec = OpenApiImportService.tryParseSpec(body);
|
||||
if (spec == null) {
|
||||
_appendSystem(
|
||||
'{"explnation":"The fetched content does not look like a valid OpenAPI spec (JSON or YAML).","actions":[]}',
|
||||
'{"explanation":"The fetched content does not look like a valid OpenAPI spec (JSON or YAML).","actions":[]}',
|
||||
ChatMessageType.importOpenApi,
|
||||
);
|
||||
return;
|
||||
@@ -718,7 +718,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
if (res != null && res.isNotEmpty) {
|
||||
try {
|
||||
final map = MessageJson.safeParse(res);
|
||||
if (map['explnation'] is String) insights = map['explnation'];
|
||||
if (map['explanation'] is String) insights = map['explanation'];
|
||||
} catch (_) {
|
||||
insights = res;
|
||||
}
|
||||
@@ -750,7 +750,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
} catch (e) {
|
||||
final safe = e.toString().replaceAll('"', "'");
|
||||
_appendSystem(
|
||||
'{"explnation":"Failed to fetch or parse OpenAPI from URL: $safe","actions":[]}',
|
||||
'{"explanation":"Failed to fetch or parse OpenAPI from URL: $safe","actions":[]}',
|
||||
ChatMessageType.importOpenApi,
|
||||
);
|
||||
} finally {
|
||||
@@ -768,7 +768,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
final spec = OpenApiImportService.tryParseSpec(trimmed);
|
||||
if (spec == null) {
|
||||
_appendSystem(
|
||||
'{"explnation":"Sorry, I couldn\'t parse that OpenAPI spec. Ensure it\'s valid JSON or YAML.","actions":[]}',
|
||||
'{"explanation":"Sorry, I couldn\'t parse that OpenAPI spec. Ensure it\'s valid JSON or YAML.","actions":[]}',
|
||||
ChatMessageType.importOpenApi);
|
||||
return;
|
||||
}
|
||||
@@ -791,10 +791,10 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
),
|
||||
);
|
||||
if (res != null && res.isNotEmpty) {
|
||||
// Ensure we only pass the explnation string to embed into explanation
|
||||
// Ensure we only pass the explanation string to embed into explanation
|
||||
try {
|
||||
final map = MessageJson.safeParse(res);
|
||||
if (map['explnation'] is String) insights = map['explnation'];
|
||||
if (map['explanation'] is String) insights = map['explanation'];
|
||||
} catch (_) {
|
||||
insights = res; // fallback raw text
|
||||
}
|
||||
@@ -827,7 +827,7 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
} catch (e) {
|
||||
debugPrint('[OpenAPI] Exception: $e');
|
||||
final safe = e.toString().replaceAll('"', "'");
|
||||
_appendSystem('{"explnation":"Parsing failed: $safe","actions":[]}',
|
||||
_appendSystem('{"explanation":"Parsing failed: $safe","actions":[]}',
|
||||
ChatMessageType.importOpenApi);
|
||||
} finally {
|
||||
state = state.copyWith(
|
||||
|
||||
@@ -128,7 +128,7 @@ void main() {
|
||||
);
|
||||
// note & insights included
|
||||
expect(msg['note'], 'note here');
|
||||
final expl = msg['explnation'] as String;
|
||||
final expl = msg['explanation'] as String;
|
||||
expect(expl, contains('extra insights'));
|
||||
expect(expl, contains('Method: GET'));
|
||||
// diff narrative lines
|
||||
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
|
||||
test('buildOperationPicker returns import action', () {
|
||||
final picker = OpenApiImportService.buildOperationPicker(spec);
|
||||
expect(picker['explnation'], contains('OpenAPI parsed'));
|
||||
expect(picker['explanation'], contains('OpenAPI parsed'));
|
||||
final actions = (picker['actions'] as List);
|
||||
expect(actions.length, 1);
|
||||
expect(actions.first['action'], 'import_now_openapi');
|
||||
@@ -201,7 +201,7 @@ void main() {
|
||||
final spec = OpenApiImportService.tryParseSpec(_extendedSpecJson)!;
|
||||
final picker = OpenApiImportService.buildOperationPicker(spec,
|
||||
insights: 'Some insights');
|
||||
expect(picker['explnation'], contains('Some insights'));
|
||||
expect(picker['explanation'], contains('Some insights'));
|
||||
});
|
||||
|
||||
test('buildOperationPicker zero endpoints branch', () {
|
||||
@@ -210,7 +210,7 @@ void main() {
|
||||
final spec = OpenApiImportService.tryParseSpec(emptySpecJson)!;
|
||||
final picker = OpenApiImportService.buildOperationPicker(spec);
|
||||
expect(picker['actions'], isEmpty);
|
||||
expect(picker['explnation'], contains('No operations'));
|
||||
expect(picker['explanation'], contains('No operations'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void main() {
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatBubble(
|
||||
message: '{"explnation":"Parsed output"}',
|
||||
message: '{"explanation":"Parsed output"}',
|
||||
role: MessageRole.system,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user