6
6
from ..models import OpenAI , Gemini , Ollama , AzureOpenAI
7
7
from ..helpers import models_tokens
8
8
9
+
9
10
class AbstractGraph (ABC ):
10
11
"""
11
12
Abstract class representing a generic graph-based tool.
@@ -19,7 +20,8 @@ def __init__(self, prompt: str, config: dict, source: Optional[str] = None):
19
20
self .source = source
20
21
self .config = config
21
22
self .llm_model = self ._create_llm (config ["llm" ])
22
- self .embedder_model = None if "embeddings" not in config else self ._create_llm (config ["embeddings" ])
23
+ self .embedder_model = None if "embeddings" not in config else self ._create_llm (
24
+ config ["embeddings" ])
23
25
self .graph = self ._create_graph ()
24
26
25
27
def _create_llm (self , llm_config : dict ):
@@ -39,7 +41,7 @@ def _create_llm(self, llm_config: dict):
39
41
except KeyError :
40
42
raise ValueError ("Model not supported" )
41
43
return OpenAI (llm_params )
42
-
44
+
43
45
elif "azure" in llm_params ["model" ]:
44
46
# take the model after the last dash
45
47
llm_params ["model" ] = llm_params ["model" ].split ("/" )[- 1 ]
@@ -48,23 +50,30 @@ def _create_llm(self, llm_config: dict):
48
50
except KeyError :
49
51
raise ValueError ("Model not supported" )
50
52
return AzureOpenAI (llm_params )
51
-
53
+
52
54
elif "gemini" in llm_params ["model" ]:
53
55
try :
54
56
self .model_token = models_tokens ["gemini" ][llm_params ["model" ]]
55
57
except KeyError :
56
58
raise ValueError ("Model not supported" )
57
59
return Gemini (llm_params )
58
-
60
+
59
61
elif "ollama" in llm_params ["model" ]:
60
- # take the model after the last dash
62
+ """
63
+ Avaiable models:
64
+ - llama2
65
+ - mistral
66
+ - codellama
67
+ - dolphin-mixtral
68
+ - mistral-openorca
69
+ """
61
70
llm_params ["model" ] = llm_params ["model" ].split ("/" )[- 1 ]
62
71
try :
63
72
self .model_token = models_tokens ["ollama" ][llm_params ["model" ]]
64
73
except KeyError :
65
74
raise ValueError ("Model not supported" )
66
75
return Ollama (llm_params )
67
-
76
+
68
77
else :
69
78
raise ValueError ("Model not supported" )
70
79
0 commit comments