pusher / pusher-http-python

Pusher Channels HTTP API library for Python
https://pusher.com/docs/server_api_guide
MIT License
376 stars 113 forks source link

streaming response time #215

Closed Ajaypawar02 closed 1 year ago

Ajaypawar02 commented 1 year ago

class MyCallbackHandler(BaseCallbackHandler): def init(self,new_payload : Dict): self.user_id = new_payload["user_id"] self.session_id = new_payload["session_id"] self.message_id = new_payload["message_id"] self.status = "processing" self.session_id_channel = f"{self.session_id}_channel" self.count = 0 self.temp_count = 0 self.response = "" self.flag = True self.threshold_no = int(os.getenv("CHUNK_SIZE")) self.text = ""

def on_llm_new_token(self, token, **kwargs) -> None:

if token != "":
    # logging.info(f"LLM token: {token}")
    pusher_client.trigger(self.session_id_channel ,'query_answer_stream', {
                "user_id": self.user_id,
                "session_id": self.session_id,
                "message_id": self.message_id,
                "answer": self.response,
                "status": self.status
                },
                )

Any suggestion to reduce response time

benw-pusher commented 1 year ago

Could you share what response time you are currently encountering? Is this the response for the pusher_client.trigger call or the time for the client to receive the triggered event?

Ajaypawar02 commented 1 year ago

issue has been resolved. Thank You