invincible-jha commited on
Commit
13c4d18
·
verified ·
1 Parent(s): 9ea6107

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -12,7 +12,7 @@ from huggingface_hub import InferenceClient
12
  import random
13
  import json
14
  import warnings
15
- from pydantic import Field
16
 
17
  # Suppress all deprecation warnings
18
  warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -54,9 +54,10 @@ classifier = MultinomialNB()
54
  classifier.fit(X, np.arange(len(approved_topics)))
55
 
56
  class CommunicationExpertAgent(Agent):
57
- role: str = Field(default="Communication Expert", const=True)
58
- goal: str = Field(default="To interpret and rephrase user queries with empathy and respect", const=True)
59
- backstory: str = Field(default="""You are an expert in communication, specializing in understanding and rephrasing queries to ensure they are interpreted in the most positive and constructive light. Your role is crucial in setting the tone for respectful and empathetic interactions.""", const=True)
 
60
 
61
  async def run(self, query):
62
  sanitized_query = re.sub(r'[<>&\']', '', query)
@@ -68,9 +69,10 @@ class CommunicationExpertAgent(Agent):
68
  return rephrased_query
69
 
70
  class ResponseExpertAgent(Agent):
71
- role: str = Field(default="Response Expert", const=True)
72
- goal: str = Field(default="To provide accurate, helpful, and emotionally intelligent responses to user queries", const=True)
73
- backstory: str = Field(default="""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.""", const=True)
 
74
 
75
  async def run(self, rephrased_query):
76
  response = await hf_client.text_generation(rephrased_query, max_new_tokens=500, temperature=0.7)
 
12
  import random
13
  import json
14
  import warnings
15
+ from typing import Literal
16
 
17
  # Suppress all deprecation warnings
18
  warnings.filterwarnings("ignore", category=DeprecationWarning)
 
54
  classifier.fit(X, np.arange(len(approved_topics)))
55
 
56
  class CommunicationExpertAgent(Agent):
57
+ role: Literal["Communication Expert"] = "Communication Expert"
58
+ goal: Literal["To interpret and rephrase user queries with empathy and respect"] = "To interpret and rephrase user queries with empathy and respect"
59
+ backstory: Literal["You are an expert in communication, specializing in understanding and rephrasing queries to ensure they are interpreted in the most positive and constructive light. Your role is crucial in setting the tone for respectful and empathetic interactions."] = \
60
+ "You are an expert in communication, specializing in understanding and rephrasing queries to ensure they are interpreted in the most positive and constructive light. Your role is crucial in setting the tone for respectful and empathetic interactions."
61
 
62
  async def run(self, query):
63
  sanitized_query = re.sub(r'[<>&\']', '', query)
 
69
  return rephrased_query
70
 
71
  class ResponseExpertAgent(Agent):
72
+ role: Literal["Response Expert"] = "Response Expert"
73
+ goal: Literal["To provide accurate, helpful, and emotionally intelligent responses to user queries"] = "To provide accurate, helpful, and emotionally intelligent responses to user queries"
74
+ backstory: Literal["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."] = \
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)