Coverage for lib/brick_layers/lib_abstract_generic_layer.py: 76%

17 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2026-01-26 23:58 +0100

1from abc import abstractmethod 

2 

3 

4 

5class LayerGeneric(): 

6 def __init__(self, conf : dict): 

7 self.conf = conf.copy() 

8 # VR TODO : question pour la migration : passer des modeles specifiques en modele generiques à stocker, sans dout einutile ! A VIRER le 14-7-23 

9 self.model = conf["model"] if "model" in conf else "" 

10 print(" conf should contain credential ") 

11 

12# def toJSON(self): 

13# return self.conf 

14 

15 

16class LayerPrompt(LayerGeneric): 

17 def __init__(self, conf): 

18 super().__init__(conf) 

19 print("NEED PRICING ") 

20 

21# def toJSON(self): 

22# return self.conf 

23 

24 def get_price_per_token(self): 

25 from auth.lib_cost import CostEstimation as CE 

26 ce = CE() 

27 return ce.get_cost_per_model(self.model) 

28 

29 @abstractmethod 

30 def prompt(self, request_used, gpt_model, verbose = False, images = None): 

31 pass 

32 

33 

34def test_load_dynamic() : # pragma no cover test 

35 from lib.brick_layers.lib_abstract_generic_layer import LayerPrompt 

36 clazz_layer = globals()["LayerPrompt"] 

37 inst = clazz_layer({}) 

38 print(" type : " + str(type(inst))) 

39 print("Et voilà !") 

40 

41