Skip to content

Commit 2f66e12

Browse files
add high reasoning for code generation step + other things
1 parent 768f716 commit 2f66e12

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![Image](./docs/readme_img.png "GitDiagram Front Page")](https://gitdiagram.com/)
22

33
![License](https://img.shields.io/badge/license-MIT-blue.svg)
4+
[![Kofi](https://img.shields.io/badge/Kofi-F16061.svg?logo=ko-fi&logoColor=white)](https://ko-fi.com/ahmedkhaleel2004)
45

56
# GitDiagram
67

backend/app/prompts.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
- Color coding or shapes to distinguish between different types of components
5454
- A legend explaining any symbols or abbreviations used
5555
56-
7. Emphasize the importance of keeping the diagram at an appropriate level of abstraction while still keeping a significant amount of detail and capturing the essential architectural elements.
56+
7. NOTE: Emphasize the importance of being very detailed and capturing the essential architectural elements. Don't overthink it too much, simply separating the project into as many components as possible is best.
5757
5858
Present your explanation and instructions within <explanation> tags, ensuring that you tailor your advice to the specific project based on the provided file tree and README content.
5959
"""
@@ -77,15 +77,6 @@
7777
3. Include both directories and specific files when relevant.
7878
4. If a component doesn't have a clear corresponding file or directory, simply dont include it in the map.
7979
80-
Before providing your final answer, use the <scratchpad> to think through your process:
81-
1. List the key components identified in the system design.
82-
2. For each component, brainstorm potential corresponding directories or files.
83-
3. Verify your mappings by double-checking the file tree.
84-
85-
<scratchpad>
86-
[Your thought process here]
87-
</scratchpad>
88-
8980
Now, provide your final answer in the following format:
9081
9182
<component_mapping>
@@ -97,6 +88,16 @@
9788
Remember to be as specific as possible in your mappings, only use what is given to you from the file tree, and to strictly follow the components mentioned in the explanation.
9889
"""
9990

91+
# ❌ BELOW IS A REMOVED SECTION FROM THE ABOVE PROMPT USED FOR CLAUDE 3.5 SONNET
92+
# Before providing your final answer, use the <scratchpad> to think through your process:
93+
# 1. List the key components identified in the system design.
94+
# 2. For each component, brainstorm potential corresponding directories or files.
95+
# 3. Verify your mappings by double-checking the file tree.
96+
97+
# <scratchpad>
98+
# [Your thought process here]
99+
# </scratchpad>
100+
100101
# just adding some clear separation between the prompts
101102
# ************************************************************
102103
# ************************************************************
@@ -140,6 +141,7 @@
140141
- If you believe the component references a specific file, include the file path.
141142
- Make sure to include the full path to the directory or file exactly as specified in the component mapping.
142143
- It is very important that you do this for as many files as possible. The more the better.
144+
- IMPORTANT: these are for click events only, these paths should not be included in the diagram's node's names.
143145
144146
Your output should be valid Mermaid.js code that can be rendered into a diagram.
145147
@@ -152,7 +154,7 @@
152154
153155
EXTREMELY Important notes on syntax!!! (PAY ATTENTION TO THIS):
154156
- Make sure to add colour to the diagram!!! This is extremely critical.
155-
- In Mermaid.js syntax, we cannot include special characters for nodes without being inside quotes! For example: `EX[/api/process (Backend)]:::api` is a syntax error but `EX["/api/process (Backend)"]:::api` is valid. This is extremely important.
157+
- In Mermaid.js syntax, we cannot include special characters for nodes without being inside quotes! For example: `EX[/api/process (Backend)]:::api` and `API -->|calls Process()| Backend` are two examples of syntax errors. They should be `EX["/api/process (Backend)"]:::api` and `API -->|"calls Process()"| Backend` respectively. Notice the quotes. This is extremely important. Make sure to include quotes for any string that contains special characters.
156158
- In Mermaid.js syntax, you cannot apply a class style directly within a subgraph declaration. For example: `subgraph "Frontend Layer":::frontend` is a syntax error. However, you can apply them to nodes within the subgraph. For example: `Example["Example Node"]:::frontend` is valid, and `class Example1,Example2 frontend` is valid.
157159
"""
158160
# ^^^ note: ive generated a few diagrams now and claude still writes incorrect mermaid code sometimes. in the future, refer to those generated diagrams and add important instructions to the prompt above to avoid those mistakes. examples are best.

backend/app/routers/generate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ async def generate(request: Request, body: ApiRequest):
179179
"instructions": body.instructions,
180180
},
181181
api_key=body.api_key,
182+
reasoning_effort="high",
182183
)
183184

184185
# check for and remove code block tags

backend/app/services/o3_mini_openrouter_service.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from app.utils.format_message import format_user_message
44
import tiktoken
55
import os
6+
from typing import Literal
67

78
load_dotenv()
89

@@ -16,7 +17,11 @@ def __init__(self):
1617
self.encoding = tiktoken.get_encoding("o200k_base")
1718

1819
def call_o3_api(
19-
self, system_prompt: str, data: dict, api_key: str | None = None
20+
self,
21+
system_prompt: str,
22+
data: dict,
23+
api_key: str | None = None,
24+
reasoning_effort: Literal["low", "medium", "high"] = "medium",
2025
) -> str:
2126
"""
2227
Makes an API call to OpenRouter O3 and returns the response.
@@ -45,13 +50,13 @@ def call_o3_api(
4550
"X-Title": "gitdiagram", # Optional. Site title for rankings on openrouter.ai.
4651
},
4752
model="openai/o3-mini", # Can be configured as needed
48-
reasoning_effort="medium", # Can be adjusted based on needs
53+
reasoning_effort=reasoning_effort, # Can be adjusted based on needs
4954
messages=[
5055
{"role": "system", "content": system_prompt},
5156
{"role": "user", "content": user_message},
5257
],
53-
max_completion_tokens=8192, # Adjust as needed
54-
temperature=0,
58+
max_completion_tokens=12000, # Adjust as needed
59+
temperature=0.2,
5560
)
5661

5762
if completion.choices[0].message.content is None:

src/components/loading.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const messages = [
1818
"Finding component relationships...",
1919
"Linking components to code...",
2020
"Extracting relevant directories...",
21+
"Reasoning about the diagram...",
2122
"Prompt engineers needed -> Check out the GitHub",
2223
"Shoutout to GitIngest for inspiration",
2324
"I need to find a way to make this faster...",

0 commit comments

Comments
 (0)