forked from Significant-Gravitas/AutoGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
197 changed files
with
67 additions
and
22,067 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
autogpts/SoloAgent/forge/actions/diagram_gen/diagram_gen.py
This file contains 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,59 @@ | ||
from __future__ import annotations | ||
from ..registry import action | ||
from forge.sdk import ForgeLogger, PromptEngine | ||
import requests | ||
import os | ||
|
||
LOG = ForgeLogger(__name__) | ||
API_KEY = os.getenv("ERASERIO_API_KEY") | ||
|
||
@action( | ||
name="gen-diagram-eraserio", | ||
description="Generate a code diagram using eraser.io", | ||
parameters=[ | ||
{ | ||
"name": "specification", | ||
"description": "Code specification", | ||
"type": "string", | ||
"required": True, | ||
}, | ||
{ | ||
"name": "code", | ||
"description": "Code generated from the specification", | ||
"type": "string", | ||
"required": False | ||
} | ||
], | ||
output_type="str" | ||
) | ||
async def generate_diagram(agent, task_id: str, specification: str, code: str) -> str: | ||
prompt_engine = PromptEngine("gpt-3.5-turbo") | ||
diagram_prompt = prompt_engine.load_prompt("diagram-prompt", specification=specification, code=code) | ||
|
||
url = "https://app.eraser.io/api/render/prompt" | ||
|
||
payload = { | ||
"text": diagram_prompt, | ||
"diagramType": "sequence-diagram", | ||
"background": True, | ||
"theme": "light", | ||
"scale": "1", | ||
"returnFile": True | ||
} | ||
headers = { | ||
"accept": "application/json", | ||
"content-type": "application/json", | ||
"Authorization": f"Bearer {API_KEY}" | ||
} | ||
|
||
response = requests.post(url, json=payload, headers=headers) | ||
|
||
if response.status_code == 200: | ||
result = response.json() | ||
LOG.info(f"Diagram generated successfully: {result['fileUrl']}") | ||
return result['fileUrl'] | ||
else: | ||
LOG.error(f"Error generating diagram: {response.text}") | ||
return "Failed to generate diagram." | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
autogpts/SoloAgent/forge/prompts/gpt-3.5-turbo/diagram-prompt.j2
This file contains 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,8 @@ | ||
# Solana Account Diagram | ||
# Specification: | ||
{{ specification }} | ||
|
||
# Code: | ||
{{ code }} | ||
|
||
# Based on the specification and the code craft a perfect prompt to feed into the eraser.io API LLM to generate the diagram |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.