igbot-base 0.0.34__py3-none-any.whl → 0.0.36__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- igbot_base/agent.py +11 -0
- igbot_base/llm.py +18 -0
- {igbot_base-0.0.34.dist-info → igbot_base-0.0.36.dist-info}/METADATA +1 -1
- {igbot_base-0.0.34.dist-info → igbot_base-0.0.36.dist-info}/RECORD +6 -6
- {igbot_base-0.0.34.dist-info → igbot_base-0.0.36.dist-info}/WHEEL +1 -1
- {igbot_base-0.0.34.dist-info → igbot_base-0.0.36.dist-info}/top_level.txt +0 -0
igbot_base/agent.py
CHANGED
@@ -22,10 +22,21 @@ class Agent(ABC):
|
|
22
22
|
logger.exception("Exception occurred at %s for query %s: %s", self.describe(), query, e)
|
23
23
|
return self.__ex_handler.handle(e)
|
24
24
|
|
25
|
+
def add_llm_message(self, llm_message, memory: LlmMemory) -> AgentResponse:
|
26
|
+
try:
|
27
|
+
return self._add_llm_message(llm_message, memory)
|
28
|
+
except Exception as e:
|
29
|
+
logger.exception("Exception occurred at %s for llm_message %s: %s", self.describe(), llm_message, e)
|
30
|
+
return self.__ex_handler.handle(e)
|
31
|
+
|
25
32
|
@abstractmethod
|
26
33
|
def _invoke(self, query, memory: LlmMemory) -> AgentResponse:
|
27
34
|
pass
|
28
35
|
|
36
|
+
@abstractmethod
|
37
|
+
def _add_llm_message(self, llm_message, memory: LlmMemory) -> AgentResponse:
|
38
|
+
pass
|
39
|
+
|
29
40
|
@abstractmethod
|
30
41
|
def describe(self):
|
31
42
|
pass
|
igbot_base/llm.py
CHANGED
@@ -34,6 +34,10 @@ class Llm(ABC):
|
|
34
34
|
def _call(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
35
35
|
pass
|
36
36
|
|
37
|
+
@abstractmethod
|
38
|
+
def _add_llm_message(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
39
|
+
pass
|
40
|
+
|
37
41
|
def _revert_memory(self, history: LlmMemory):
|
38
42
|
history.revert_to_snapshot()
|
39
43
|
|
@@ -51,6 +55,20 @@ class Llm(ABC):
|
|
51
55
|
self._exception_handler.handle(e)
|
52
56
|
raise BaseLlmException(f"Exception occurred while calling llm api", self, e)
|
53
57
|
|
58
|
+
def add_llm_message(self, llm_message: str, history: LlmMemory, params: dict) -> str:
|
59
|
+
logger.debug("Call to %s with llm message: %s", self.__str__(), llm_message)
|
60
|
+
history.set_snapshot()
|
61
|
+
try:
|
62
|
+
response = self._add_llm_message(llm_message, history, params)
|
63
|
+
logger.debug("LLM %s %s responded: %s", self._name, self._model.value.get_name(), response)
|
64
|
+
return response
|
65
|
+
except Exception as e:
|
66
|
+
logger.error("Error occurred in LLM %s, Model %s at calling the API: %s",
|
67
|
+
self._name, self._model.value.get_name(), e)
|
68
|
+
self._revert_memory(history)
|
69
|
+
self._exception_handler.handle(e)
|
70
|
+
raise BaseLlmException(f"Exception occurred while calling llm api", self, e)
|
71
|
+
|
54
72
|
def get_additional_llm_args(self):
|
55
73
|
args = {}
|
56
74
|
if self._temperature is not None:
|
@@ -1,9 +1,9 @@
|
|
1
1
|
igbot_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
igbot_base/agent.py,sha256=
|
2
|
+
igbot_base/agent.py,sha256=yrZ4XSrR50g0xNpkUCnkgxljA8lOZnp8XqRMtNAss1M,1483
|
3
3
|
igbot_base/agent_response.py,sha256=ujLaFkIw9he-X1YFIICTJvq_4pmzTvTF4txEfeZtKSA,1041
|
4
4
|
igbot_base/base_exception.py,sha256=uRZXwYdsER2y_Rlah1TaSXwR6Kb9t2lNyngar0p5YFk,2146
|
5
5
|
igbot_base/exception_handler.py,sha256=Er5LbNt2ga2-e0GSzkJw66E-NS1dN_2msTRyyac1qX8,536
|
6
|
-
igbot_base/llm.py,sha256=
|
6
|
+
igbot_base/llm.py,sha256=dBZo7utmmy1BJM34SMujP8iyidJnU6c1iAjLNhwYz2E,3071
|
7
7
|
igbot_base/llmmemory.py,sha256=eMjkjFMKgyAqpM7-q3xzQAP6gDeNfkpPkb9MK1hN8iY,1157
|
8
8
|
igbot_base/logging_adapter.py,sha256=kMuAaQPCba2luk0-WPxAbPNJaBL1yZsaff35ltKWgww,256
|
9
9
|
igbot_base/models.py,sha256=kbscj0jTNkJu9cglEQILjdOWJuwD3pZ0Q1rxz2q7tg8,1370
|
@@ -15,7 +15,7 @@ igbot_base/retriever.py,sha256=YHBHxiuPttsIAtjwwIz0fa9q2uFtsg0WoMRCorCt1PM,635
|
|
15
15
|
igbot_base/tokenizer.py,sha256=WSR0GFc1eoMmyL58RAxtpb2iWCrqu9vQ2Ui-hqs4plw,1032
|
16
16
|
igbot_base/tool.py,sha256=ghjuU3cK_VElHGStUl3IYf9dlRDOGM_aQucUQNUH3mU,431
|
17
17
|
igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
|
18
|
-
igbot_base-0.0.
|
19
|
-
igbot_base-0.0.
|
20
|
-
igbot_base-0.0.
|
21
|
-
igbot_base-0.0.
|
18
|
+
igbot_base-0.0.36.dist-info/METADATA,sha256=NC8x8EdzFLTvGUqSbv3L_odPpTIZOfl7GwuwjCXmfVQ,235
|
19
|
+
igbot_base-0.0.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
20
|
+
igbot_base-0.0.36.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
|
21
|
+
igbot_base-0.0.36.dist-info/RECORD,,
|
File without changes
|