Bug Summary:
I use sonar-deep-research by using this pipeline to show citations and got this issue
Reproduction Details
Steps to Reproduce:
Using this pipelines:
frompydanticimportBaseModel,FieldfromtypingimportOptional,Union,Generator,Iteratorfromopen_webui.utils.miscimportget_last_user_messagefromopen_webui.utils.miscimportpop_system_messageimportosimportjsonimporttimeimportrequestsclassPipe:classValves(BaseModel):NAME_PREFIX:str=Field(default="Perplexity/",description="The prefix applied before the model names.",)PERPLEXITY_API_BASE_URL:str=Field(default="https://api.perplexity.ai",description="The base URL for Perplexity API endpoints.",)PERPLEXITY_API_KEY:str=Field(default="",description="Required API key to access Perplexity services.",)def__init__(self):self.type="manifold"self.valves=self.Valves()defpipes(self):return[{"id":"sonar-reasoning-pro","name":f"Sonar Reasoning Pro 128k 8k output",},{"id":"sonar-reasoning","name":f"Sonar Reasoning 128k 8k output",},{"id":"sonar-pro","name":f"Sonar Pro 200k",},{"id":"sonar","name":f"Sonar 128k",},{"id":"r1-1776","name":f"Deepseek-R1 128k",},{"id":"sonar-deep-research","name":f"Sonar Deep Research 60k",},]defpipe(self,body:dict,__user__:dict)->Union[str,Generator,Iterator]:print(f"pipe:{__name__}")ifnotself.valves.PERPLEXITY_API_KEY:raiseException("PERPLEXITY_API_KEY not provided in the valves.")headers={"Authorization":f"Bearer {self.valves.PERPLEXITY_API_KEY}","Content-Type":"application/json","accept":"application/json",}system_message,messages=pop_system_message(body.get("messages",[]))system_prompt="You are a helpful assistant."ifsystem_messageisnotNone:system_prompt=system_message["content"]model_id=body["model"]ifmodel_id.startswith(self.valves.NAME_PREFIX):model_id=model_id[len(self.valves.NAME_PREFIX):]ifmodel_id.startswith("perplexity."):model_id=model_id[len("perplexity."):]payload={"model":model_id,"messages":[{"role":"system","content":system_prompt},*messages],"stream":body.get("stream",True),"return_citations":True,"return_images":True,}url=f"{self.valves.PERPLEXITY_API_BASE_URL}/chat/completions"try:ifbody.get("stream",False):returnself.stream_response(url,headers,payload)else:returnself.non_stream_response(url,headers,payload)exceptrequests.exceptions.RequestExceptionase:print(f"Request failed: {e}")returnf"Error: Request failed: {e}"exceptExceptionase:print(f"Error in pipe method: {e}")returnf"Error: {e}"defstream_response(self,url,headers,payload):try:withrequests.post(url,headers=headers,json=payload,stream=True,timeout=(3.05,300))asresponse:ifresponse.status_code!=200:raiseException(f"HTTP Error {response.status_code}: {response.text}")data=Noneforlineinresponse.iter_lines():ifline:line=line.decode("utf-8")ifline.startswith("data: "):try:data=json.loads(line[6:])yielddata["choices"][0]["delta"]["content"]time.sleep(0.01)# Delay to avoid overwhelming the clientexceptjson.JSONDecodeError:print(f"Failed to parse JSON: {line}")exceptKeyErrorase:print(f"Unexpected data structure: {e}")print(f"Full data: {data}")citations=data.get("citations",[])citations_string="\n".join([f"[{i+1}] {url}"fori,urlinenumerate(citations)])yield"\n\n"+citations_stringexceptrequests.exceptions.RequestExceptionase:print(f"Request failed: {e}")yieldf"Error: Request failed: {e}"exceptExceptionase:print(f"General error in stream_response method: {e}")yieldf"Error: {e}"defnon_stream_response(self,url,headers,payload):try:response=requests.post(url,headers=headers,json=payload,timeout=(3.05,300))ifresponse.status_code!=200:raiseException(f"HTTP Error {response.status_code}: {response.text}")res=response.json()citations=res.get("citations",[])citations_string="\n".join([f"[{i+1}] {url}"fori,urlinenumerate(citations)])returnres["choices"][0]["message"]["content"]+"\n\n"+citations_stringexceptrequests.exceptions.RequestExceptionase:print(f"Failed non-stream request: {e}")returnf"Error: {e}"
Choose Sonar Deep Research
Enter the prompt that take times to response
Come to incognito mode and try to connect to website
May I ask you if you have any script that uses async ? I have tried many times but none of it worked
<!-- gh-comment-id:2699784222 -->
@KenKout commented on GitHub (Mar 5, 2025):
May I ask you if you have any script that uses async ? I have tried many times but none of it worked
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @KenKout on GitHub (Mar 4, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/11166
Bug Report
Installation Method
Docker Compose
Environment
Description
Bug Summary:
I use sonar-deep-research by using this pipeline to show citations and got this issue
Reproduction Details
Steps to Reproduce:
Logs and Screenshots
Screenshots/Screen Recordings (if applicable):
https://github.com/user-attachments/assets/94079e1e-0e6d-4c3a-a2f4-c3779e28727d
Potential issue
https://stackoverflow.com/questions/71516140/fastapi-runs-api-calls-in-serial-instead-of-parallel-fashion
@tjbck commented on GitHub (Mar 4, 2025):
asyncshould be used.@KenKout commented on GitHub (Mar 5, 2025):
May I ask you if you have any script that uses async ? I have tried many times but none of it worked