Spaces:
Paused
Paused
Update app.py
Browse files354 unmodified lines35535635735835936036135835936036136236336436536636736811 unmodified lines3803813823793833843813823833843853863853863873883891 unmodified line391392393394395396397354 unmodified lines try: with WEBS(proxy=proxy) as webs: # 1. Perform the web search search_results = webs.text(keywords=q, region=region, safesearch=safesearch, timelimit=timelimit, backend=backend, max_results=max_results) search_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 asynchronously extracted_text = ""11 unmodified lines f"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 service try: response = webs.chat(keywords=ai_prompt, model=model) except Exception as e: raise HTTPException(status_code=500, detail=f"Error during FastAI request: {e}") # 4. Get the AI's response directly using webs().chat response = webs.chat(keywords=ai_prompt, model=model)
# 5. Return the results return JSONResponse(content={"response": response})1 unmodified line except 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