From bd0bbd51119de984369d389074c50cebc870846f Mon Sep 17 00:00:00 2001 From: Mahesh Kommareddi Date: Tue, 18 Jun 2024 22:54:36 -0400 Subject: [PATCH] Main changes involve working researchers and be --- __pycache__/tasks.cpython-310.pyc | Bin 12017 -> 5025 bytes __pycache__/tools.cpython-310.pyc | Bin 2978 -> 2978 bytes ecom.py | 479 ++++++++++++++++++++++++++++++ learning.py | 0 local-agent.py | 2 +- tasks.py | 271 ----------------- utils.py | 46 +++ your_database.db | Bin 0 -> 28672 bytes 8 files changed, 526 insertions(+), 272 deletions(-) create mode 100644 ecom.py create mode 100644 learning.py create mode 100644 utils.py create mode 100644 your_database.db diff --git a/__pycache__/tasks.cpython-310.pyc b/__pycache__/tasks.cpython-310.pyc index abc561a923b3d3cbe0f36288d3036bc6aa57d4c2..d328206a267abb0d018550a3f424b1377bed92f4 100644 GIT binary patch delta 885 zcmZva&rcIU6vubk?e0P;C_joKltQ8HN~r>hs0{&s5cOa*9!%Dlb=@7>wfm!)or*sW zn!v$uGn07tWH|31;KhrHCSJVE)e{L9a!rG&90z9@^{R(7hmV_h=Faayo|I|V14tTVVF8IySQNzpmsoZOJs zkx_EAdy+mBmy>cL&W@DOK(EjseSm%ej_{U5h8b3?mELyCu_!jF6*bL>TC^SMkg!`I zf%?%n>P9)Fy-w_sT)dh4g4mEc(PN~S>o}k*Zs0}@l4D-JP~)i z)uv<^vhHC7Quh%YVT;%eOibJIyvLT^oRiq6{G*$r;=eB6=E@pzDJEnLA`xI5PyrlK z>)CfbP`V60XJUWsE6Qy`d$^hsy*{k?}SIhX88yuAKQeq$UOX*1nQ33O8N8fy9s7=>yhO4VwZcyJd zw03|a+iGDlAe^{rhXEDuM8s@KdYUXjWEC(2$OFy_7%6!Enf+~+EW(j&6THS1@my_> zk`-`0()?rf<2b+srsr>-8Hw$lZYVc|vtDNY)Lpc|K2BAY35dSVeoa-oxMrGxS{QJatJJ7)j6b$rU)i3b+P<267q7Bp`pNmVdLQ)%?(Ddw3C=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7@E$xuA|t^x-O`6UZ;2y!5=VUG~2n`CtLJ%Z*)M%9kjB#a6Lxm~Kl#89ER0;Lm# zDoGq2A5PJMMcr51)w?L%k>A5ed|X0^Ns+{7n?2xGupxZGM5_Tfk$au^8A|n0@d?cs zP$DQ(9{BG)(+AfQlOi(%%_n zLpOB;|H}Vv>`m*7dEI{)d#Xkid0AoP zZ$qE8@CBqb?HG>N+4o|ki1cr~0EEye>$O4^xvFjyNLiu0-$?z}jc?1}8Y3uwO9r4) zYAsjfb&*kpdhh--3#R;|(fDVSOLE>{8{;r2WhkR*3rd*tH^vxRuzvY#qnfrnf6Oy2 nPNd#3(#jkz1INXL19pKcnd63#?UaVnEZ1BtXJkyg;S~h$}fc zm(2kvzm9DZvOFJ9P7flV%x(#kpUZw8S)Ly#X9AJ$=WqtfU*?#LEH40*vx3M^=ClCH qpW$4BEH4O@bAZZoWyyf? str: + return f"I understand. I have done what is necessary." + + +manager_agent = Agent( + role="Business Operations Manager", + goal="Coordinate and manage business processes efficiently", + backstory=( + "You are the Business Operations Manager at an e-commerce company." + "Your role is to oversee and coordinate various business processes," + "including order processing, customer support, inventory management, and logistics." + "You have access to a tool that allows you to delegate tasks to specialized agents." + "The agents you can delegate to are order_agent, customer_agent, inventory_agent, and logistics_agent" + ), + delegate=True, + tools=[ManagerTool()], + max_rpm=100, +) + +manager_task = Task( + description="Manage and coordinate the appropriate business processes based on the given input.", + expected_output="Business processes executed successfully.", + agent=manager_agent, +) + +crew = Crew( + name="eCommerce Team", + agents=[ + manager_agent, + order_agent, + customer_agent, + payment_agent, + inventory_agent, + logistics_agent + ], + tasks=[manager_task, order_task, customer_task, payment_task, inventory_task, logistics_task], + manager_llm=ChatOpenAI( + model="amazon-embeddings", + base_url="http://chat.the.mk:1337", + temperature=0.5 + ), # Mandatory for hierarchical process + process=Process.hierarchical, # Specifies the hierarchical management approach +) + +crew.kickoff() \ No newline at end of file diff --git a/learning.py b/learning.py new file mode 100644 index 0000000..e69de29 diff --git a/local-agent.py b/local-agent.py index cc174a5..74bcd5f 100644 --- a/local-agent.py +++ b/local-agent.py @@ -80,4 +80,4 @@ def blog_post(id): return "Blog entry not found", 404 if __name__ == '__main__': - socketio.run(app, debug=True, port=5001) + socketio.run(app, debug=True, host="0.0.0.0", port=5001) diff --git a/tasks.py b/tasks.py index 928f863..7d25997 100644 --- a/tasks.py +++ b/tasks.py @@ -32,282 +32,11 @@ llm = ChatOpenAI( temperature=0.1 ) -# Example usage -order_details = { - 'customer_id': 1234, - 'items': [ - {'product_id': 'ABC123', 'quantity': 2}, - {'product_id': 'XYZ456', 'quantity': 1} - ] -} - -customer_inquiry = { - 'customer_id': 5678, - 'issue': 'Order status inquiry' -} - -shipping_details = { - 'order_id': 9876, - 'shipping_address': '123 Main St, Anytown USA' -} - -order = { - 'order_details': order_details, - 'customer_inquiry': customer_inquiry, - 'shipping_details': shipping_details -} - # Load tools search_tool = SerperDevTool() scrape_tool = SeleniumScrapingTool() scrape_tool_bare = ScrapeWebsiteTool() -order_management_tool = MockTool() -order_management_tool.set_name("Order Management") -inventory_tool = MockTool() -inventory_tool.set_name("Inventory") -customer_support_tool = MockTool() -customer_support_tool.set_name("Customer Support") -order_tracking_tool = MockTool() -order_tracking_tool.set_name("Order Tracking") -supplier_management_tool = MockTool() -supplier_management_tool.set_name("Supplier Management") -shipping_tool = MockTool() -shipping_tool.set_name("Shipping") -tracking_tool = MockTool() -tracking_tool.set_name("Tracking") - -# Callback functions -def order_callback(output): - if isinstance(output, langchain_core.agents.AgentFinish): - print("Order Agent finished") - elif output and output[0]: - print(output[0]) - if output[0][0]: - print(output[0][0].log) - -def customer_callback(output): - if isinstance(output, langchain_core.agents.AgentFinish): - print("Customer Agent finished") - elif output and output[0]: - print(output[0]) - if output[0][0]: - print(output[0][0].log) - -def inventory_callback(output): - if isinstance(output, langchain_core.agents.AgentFinish): - print("Inventory Agent finished") - elif output and output[0]: - print(output[0]) - if output[0][0]: - print(output[0][0].log) - -def logistics_callback(output): - if isinstance(output, langchain_core.agents.AgentFinish): - print("Logistics Agent finished") - elif output and output[0]: - print(output[0]) - if output[0][0]: - print(output[0][0].log) - -# Define the Order Agent -order_agent = Agent( - role='Order Manager', - goal='Manage and process customer orders efficiently', - backstory=( - "You are the Order Manager at an e-commerce company." - "Your responsibilities include receiving and processing customer orders," - "updating inventory levels, and coordinating with the logistics team for shipping." - "You have access to the company's order management system and inventory database." - ), - tools=[order_management_tool, inventory_tool], - max_rpm=100, - step_callback=order_callback -) - -order_task = Task( - description=( - "Process the incoming customer order." - "Update the inventory levels accordingly." - "Coordinate with the logistics team for shipping." - ), - expected_output="Order processed successfully, inventory updated, and shipping coordinated.", - agent=order_agent -) - -# Define the Customer Agent -customer_agent = Agent( - role='Customer Service Representative', - goal='Provide excellent customer support and resolve inquiries', - backstory=( - "You are a Customer Service Representative at an e-commerce company." - "Your role is to assist customers with their questions, concerns, and complaints." - "You have access to customer order history, product information, and company policies." - ), - tools=[customer_support_tool, order_tracking_tool], - max_rpm=100, - step_callback=customer_callback -) - -customer_task = Task( - description=( - "Respond to the customer inquiry or complaint." - "Provide relevant information, track order status, or escalate the issue if necessary." - ), - expected_output="Customer inquiry resolved or escalated appropriately.", - agent=customer_agent -) - -# Define the Inventory Agent -inventory_agent = Agent( - role='Inventory Manager', - goal='Maintain accurate inventory levels and optimize stock', - backstory=( - "You are the Inventory Manager at an e-commerce company." - "Your responsibilities include monitoring inventory levels, reordering products," - "and ensuring efficient stock management." - "You have access to the company's inventory database and supplier information." - ), - tools=[inventory_tool, supplier_management_tool], - max_rpm=100, - step_callback=inventory_callback -) - -inventory_task = Task( - description=( - "Monitor inventory levels and reorder products as needed." - "Coordinate with suppliers for timely restocking." - "Optimize stock levels based on demand and sales data." - ), - expected_output="Inventory levels optimized, and restocking coordinated with suppliers.", - agent=inventory_agent -) - -# Define the Logistics Agent -logistics_agent = Agent( - role='Logistics Coordinator', - goal='Ensure efficient and timely shipping of orders', - backstory=( - "You are the Logistics Coordinator at an e-commerce company." - "Your role is to manage the shipping process, coordinate with carriers," - "and track shipments to ensure timely delivery." - "You have access to the company's order management system and carrier integrations." - ), - tools=[shipping_tool, tracking_tool], - max_rpm=100, - step_callback=logistics_callback -) - -logistics_task = Task( - description=( - "Coordinate the shipping of the processed order." - "Select the appropriate carrier and shipping method." - "Track the shipment and provide updates to the customer." - ), - expected_output="Order shipped successfully, and tracking information provided to the customer.", - agent=logistics_agent -) - -# Update the Company class -class Company: - def __init__(self): - self.order_agent = order_agent - self.customer_agent = customer_agent - self.inventory_agent = inventory_agent - self.logistics_agent = logistics_agent - - self.order_crew = Crew(agents=[order_agent], tasks=[order_task]) - self.customer_crew = Crew(agents=[customer_agent], tasks=[customer_task]) - self.inventory_crew = Crew(agents=[inventory_agent], tasks=[inventory_task]) - self.logistics_crew = Crew(agents=[logistics_agent], tasks=[logistics_task]) - - def process_order(self, order): - # Execute the order crew with the provided order details - order_result = self.order_crew.kickoff(order_task, order) - return order_result - - def handle_customer_inquiry(self, inquiry): - # Execute the customer crew with the provided inquiry details - inquiry_result = self.customer_crew.kickoff(customer_task, inquiry) - return inquiry_result - - def manage_inventory(self): - # Execute the inventory crew - inventory_result = self.inventory_crew.kickoff(inventory_task) - return inventory_result - - def ship_order(self, order): - # Execute the logistics crew with the provided order details - shipping_result = self.logistics_crew.kickoff(logistics_task, order) - return shipping_result - -company = Company() - -class ManagerTool(BaseTool): - name: str | None = "Manager Tool" - description: str | None = "A tool for the Manager Agent to coordinate other agents and handle business processes." - - # name = "Manager Tool" - # description = "A tool for the Manager Agent to coordinate other agents and handle business processes." - - def _run(self, **kwargs) -> str: - # Parse the argument to determine the requested action - if len(kwargs) > 0: - action = kwargs[0] - - if action == "process_order": - order_details = kwargs.get('order_details', order['order_details']) - result = company.process_order(order_details) - elif action == "handle_inquiry": - customer_inquiry = kwargs.get('customer_inquiry', order['customer_inquiry']) - result = company.handle_customer_inquiry(customer_inquiry) - elif action == "manage_inventory": - result = company.manage_inventory() - elif action == "ship_order": - shipping_details = kwargs.get('shipping_details', order['shipping_details']) - result = company.ship_order(shipping_details) - else: - result = f"The orders and status is: {order}" - - return str(result) - return f"I understand. I have done what is necessary." - -# Define the Manager Agent -manager_agent = Agent( - role="Business Operations Manager", - goal="Coordinate and manage business processes efficiently", - backstory=( - "You are the Business Operations Manager at an e-commerce company." - "Your role is to oversee and coordinate various business processes," - "including order processing, customer support, inventory management, and logistics." - "You have access to a tool that allows you to delegate tasks to specialized agents." - "The agents you can delegate to are order_agent, customer_agent, inventory_agent, and logistics_agent" - ), - tools=[ManagerTool()], - max_rpm=100, -) - -manager_task = Task( - description="Manage and coordinate the appropriate business processes based on the given input.", - expected_output="Business processes executed successfully.", - agent=manager_agent, -) - -project_crew = Crew( - agents=[manager_agent, order_agent, customer_agent, inventory_agent, logistics_agent], - tasks=[manager_task, order_task, customer_task, inventory_task, logistics_task], - manager_llm=ChatOpenAI( - model="amazon-embeddings", - base_url="http://chat.the.mk:1337", - temperature=0.1 - ), # Mandatory for hierarchical process - process=Process.hierarchical, # Specifies the hierarchical management approach - # memory=True, # Enable memory usage for enhanced task execution -) - -# Pass the order_details, customer_inquiry, and shipping_details as arguments to the kickoff method -project_crew.kickoff() - # Function to update task status in MongoDB def update_task_status(task_id, status, message): try: diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..d17dcc3 --- /dev/null +++ b/utils.py @@ -0,0 +1,46 @@ +import os +import sqlite3 +import requests +from dotenv import load_dotenv + +load_dotenv() + +STRIPE_SECRET_KEY = os.getenv("STRIPE_SECRET_KEY") + +# Create a new SQLite database file (if it doesn't exist) +conn = sqlite3.connect('your_database.db') +c = conn.cursor() + +# Create tables for customers, orders, and payments +c.execute('''CREATE TABLE IF NOT EXISTS customers + (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, email TEXT)''') +c.execute('''CREATE TABLE IF NOT EXISTS orders + (id INTEGER PRIMARY KEY AUTOINCREMENT, customer_id INTEGER, items TEXT, total REAL)''') +c.execute('''CREATE TABLE IF NOT EXISTS payments + (id INTEGER PRIMARY KEY AUTOINCREMENT, order_id INTEGER, amount REAL, status TEXT)''') + +def create_customer(customer_data): + name = customer_data.get("name") + email = customer_data.get("email") + c.execute("INSERT INTO customers (name, email) VALUES (?, ?)", (name, email)) + conn.commit() + return c.lastrowid + +def create_order(order_data): + customer_id = order_data.get("customer_id") + items = str(order_data.get("items")) + total = order_data.get("total") + c.execute("INSERT INTO orders (customer_id, items, total) VALUES (?, ?, ?)", (customer_id, items, total)) + conn.commit() + return c.lastrowid + +def process_payment(payment_data): + order_id = payment_data.get("order_id") + amount = payment_data.get("amount") + # Implement payment processing logic using Stripe API + status = "paid" # Replace with actual payment status + c.execute("INSERT INTO payments (order_id, amount, status) VALUES (?, ?, ?)", (order_id, amount, status)) + conn.commit() + return c.lastrowid + +# Add more utility functions as needed \ No newline at end of file diff --git a/your_database.db b/your_database.db new file mode 100644 index 0000000000000000000000000000000000000000..a7bd2ab57f8dd8ad0fd3e21aca57d3bef2c24464 GIT binary patch literal 28672 zcmeI)J#W)M00!W@IB^t`)QBa@Q00`VQLQRzp?pjYU_rmz)D=_+6%(7*D7KT>rc|hd z2Yv-oe+LsY13v&3Heg_b9dVAa+Z0$LRcfpEl;l2gab7?6a*Cae^(E6Y*fXbZX&##) zmkFh0jxj=r$e&sMj7x?$(s75^^jQ0UO_5AJSSa#$#ljaN9Y~X7Z^p#p9`B$)00Izz z00bZa0SG_<0uVS2fj|l)7Opu_R(B9+1$3K>wUv@nW{Wg zYe6BCEmbNs*cl`;?H7jaIsN^lAr56qhDQq3?K`^P_QF`f@Yqn>4`|%#tf-C6= zXm1dwtLjB2wY8L3nw+Ft(K*!X@M+tw(en+vZMef-VJP2; zHz#b(GGzYAT0m%Y7OW1o8HaI`Mrvp~$?!Sq)9myUJP*K zCV8Jv^BxU*SFe}zLfo02S