Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -339,8 +339,8 @@ def web_search_and_extract_threading(
|
|
| 339 |
@app.get("/api/adv_web_search")
|
| 340 |
async def adv_web_search(
|
| 341 |
q: str,
|
| 342 |
-
model: str = "
|
| 343 |
-
max_results: int =
|
| 344 |
timelimit: Optional[str] = None,
|
| 345 |
safesearch: str = "moderate",
|
| 346 |
region: str = "wt-wt",
|
|
@@ -381,7 +381,7 @@ async def adv_web_search(
|
|
| 381 |
|
| 382 |
# 4. Get the FastAI's response using FastAI service
|
| 383 |
try:
|
| 384 |
-
response =
|
| 385 |
except Exception as e:
|
| 386 |
raise HTTPException(status_code=500, detail=f"Error during FastAI request: {e}")
|
| 387 |
|
|
@@ -554,24 +554,24 @@ if __name__ == "__main__":
|
|
| 554 |
import uvicorn
|
| 555 |
uvicorn.run(app, host="0.0.0.0", port=8083)
|
| 556 |
|
| 557 |
-
def main():
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
|
| 562 |
-
|
| 563 |
-
|
| 564 |
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
|
| 573 |
-
|
| 574 |
-
|
| 575 |
|
| 576 |
-
if __name__ == "__main__":
|
| 577 |
-
|
|
|
|
| 339 |
@app.get("/api/adv_web_search")
|
| 340 |
async def adv_web_search(
|
| 341 |
q: str,
|
| 342 |
+
model: str = "gpt-4o-mini",
|
| 343 |
+
max_results: int = 5,
|
| 344 |
timelimit: Optional[str] = None,
|
| 345 |
safesearch: str = "moderate",
|
| 346 |
region: str = "wt-wt",
|
|
|
|
| 381 |
|
| 382 |
# 4. Get the FastAI's response using FastAI service
|
| 383 |
try:
|
| 384 |
+
response = webs.chat(keywords=ai_prompt, model=model)
|
| 385 |
except Exception as e:
|
| 386 |
raise HTTPException(status_code=500, detail=f"Error during FastAI request: {e}")
|
| 387 |
|
|
|
|
| 554 |
import uvicorn
|
| 555 |
uvicorn.run(app, host="0.0.0.0", port=8083)
|
| 556 |
|
| 557 |
+
# def main():
|
| 558 |
+
# # Retrieve the space ID and token from environment variables
|
| 559 |
+
# space_id = os.getenv("SPACE_ID")
|
| 560 |
+
# token = os.getenv("HF_TOKEN")
|
| 561 |
|
| 562 |
+
# # Initialize the HfApi with the retrieved token
|
| 563 |
+
# api = HfApi(token=token)
|
| 564 |
|
| 565 |
+
# while True:
|
| 566 |
+
# try:
|
| 567 |
+
# # Restart the space
|
| 568 |
+
# api.restart_space(space_id, factory_reboot=False)
|
| 569 |
+
# print(f"Successfully restarted the space: {space_id}")
|
| 570 |
+
# except Exception as e:
|
| 571 |
+
# print(f"Error restarting the space: {e}")
|
| 572 |
|
| 573 |
+
# # Wait for 10 minutes before restarting again
|
| 574 |
+
# time.sleep(600) # Sleep for 600 seconds (10 minutes)
|
| 575 |
|
| 576 |
+
# if __name__ == "__main__":
|
| 577 |
+
# main()
|