invincible-jha commited on
Commit
6bbc3b0
·
verified ·
1 Parent(s): 4ec7452

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -75,8 +75,13 @@ class ResponseExpertAgent(Agent):
75
  "You are an expert in Zerodha's services and policies, with a keen ability to provide comprehensive and empathetic responses. Your role is to ensure that all user queries are addressed accurately while maintaining a respectful and supportive tone."
76
 
77
  async def run(self, rephrased_query):
78
- response = await hf_client.text_generation(rephrased_query, max_new_tokens=500, temperature=0.7)
79
- return response['generated_text']
 
 
 
 
 
80
 
81
  class PostprocessingAgent(Agent):
82
  role: Literal["Postprocessing Expert"] = "Postprocessing Expert"
 
75
  "You are an expert in Zerodha's services and policies, with a keen ability to provide comprehensive and empathetic responses. Your role is to ensure that all user queries are addressed accurately while maintaining a respectful and supportive tone."
76
 
77
  async def run(self, rephrased_query):
78
+ try:
79
+ logger.info(f"Sending query for generation: {rephrased_query}")
80
+ response = await hf_client.text_generation(rephrased_query, max_new_tokens=500, temperature=0.7)
81
+ return response['generated_text']
82
+ except Exception as e:
83
+ logger.error(f"Failed to generate text due to: {str(e)}")
84
+ return "Error in generating response. Please try again."
85
 
86
  class PostprocessingAgent(Agent):
87
  role: Literal["Postprocessing Expert"] = "Postprocessing Expert"