File size: 962 Bytes
540f246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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