Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,13 +27,13 @@ User question: "{prompt}"
|
|
| 27 |
Write a valid SQL query using the 'df' table. Return only the SQL code.
|
| 28 |
"""
|
| 29 |
|
| 30 |
-
url = "https://api.together.xyz/
|
| 31 |
headers = {
|
| 32 |
"Authorization": f"Bearer {TOGETHER_API_KEY}",
|
| 33 |
"Content-Type": "application/json"
|
| 34 |
}
|
| 35 |
payload = {
|
| 36 |
-
"model": "meta-llama/Llama-3-8B-Instruct"
|
| 37 |
"prompt": full_prompt,
|
| 38 |
"max_tokens": 300,
|
| 39 |
"temperature": 0.7,
|
|
@@ -42,7 +42,7 @@ Write a valid SQL query using the 'df' table. Return only the SQL code.
|
|
| 42 |
response = requests.post(url, headers=headers, json=payload)
|
| 43 |
response.raise_for_status()
|
| 44 |
result = response.json()
|
| 45 |
-
return result['
|
| 46 |
|
| 47 |
# 🧽 Clean SQL for DuckDB compatibility
|
| 48 |
def clean_sql_for_duckdb(sql, df_columns):
|
|
|
|
| 27 |
Write a valid SQL query using the 'df' table. Return only the SQL code.
|
| 28 |
"""
|
| 29 |
|
| 30 |
+
url = "https://api.together.xyz/v1/completions"
|
| 31 |
headers = {
|
| 32 |
"Authorization": f"Bearer {TOGETHER_API_KEY}",
|
| 33 |
"Content-Type": "application/json"
|
| 34 |
}
|
| 35 |
payload = {
|
| 36 |
+
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1", # You can use "meta-llama/Llama-3-8B-Instruct" too
|
| 37 |
"prompt": full_prompt,
|
| 38 |
"max_tokens": 300,
|
| 39 |
"temperature": 0.7,
|
|
|
|
| 42 |
response = requests.post(url, headers=headers, json=payload)
|
| 43 |
response.raise_for_status()
|
| 44 |
result = response.json()
|
| 45 |
+
return result['choices'][0]['text'].strip("```sql").strip("```").strip()
|
| 46 |
|
| 47 |
# 🧽 Clean SQL for DuckDB compatibility
|
| 48 |
def clean_sql_for_duckdb(sql, df_columns):
|