Spaces:
Running
Running
Update app4.py
Browse files
app4.py
CHANGED
|
@@ -194,9 +194,10 @@ def update_news_hourly():
|
|
| 194 |
# Async Together API
|
| 195 |
# -------------------
|
| 196 |
async def async_together_chat(messages):
|
|
|
|
| 197 |
url = "https://api.together.xyz/v1/chat/completions"
|
| 198 |
headers = {
|
| 199 |
-
"Authorization": f"Bearer {
|
| 200 |
"Content-Type": "application/json",
|
| 201 |
}
|
| 202 |
payload = {
|
|
@@ -209,6 +210,7 @@ async def async_together_chat(messages):
|
|
| 209 |
result = await resp.json()
|
| 210 |
return result["choices"][0]["message"]["content"]
|
| 211 |
|
|
|
|
| 212 |
# -------------------
|
| 213 |
# Query function
|
| 214 |
# -------------------
|
|
|
|
| 194 |
# Async Together API
|
| 195 |
# -------------------
|
| 196 |
async def async_together_chat(messages):
|
| 197 |
+
api_key = st.secrets["TOGETHER_API_KEY"] # Access here, not globally
|
| 198 |
url = "https://api.together.xyz/v1/chat/completions"
|
| 199 |
headers = {
|
| 200 |
+
"Authorization": f"Bearer {api_key}",
|
| 201 |
"Content-Type": "application/json",
|
| 202 |
}
|
| 203 |
payload = {
|
|
|
|
| 210 |
result = await resp.json()
|
| 211 |
return result["choices"][0]["message"]["content"]
|
| 212 |
|
| 213 |
+
|
| 214 |
# -------------------
|
| 215 |
# Query function
|
| 216 |
# -------------------
|