Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import requests
|
|
| 3 |
import os
|
| 4 |
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 = os.environ["DATASAUR_API_URL"]
|
|
@@ -57,6 +59,7 @@ def magic_function(input_text):
|
|
| 57 |
}
|
| 58 |
|
| 59 |
try:
|
|
|
|
| 60 |
response = requests.post(API_URL, headers=headers, json=data)
|
| 61 |
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
|
| 62 |
|
|
@@ -65,6 +68,9 @@ def magic_function(input_text):
|
|
| 65 |
# Extract content from a standard chat completion response structure.
|
| 66 |
# This may need adjustment if the API has a different format.
|
| 67 |
content = response_json.get("choices", [{}])[0].get("message", {}).get("content", "Error: Could not parse response.")
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
result = extract_json_from_text(content)
|
| 70 |
|
|
|
|
| 3 |
import os
|
| 4 |
import re
|
| 5 |
|
| 6 |
+
from run_model import run
|
| 7 |
+
|
| 8 |
# WARNING: It is not recommended to hardcode sensitive data like API tokens in code.
|
| 9 |
# Consider using environment variables or other secure methods for production applications.
|
| 10 |
API_URL = os.environ["DATASAUR_API_URL"]
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
try:
|
| 62 |
+
"""
|
| 63 |
response = requests.post(API_URL, headers=headers, json=data)
|
| 64 |
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
|
| 65 |
|
|
|
|
| 68 |
# Extract content from a standard chat completion response structure.
|
| 69 |
# This may need adjustment if the API has a different format.
|
| 70 |
content = response_json.get("choices", [{}])[0].get("message", {}).get("content", "Error: Could not parse response.")
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
content = run(input_text)
|
| 74 |
|
| 75 |
result = extract_json_from_text(content)
|
| 76 |
|