Spaces:
Paused
Paused
Update app.py
Browse files354 unmodified lines35535635735835936036136236336411 unmodified lines3763773783793803813823833843853863873883891 unmodified line391392393394395396354 unmodified linestry:with WEBS(proxy=proxy) as webs:# 1. Perform the web searchsearch_results = webs.text(keywords=q, region=region,safesearch=safesearch,timelimit=timelimit, backend=backend,max_results=max_results)# 2. Extract text from top search result URLs asynchronouslyextracted_text = ""11 unmodified linesf"2. **Details:** Include any additional relevant details or explanations.\n"f"3. **Sources:** List the sources of the information with clickable links for further reading.\n\n"f"Search Results:\n{extracted_text}")# 4. Get the FastAI's response using FastAI servicetry:response = webs.chat(keywords=ai_prompt, model=model)except Exception as e:raise HTTPException(status_code=500, detail=f"Error during FastAI request: {e}")# 5. Return the resultsreturn JSONResponse(content={"response": response})1 unmodified lineexcept Exception as e:raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")@app.get("/api/website_summarizer")async def website_summarizer(url: str, proxy: Optional[str] = None):"""Summarizes the content of a given URL using a chat model."""354 unmodified lines35535635735835936036136236336436536636736811 unmodified lines3803813823833843853863873883891 unmodified line391392393394395396397354 unmodified linestry:with WEBS(proxy=proxy) as webs:# 1. Perform the web searchsearch_results = webs.text(keywords=q,region=region,safesearch=safesearch,timelimit=timelimit,backend=backend,max_results=max_results)# 2. Extract text from top search result URLs asynchronouslyextracted_text = ""11 unmodified linesf"2. **Details:** Include any additional relevant details or explanations.\n"f"3. **Sources:** List the sources of the information with clickable links for further reading.\n\n"f"Search Results:\n{extracted_text}")# 4. Get the AI's response directly using webs().chatresponse = webs.chat(keywords=ai_prompt, model=model)# 5. Return the resultsreturn JSONResponse(content={"response": response})1 unmodified lineexcept Exception as e:raise HTTPException(status_code=500, detail=f"Error during advanced search: {e}")@app.get("/api/website_summarizer")async def website_summarizer(url: str, proxy: Optional[str] = None):"""Summarizes the content of a given URL using a chat model."""
app.py+12-11