File size: 1,214 Bytes
03f1c64
2fbdd0c
03f1c64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2fbdd0c
03f1c64
 
 
 
 
 
 
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
31
32
33
from modules.base.chain import IChain
from modules.settings.user_settings import UserSettings
from typing import Dict , Any, Callable
import os

class RouterChain(IChain):
    """
    RouterChain Class

    Design:
    The RouterChain class extends the IChain interface and provides an implementation for the run 
    method. It also introduces a new method, add_chain, for adding destination chains. The class adheres 
    to the Open/Closed Principle (OCP) as it can be extended without modifying its behavior.

    Intended Implementation:
    The RouterChain class serves as a router that selects the appropriate DestinationChain based on 
    the input. The selection logic should be implemented in the run method. The add_chain method 
    allows new DestinationChain instances to be added to the RouterChain.
    """
    template : str 
    destination_chains: Dict[int, IChain]
    display: Callable = print
    question: str
    usage: str
    llm: Any
    api_key: str 

    def add_chain(self, domain: str, chain: IChain) -> None:
        self.destination_chains[domain] = chain

    def run(self, input: str) -> str:
        # Implement the logic to select the appropriate DestinationChain
        pass