Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,35 +24,35 @@ def transcribe_audio(audio_file):
|
|
24 |
return f"Error: {response.status_code}, {response.text}"
|
25 |
|
26 |
# Function to query the Mistral model to generate Mermaid.js code
|
27 |
-
def generate_mermaid_code(prompt):
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
-
if response.status_code == 200:
|
47 |
-
result = response.json()
|
48 |
-
# Extract the generated Mermaid.js code
|
49 |
-
PROMPT1 = f"ORGANISE, OPTIME AND FORMATE MERMAID.JS CODE AND GIVE ME only MERMAID.JS CODE : {result[0]['generated_text'].strip()}"
|
50 |
-
return generate_mermaid_code1(PROMPT1)
|
51 |
-
# return result[0]['generated_text'].strip()
|
52 |
-
else:
|
53 |
-
return f"Error: {response.status_code}, {response.text}"
|
54 |
-
|
55 |
-
def generate_mermaid_code1(prompt):
|
56 |
|
57 |
# Model endpoint
|
58 |
MODEL = "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
|
@@ -65,10 +65,10 @@ def generate_mermaid_code1(prompt):
|
|
65 |
"Authorization": f"Bearer {api_key}",
|
66 |
"Content-Type": "application/json"
|
67 |
}
|
68 |
-
|
69 |
# Define input messages
|
70 |
messages = [
|
71 |
-
{"role": "user", "content":
|
72 |
]
|
73 |
|
74 |
# Extract user content as input text
|
|
|
24 |
return f"Error: {response.status_code}, {response.text}"
|
25 |
|
26 |
# Function to query the Mistral model to generate Mermaid.js code
|
27 |
+
# def generate_mermaid_code(prompt):
|
28 |
+
# # mermaid_prompt = f"Use the appropriate diagram type (Use Case Diagram, Flowchart, Sequence Diagram, Entity-Relationship (ER) Diagram,State Diagram, Pie Chart etc.) based on the context.\n" \
|
29 |
+
# # "Generate a valid, syntactically correct MermaidJS diagram code for the following: {prompt}"
|
30 |
+
# mermaid_prompt = f"Generate a valid MermaidJS diagram code for the following: {prompt}"
|
31 |
+
|
32 |
+
|
33 |
+
# # Prepare the payload (input for the model)
|
34 |
+
# payload = {
|
35 |
+
# "inputs": mermaid_prompt,
|
36 |
+
# "parameters": {
|
37 |
+
# "max_length": 256,
|
38 |
+
# "temperature": 0.7
|
39 |
+
# }
|
40 |
+
# }
|
41 |
+
|
42 |
+
# # Send the request to the Mistral API
|
43 |
+
# response = requests.post(MISTRAL_API_URL, headers=headers, json=payload)
|
44 |
+
|
45 |
+
# # Check if the request was successful
|
46 |
+
# if response.status_code == 200:
|
47 |
+
# result = response.json()
|
48 |
+
# # Extract the generated Mermaid.js code
|
49 |
+
# PROMPT1 = f"ORGANISE, OPTIME AND FORMATE MERMAID.JS CODE AND GIVE ME only MERMAID.JS CODE : {result[0]['generated_text'].strip()}"
|
50 |
+
# return generate_mermaid_code1(PROMPT1)
|
51 |
+
# # return result[0]['generated_text'].strip()
|
52 |
+
# else:
|
53 |
+
# return f"Error: {response.status_code}, {response.text}"
|
54 |
|
55 |
+
def generate_mermaid_code(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
# Model endpoint
|
58 |
MODEL = "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
|
|
|
65 |
"Authorization": f"Bearer {api_key}",
|
66 |
"Content-Type": "application/json"
|
67 |
}
|
68 |
+
mermaid_prompt = f"Generate all valid MermaidJS code for the following: {prompt}"
|
69 |
# Define input messages
|
70 |
messages = [
|
71 |
+
{"role": "user", "content": mermaid_prompt}
|
72 |
]
|
73 |
|
74 |
# Extract user content as input text
|