Spaces:
				
			
			
	
			
			
		Paused
		
	
	
	
			
			
	
	
	
	
		
		
		Paused
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 1 | 
         
             
            from fastapi import FastAPI, HTTPException, Query
         
     | 
| 2 | 
         
             
            from fastapi.responses import JSONResponse
         
     | 
| 3 | 
         
            -
            from webscout import WEBS, transcriber, LLM, fastai
         
     | 
| 4 | 
         
             
            from typing import Optional, List, Dict, Union
         
     | 
| 5 | 
         
             
            from fastapi.encoders import jsonable_encoder
         
     | 
| 6 | 
         
             
            from bs4 import BeautifulSoup
         
     | 
| 
         @@ -161,7 +161,13 @@ async def fast_ai(user: str, model: str = "llama3-70b", system: str = "Answer as 
     | 
|
| 161 | 
         
             
                except Exception as e:
         
     | 
| 162 | 
         
             
                    raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
         
     | 
| 163 | 
         | 
| 164 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 165 | 
         | 
| 166 | 
         
             
            @app.get("/api/answers")
         
     | 
| 167 | 
         
             
            async def answers(q: str, proxy: Optional[str] = None):
         
     | 
| 
         | 
|
| 1 | 
         
             
            from fastapi import FastAPI, HTTPException, Query
         
     | 
| 2 | 
         
             
            from fastapi.responses import JSONResponse
         
     | 
| 3 | 
         
            +
            from webscout import WEBS, transcriber, LLM, fastai, fastai_stream
         
     | 
| 4 | 
         
             
            from typing import Optional, List, Dict, Union
         
     | 
| 5 | 
         
             
            from fastapi.encoders import jsonable_encoder
         
     | 
| 6 | 
         
             
            from bs4 import BeautifulSoup
         
     | 
| 
         | 
|
| 161 | 
         
             
                except Exception as e:
         
     | 
| 162 | 
         
             
                    raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
         
     | 
| 163 | 
         | 
| 164 | 
         
            +
            @app.get("/api/streaming-fastAI")
         
     | 
| 165 | 
         
            +
            async def fast_ai(user: str, model: str = "llama3-8b", system: str = "Answer as concisely as possible."):
         
     | 
| 166 | 
         
            +
                """Get a streaming response from the Snova AI service."""
         
     | 
| 167 | 
         
            +
                try:
         
     | 
| 168 | 
         
            +
                    return StreamingResponse(fastai_stream(user, model, system), media_type="text/event-stream")
         
     | 
| 169 | 
         
            +
                except Exception as e:
         
     | 
| 170 | 
         
            +
                    raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
         
     | 
| 171 | 
         | 
| 172 | 
         
             
            @app.get("/api/answers")
         
     | 
| 173 | 
         
             
            async def answers(q: str, proxy: Optional[str] = None):
         
     |