Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,10 +46,37 @@ def generate_mermaid_code(prompt):
|
|
46 |
if response.status_code == 200:
|
47 |
result = response.json()
|
48 |
# Extract the generated Mermaid.js code
|
49 |
-
|
|
|
|
|
50 |
else:
|
51 |
return f"Error: {response.status_code}, {response.text}"
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Function to process text, audio, or both inputs
|
54 |
def process_input(input_type, text_input, audio_input):
|
55 |
if input_type == "Audio" and audio_input is not None:
|
|
|
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 |
+
mermaid_prompt = f"{prompt}"
|
58 |
+
|
59 |
+
|
60 |
+
# Prepare the payload (input for the model)
|
61 |
+
payload = {
|
62 |
+
"inputs": mermaid_prompt,
|
63 |
+
"parameters": {
|
64 |
+
"max_length": 256,
|
65 |
+
"temperature": 0.7
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
# Send the request to the Mistral API
|
70 |
+
response = requests.post(MISTRAL_API_URL, headers=headers, json=payload)
|
71 |
+
|
72 |
+
# Check if the request was successful
|
73 |
+
if response.status_code == 200:
|
74 |
+
result = response.json()
|
75 |
+
# Extract the generated Mermaid.js code
|
76 |
+
return result[0]['generated_text'].strip()
|
77 |
+
else:
|
78 |
+
return f"Error: {response.status_code}, {response.text}"
|
79 |
+
|
80 |
# Function to process text, audio, or both inputs
|
81 |
def process_input(input_type, text_input, audio_input):
|
82 |
if input_type == "Audio" and audio_input is not None:
|