MCPcopy Create free account
hub / github.com/VGabriel45/SolidityVisualizer / modify

Function modify

backend/app/routers/modify.py:34–82  ·  view source on GitHub ↗
(request: Request, body: ModifyRequest)

Source from the content-addressed store, hash-verified

32@router.post("")
33# @limiter.limit("2/minute;10/day")
34async def modify(request: Request, body: ModifyRequest):
35 try:
36 # Check instructions length
37 if not body.instructions or not body.current_diagram:
38 return {"error": "Instructions and/or current diagram are required"}
39 elif (
40 len(body.instructions) > 1000 or len(body.current_diagram) > 100000
41 ): # just being safe
42 return {"error": "Instructions exceed maximum length of 1000 characters"}
43
44 if body.repo in [
45 "fastapi",
46 "streamlit",
47 "flask",
48 "api-analytics",
49 "monkeytype",
50 ]:
51 return {"error": "Example repos cannot be modified"}
52
53 # modified_mermaid_code = claude_service.call_claude_api(
54 # system_prompt=SYSTEM_MODIFY_PROMPT,
55 # data={
56 # "instructions": body.instructions,
57 # "explanation": body.explanation,
58 # "diagram": body.current_diagram,
59 # },
60 # )
61
62 modified_mermaid_code = o1_service.call_o1_api(
63 system_prompt=SYSTEM_MODIFY_PROMPT,
64 data={
65 "instructions": body.instructions,
66 "explanation": body.explanation,
67 "diagram": body.current_diagram,
68 },
69 )
70
71 # Check for BAD_INSTRUCTIONS response
72 if "BAD_INSTRUCTIONS" in modified_mermaid_code:
73 return {"error": "Invalid or unclear instructions provided"}
74
75 return {"diagram": modified_mermaid_code}
76 except RateLimitError as e:
77 raise HTTPException(
78 status_code=429,
79 detail="Service is currently experiencing high demand. Please try again in a few minutes.",
80 )
81 except Exception as e:
82 return {"error": str(e)}

Callers

nothing calls this directly

Calls 1

call_o1_apiMethod · 0.80

Tested by

no test coverage detected