Files
LLM_Engineering_OLD/week8/agents/specialist_agent.py
Edward Donner 196b6aea82 Week 8 updates
2024-09-29 22:16:56 -04:00

30 lines
933 B
Python

import modal
from agents.agent import Agent
class SpecialistAgent(Agent):
"""
An Agent that runs our fine-tuned LLM that's running remotely on Modal
"""
name = "Specialist Agent"
color = Agent.RED
def __init__(self):
"""
Set up this Agent by creating an instance of the modal class
"""
self.log("Specialist Agent is initializing - connecting to modal")
Pricer = modal.Cls.lookup("pricer-service", "Pricer")
self.pricer = Pricer()
self.log("Specialist Agent is ready")
def price(self, description: str) -> float:
"""
Make a remote call to return the estimate of the price of this item
"""
self.log("Specialist Agent is calling remote fine-tuned model")
result = self.pricer.price.remote(description)
self.log(f"Specialist Agent completed - predicting ${result:.2f}")
return result