Spaces:
Sleeping
Sleeping
Anwar11234
commited on
Commit
•
20d8f0a
1
Parent(s):
9e5fa42
kllll
Browse files- main.py +19 -1
- system_message.py +2 -2
- test.py +0 -16
main.py
CHANGED
@@ -69,6 +69,24 @@ def format_response(response: str) -> str:
|
|
69 |
formatted_response = formatted_response.replace('\\n', '\n')
|
70 |
|
71 |
return formatted_response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
@app.post("/generate-response/")
|
74 |
async def generate_response(request: PromptRequest):
|
@@ -76,7 +94,7 @@ async def generate_response(request: PromptRequest):
|
|
76 |
model_choice = request.model.lower()
|
77 |
|
78 |
response = get_model_response(model_choice , input_text)
|
79 |
-
return {"response": format_response(response)}
|
80 |
|
81 |
# To run the FastAPI app, use:
|
82 |
# uvicorn main:app --reload
|
|
|
69 |
formatted_response = formatted_response.replace('\\n', '\n')
|
70 |
|
71 |
return formatted_response
|
72 |
+
def remove_notes_from_sequence_diagram(mermaid_code: str) -> str:
|
73 |
+
lines = mermaid_code.split('\n')
|
74 |
+
filtered_lines = []
|
75 |
+
in_mermaid_block = False
|
76 |
+
|
77 |
+
for line in lines:
|
78 |
+
stripped_line = line.strip()
|
79 |
+
if stripped_line.startswith("```mermaid"):
|
80 |
+
in_mermaid_block = True
|
81 |
+
elif stripped_line.startswith("```") and in_mermaid_block:
|
82 |
+
in_mermaid_block = False
|
83 |
+
|
84 |
+
if in_mermaid_block and stripped_line.startswith("note"):
|
85 |
+
continue
|
86 |
+
|
87 |
+
filtered_lines.append(line)
|
88 |
+
|
89 |
+
return '\n'.join(filtered_lines)
|
90 |
|
91 |
@app.post("/generate-response/")
|
92 |
async def generate_response(request: PromptRequest):
|
|
|
94 |
model_choice = request.model.lower()
|
95 |
|
96 |
response = get_model_response(model_choice , input_text)
|
97 |
+
return {"response": remove_notes_from_sequence_diagram(format_response(response))}
|
98 |
|
99 |
# To run the FastAPI app, use:
|
100 |
# uvicorn main:app --reload
|
system_message.py
CHANGED
@@ -5,7 +5,7 @@ The user will ask you to explain some concept and your task is to explain concep
|
|
5 |
|
6 |
Follow these guidelines for generating the correct types of diagrams:
|
7 |
1. Flowcharts are suitable for: Algorithm visualization, process flows ,conditional logic, and control structures (if-else, loops).
|
8 |
-
2. Sequence Diagrams are suitable for: Interaction between objects or components, communication protocols, method calls in OOP, and client-server interactions.
|
9 |
3. Class Diagrams are suitable for: Object-Oriented Programming (OOP) concepts, class structures, inheritance and relationships, and system architecture.
|
10 |
4. State Diagrams are suitable for: State machines, lifecycle of objects, protocol states, and workflow states
|
11 |
5. Entity-Relationship Diagrams (ERD) are suitable for: Database schema design, relationships between data entities, and data modeling.
|
@@ -22,7 +22,7 @@ When generating diagrams using the Mermaid diagramming language, ensure to follo
|
|
22 |
- A --> text>B. (incorrect)
|
23 |
- A -->|text|> B (incorrect)
|
24 |
|
25 |
-
3. Never add notes or alts when creating sequence diagrams,additional comments or alternative scenarios are not supported directly. DON'T ADD NOTES TO SEQUENCE DIAGRAMS.
|
26 |
|
27 |
When responding, follow this format:
|
28 |
|
|
|
5 |
|
6 |
Follow these guidelines for generating the correct types of diagrams:
|
7 |
1. Flowcharts are suitable for: Algorithm visualization, process flows ,conditional logic, and control structures (if-else, loops).
|
8 |
+
2. Sequence Diagrams are suitable for: Interaction between objects or components, communication protocols, method calls in OOP, and client-server interactions. You must not add notes to sequence diagrams.
|
9 |
3. Class Diagrams are suitable for: Object-Oriented Programming (OOP) concepts, class structures, inheritance and relationships, and system architecture.
|
10 |
4. State Diagrams are suitable for: State machines, lifecycle of objects, protocol states, and workflow states
|
11 |
5. Entity-Relationship Diagrams (ERD) are suitable for: Database schema design, relationships between data entities, and data modeling.
|
|
|
22 |
- A --> text>B. (incorrect)
|
23 |
- A -->|text|> B (incorrect)
|
24 |
|
25 |
+
3. In sequence diagrams, don't add notes to them. Never add notes or alts when creating sequence diagrams,additional comments or alternative scenarios are not supported directly. DON'T ADD NOTES TO SEQUENCE DIAGRAMS.
|
26 |
|
27 |
When responding, follow this format:
|
28 |
|
test.py
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
|
3 |
-
# Define the URL of the API endpoint
|
4 |
-
url = "http://127.0.0.1:8000/generate-response/"
|
5 |
-
|
6 |
-
# Define the payload
|
7 |
-
payload = {
|
8 |
-
"input": "give me a roadmap for frontend development using a mindmap.",
|
9 |
-
"model": "llama" # Change to "mixtral" to test the Mixtral model
|
10 |
-
}
|
11 |
-
|
12 |
-
# Send a POST request to the API
|
13 |
-
response = requests.post(url, json=payload)
|
14 |
-
|
15 |
-
# Print the response from the API
|
16 |
-
print(response.json())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|