Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import re
|
|
5 |
|
6 |
# WARNING: It is not recommended to hardcode sensitive data like API tokens in code.
|
7 |
# Consider using environment variables or other secure methods for production applications.
|
8 |
-
API_URL = "https://deployment.datasaur.ai/api/deployment/8/
|
9 |
API_TOKEN = os.environ["DATASAUR_API_KEY"]
|
10 |
|
11 |
def magic_function(input_text):
|
@@ -17,7 +17,7 @@ def magic_function(input_text):
|
|
17 |
"Authorization": f"Bearer {API_TOKEN}",
|
18 |
}
|
19 |
data = {
|
20 |
-
"messages": [{"role": "user", "content": f"
|
21 |
}
|
22 |
|
23 |
try:
|
@@ -31,8 +31,8 @@ def magic_function(input_text):
|
|
31 |
content = response_json.get("choices", [{}])[0].get("message", {}).get("content", "Error: Could not parse response.")
|
32 |
|
33 |
# Remove unwanted prefixes and characters from the response.
|
34 |
-
# This regex removes "
|
35 |
-
content = re.sub(r'^\s*(\*\*
|
36 |
content = content.replace("`", "")
|
37 |
|
38 |
return content.strip()
|
|
|
5 |
|
6 |
# WARNING: It is not recommended to hardcode sensitive data like API tokens in code.
|
7 |
# Consider using environment variables or other secure methods for production applications.
|
8 |
+
API_URL = "https://deployment.datasaur.ai/api/deployment/8/2723/chat/completions"
|
9 |
API_TOKEN = os.environ["DATASAUR_API_KEY"]
|
10 |
|
11 |
def magic_function(input_text):
|
|
|
17 |
"Authorization": f"Bearer {API_TOKEN}",
|
18 |
}
|
19 |
data = {
|
20 |
+
"messages": [{"role": "user", "content": f"**Input:** `{input_text}`"}]
|
21 |
}
|
22 |
|
23 |
try:
|
|
|
31 |
content = response_json.get("choices", [{}])[0].get("message", {}).get("content", "Error: Could not parse response.")
|
32 |
|
33 |
# Remove unwanted prefixes and characters from the response.
|
34 |
+
# This regex removes "Suggestion: " or "**Suggestion**: " from the beginning of the string, case-insensitively.
|
35 |
+
content = re.sub(r'^\s*(\*\*Suggestion\*\*:\s*|Suggestion:\s*)', '', content, flags=re.IGNORECASE)
|
36 |
content = content.replace("`", "")
|
37 |
|
38 |
return content.strip()
|