Files
LLM_Engineering_OLD/week8/community_contributions/agents/ft_price_agent.py
2025-06-05 16:42:02 +02:00

29 lines
1.0 KiB
Python

import modal
from agents.base_agent import Agent
class FTPriceAgent(Agent):
"""
An Agent that runs the fine-tuned LLM that's running remotely on Modal
"""
name = "FTPrice Agent"
color = Agent.RED
def __init__(self):
"""
Set up this Agent by creating an instance of the modal class
"""
self.log("FTPrice Agent is initializing - connecting to modal")
Pricer = modal.Cls.from_name("llm-ft-pricer", "Pricer") # 1st API call: to fetch Pricer (remote class)
self.pricer = Pricer()
self.log("FTPrice 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("FTPrice Agent is calling remote fine-tuned model")
result = self.pricer.price.remote(description) # 2nd API call: to run the price method in the remote Pricer class
self.log(f"FTPrice Agent completed - predicting ${result:.2f}")
return result