Anwar11234 commited on
Commit
bdd8d7a
·
1 Parent(s): 24ad1e8
Files changed (2) hide show
  1. main.py +1 -20
  2. system_message.py +1 -1
main.py CHANGED
@@ -69,32 +69,13 @@ def format_response(response: str) -> str:
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):
93
  input_text = request.input
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
 
69
  formatted_response = formatted_response.replace('\\n', '\n')
70
 
71
  return formatted_response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  @app.post("/generate-response/")
73
  async def generate_response(request: PromptRequest):
74
  input_text = request.input
75
  model_choice = request.model.lower()
76
 
77
  response = get_model_response(model_choice , input_text)
78
+ return {"response": format_response(response)}
79
 
80
  # To run the FastAPI app, use:
81
  # uvicorn main:app --reload
system_message.py CHANGED
@@ -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. 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
 
 
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. DON'T ADD NOTES TO SEQUENCE DIAGRAMS.
26
 
27
  When responding, follow this format:
28