worth-brain / agents /specialist_agent.py
MightyOctopus's picture
add advanced price estimate logic in Ensemble class
08e76a1
# fetch the pricer-service from modal and make an instance of it
# Infer to price
import modal
from agents.agents import Agent
class SpecialistAgent(Agent):
"""
An Agent that runs the 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.from_name("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 a given item description
"""
self.log("Specialist Agent is calling remote fine-tuned model... If this is a cold start, this might take some time to wake it up")
result = self.pricer.price.remote(description)
self.log(f"Specialist Agent completed - predicting ${result:.2f}")
return result