Spaces:
Paused
Paused
Update app.py
Browse files338 unmodified lines33934034134234334234334434534634 unmodified lines381382383384384385386387166 unmodified lines554555556557558559560557558559560561562563562563564565566567568569570571565566567568569570571572573574573574575576577576577338 unmodified lines@app.get("/api/adv_web_search")async def adv_web_search( q: str, model: str = "llama3-8b", max_results: int = 3, model: str = "gpt-4o-mini", max_results: int = 5, timelimit: Optional[str] = None, safesearch: str = "moderate", region: str = "wt-wt",34 unmodified lines
# 4. Get the FastAI's response using FastAI service try: response = await asyncio.to_thread(fastai, ai_prompt, model=model, system=system_prompt) response = webs.chat(keywords=ai_prompt, model=model) except Exception as e: raise HTTPException(status_code=500, detail=f"Error during FastAI request: {e}")
166 unmodified lines import uvicorn uvicorn.run(app, host="0.0.0.0", port=8083)
def main(): # Retrieve the space ID and token from environment variables space_id = os.getenv("SPACE_ID") token = os.getenv("HF_TOKEN")# def main():# # Retrieve the space ID and token from environment variables# space_id = os.getenv("SPACE_ID")# token = os.getenv("HF_TOKEN")
# Initialize the HfApi with the retrieved token api = HfApi(token=token)# # Initialize the HfApi with the retrieved token# api = HfApi(token=token)
while True: try: # Restart the space api.restart_space(space_id, factory_reboot=False) print(f"Successfully restarted the space: {space_id}") except Exception as e: print(f"Error restarting the space: {e}")# while True:# try:# # Restart the space# api.restart_space(space_id, factory_reboot=False)# print(f"Successfully restarted the space: {space_id}")# except Exception as e:# print(f"Error restarting the space: {e}")
# Wait for 10 minutes before restarting again time.sleep(600) # Sleep for 600 seconds (10 minutes)# # Wait for 10 minutes before restarting again# time.sleep(600) # Sleep for 600 seconds (10 minutes)
if __name__ == "__main__": main()# if __name__ == "__main__":# main()app.py+20-20