invincible-jha commited on
Commit
4e0b2a3
·
verified ·
1 Parent(s): c20b0c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -7,11 +7,12 @@ import numpy as np
7
  from sklearn.feature_extraction.text import CountVectorizer
8
  from sklearn.naive_bayes import MultinomialNB
9
  import asyncio
10
- from crewai import Agent, Task, Crew
11
  from huggingface_hub import InferenceClient
12
  import random
13
  import json
14
  import warnings
 
15
 
16
  # Suppress all deprecation warnings
17
  warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -53,9 +54,9 @@ classifier = MultinomialNB()
53
  classifier.fit(X, np.arange(len(approved_topics)))
54
 
55
  class CommunicationExpertAgent(Agent):
56
- role = "Communication Expert"
57
- goal = "To interpret and rephrase user queries with empathy and respect"
58
- backstory = """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."""
59
 
60
  async def run(self, query):
61
  sanitized_query = re.sub(r'[<>&\']', '', query)
@@ -67,9 +68,9 @@ class CommunicationExpertAgent(Agent):
67
  return rephrased_query
68
 
69
  class ResponseExpertAgent(Agent):
70
- role = "Response Expert"
71
- goal = "To provide accurate, helpful, and emotionally intelligent responses to user queries"
72
- backstory = """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."""
73
 
74
  async def run(self, rephrased_query):
75
  response = await hf_client.text_generation(rephrased_query, max_new_tokens=500, temperature=0.7)
 
7
  from sklearn.feature_extraction.text import CountVectorizer
8
  from sklearn.naive_bayes import MultinomialNB
9
  import asyncio
10
+ from crewai import Agent
11
  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
  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
  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)