-
Notifications
You must be signed in to change notification settings - Fork 337
feat: Add live-api-debugger template #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AniketKu23
wants to merge
2
commits into
Lamatic:main
Choose a base branch
from
AniketKu23:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Live API Debugger 🐛 -> 🦋 | ||
|
|
||
| An advanced developer tool that fixes your broken API integration code by directly reading the live official API documentation. | ||
|
|
||
| ## Why this exists | ||
|
|
||
| APIs update constantly. LLMs often hallucinate deprecated code because their training data is outdated. By forcing the agent to scrape the live documentation URL you provide, you guarantee the AI writes code for the exact, newest version of the API. | ||
|
|
||
| ## How it works | ||
|
|
||
| 1. **Trigger**: Accepts `error_message`, `failing_code`, and `api_docs_url`. | ||
| 2. **Scraper (Firecrawl)**: Visits the `api_docs_url` and extracts the main Markdown content. | ||
| 3. **LLM**: Analyzes the error and failing code against the fresh documentation context to generate a Root Cause Analysis, rewritten code, and verification steps. | ||
|
|
||
| ## How to test it | ||
|
|
||
| 1. Create a flow in Lamatic Studio based on this template. | ||
| 2. Provide test values: | ||
| - `error_message`: `{"error": "Missing required param: currency."}` | ||
| - `failing_code`: `stripe.paymentIntents.create({ amount: 2000 })` | ||
| - `api_docs_url`: `https://docs.stripe.com/api/payment_intents/create` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Live API Debugger | ||
|
|
||
| ## Overview | ||
|
|
||
| This template implements a synchronous, request-response pipeline for debugging code. It accepts an error message, code snippet, and documentation URL via a GraphQL API Request. It uses Firecrawl to fetch the live documentation page, and an LLM to reason over the documentation to fix the user's code. | ||
|
|
||
| ## Flow | ||
|
|
||
| 1. **API Request**: Receives `error_message`, `failing_code`, and `api_docs_url`. | ||
| 2. **Firecrawl Scraper**: Fetches `api_docs_url` and extracts the main text. | ||
| 3. **Generate Text (LLM)**: Analyzes the context and generates the markdown fix. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| 4. **API Response**: Returns a JSON object with a `fix` field containing the generated markdown. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export default ` | ||
| # Default Constitution | ||
| 1. Be helpful and professional. | ||
| 2. Provide code fixes that are safe and secure. | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| export const meta = { | ||
| "name": "Live API Debugger", | ||
| "description": "Advanced API Error Troubleshooter. Scrapes live docs to fix failing code.", | ||
| "tags": ["developer-tools", "debugging"], | ||
| "testInput": null, | ||
| "githubUrl": "https://github.com/Lamatic/AgentKit/tree/main/kits/live-api-debugger", | ||
| "documentationUrl": "", | ||
| "deployUrl": "", | ||
| "author": { | ||
| "name": "Lamatic Intern Candidate", | ||
| "email": "candidate@example.com" | ||
| } | ||
| }; | ||
|
|
||
| export const inputs = {}; | ||
|
|
||
| export const references = { | ||
| "constitutions": { | ||
| "default": "@constitutions/default.md" | ||
| }, | ||
| "prompts": { | ||
| "live_api_debugger_generate_text_user": "@prompts/live-api-debugger_generate-text_user.md", | ||
| "live_api_debugger_generate_text_system": "@prompts/live-api-debugger_generate-text_system.md" | ||
| }, | ||
| "modelConfigs": { | ||
| "live_api_debugger_generate_text": "@model-configs/live-api-debugger_generate-text.ts" | ||
| } | ||
| }; | ||
|
|
||
| export const nodes = [ | ||
| { | ||
| "id": "triggerNode_1", | ||
| "type": "triggerNode", | ||
| "position": { "x": 0, "y": 0 }, | ||
| "data": { | ||
| "nodeId": "graphqlNode", | ||
| "trigger": true, | ||
| "values": { | ||
| "nodeName": "API Request", | ||
| "responeType": "realtime", | ||
| "advance_schema": "{\"error_message\":\"string\",\"failing_code\":\"string\",\"api_docs_url\":\"string\"}" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "scraperNode_2", | ||
| "type": "dynamicNode", | ||
| "position": { "x": 0, "y": 0 }, | ||
| "data": { | ||
| "nodeId": "scraperNode", | ||
| "values": { | ||
| "nodeName": "Scraper", | ||
| "url": "{{triggerNode_1.output.api_docs_url}}", | ||
| "mobile": false, | ||
| "waitFor": 2000, | ||
| "credentials": null, | ||
| "excludeTags": [], | ||
| "includeTags": [], | ||
| "onlyMainContent": true, | ||
| "skipTLsVerification": false | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "LLMNode_3", | ||
| "type": "dynamicNode", | ||
| "position": { "x": 0, "y": 0 }, | ||
| "data": { | ||
| "nodeId": "LLMNode", | ||
| "values": { | ||
| "nodeName": "Generate Text", | ||
| "tools": [], | ||
| "prompts": [ | ||
| { | ||
| "id": "user-prompt", | ||
| "role": "user", | ||
| "content": "@prompts/live-api-debugger_generate-text_user.md" | ||
| }, | ||
| { | ||
| "id": "system-prompt", | ||
| "role": "system", | ||
| "content": "@prompts/live-api-debugger_generate-text_system.md" | ||
| } | ||
| ], | ||
| "memories": "@model-configs/live-api-debugger_generate-text.ts", | ||
| "messages": "@model-configs/live-api-debugger_generate-text.ts", | ||
| "generativeModelName": "@model-configs/live-api-debugger_generate-text.ts" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "graphqlResponseNode_4", | ||
| "type": "dynamicNode", | ||
| "position": { "x": 0, "y": 0 }, | ||
| "data": { | ||
| "nodeId": "graphqlResponseNode", | ||
| "values": { | ||
| "nodeName": "API Response", | ||
| "outputMapping": "{\n \"fix\": \"{{LLMNode_3.output.generatedResponse}}\"\n}" | ||
| } | ||
| } | ||
| } | ||
| ]; | ||
|
|
||
| export const edges = [ | ||
| { | ||
| "id": "triggerNode_1-scraperNode_2", | ||
| "source": "triggerNode_1", | ||
| "target": "scraperNode_2", | ||
| "sourceHandle": "bottom", | ||
| "targetHandle": "top", | ||
| "type": "defaultEdge" | ||
| }, | ||
| { | ||
| "id": "scraperNode_2-LLMNode_3", | ||
| "source": "scraperNode_2", | ||
| "target": "LLMNode_3", | ||
| "sourceHandle": "bottom", | ||
| "targetHandle": "top", | ||
| "type": "defaultEdge" | ||
| }, | ||
| { | ||
| "id": "LLMNode_3-graphqlResponseNode_4", | ||
| "source": "LLMNode_3", | ||
| "target": "graphqlResponseNode_4", | ||
| "sourceHandle": "bottom", | ||
| "targetHandle": "top", | ||
| "type": "defaultEdge" | ||
| }, | ||
| { | ||
| "id": "response-graphqlResponseNode_4", | ||
| "source": "triggerNode_1", | ||
| "target": "graphqlResponseNode_4", | ||
| "sourceHandle": "to-response", | ||
| "targetHandle": "from-trigger", | ||
| "type": "responseEdge" | ||
| } | ||
| ]; | ||
|
|
||
| export default { meta, inputs, references, nodes, edges }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export default { | ||
| name: "Live API Debugger", | ||
| description: "Advanced API Error Troubleshooter. Analyzes an error message, failing code snippet, and scrapes the live official API documentation using Firecrawl to provide a precise code fix.", | ||
| version: '1.0.0', | ||
| type: 'template' as const, | ||
| author: {"name":"Lamatic Intern Candidate","email":"candidate@example.com"}, | ||
| tags: ["developer-tools", "debugging", "agentic-coding"], | ||
| steps: [ | ||
| { id: "live-api-debugger", type: 'mandatory' as const } | ||
| ], | ||
| links: { | ||
| "github": "https://github.com/Lamatic/AgentKit/tree/main/kits/live-api-debugger" | ||
| }, | ||
| }; |
5 changes: 5 additions & 0 deletions
5
kits/live-api-debugger/model-configs/live-api-debugger_generate-text.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export default { | ||
| "provider": "openai", | ||
| "model": "gpt-4o", | ||
| "temperature": 0.2 | ||
| }; |
1 change: 1 addition & 0 deletions
1
kits/live-api-debugger/prompts/live-api-debugger_generate-text_system.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| You are an elite Senior Backend Engineer. Your job is to debug failing code based on an error message and the official API documentation. Be concise, accurate, and professional. Format your response in clean Markdown with three sections: 'Root Cause Analysis', 'The Fix (Code)', and 'Verification'. |
12 changes: 12 additions & 0 deletions
12
kits/live-api-debugger/prompts/live-api-debugger_generate-text_user.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| **Error Message:** | ||
| {{triggerNode_1.output.error_message}} | ||
|
|
||
| **Failing Code:** | ||
| ``` | ||
| {{triggerNode_1.output.failing_code}} | ||
| ``` | ||
|
|
||
| **API Docs Context:** | ||
| {{scraperNode_2.output.markdown}} | ||
|
|
||
| Please analyze the context and provide the working code to fix the error. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.