igbot-base 0.0.11__py3-none-any.whl → 0.0.12__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 +18 -2
- igbot_base/exception_handler.py +8 -0
- igbot_base/llm.py +1 -0
- {igbot_base-0.0.11.dist-info → igbot_base-0.0.12.dist-info}/METADATA +1 -1
- {igbot_base-0.0.11.dist-info → igbot_base-0.0.12.dist-info}/RECORD +7 -7
- {igbot_base-0.0.11.dist-info → igbot_base-0.0.12.dist-info}/WHEEL +0 -0
- {igbot_base-0.0.11.dist-info → igbot_base-0.0.12.dist-info}/top_level.txt +0 -0
igbot_base/agent.py
CHANGED
@@ -2,11 +2,27 @@ from abc import ABC, abstractmethod
|
|
2
2
|
|
3
3
|
from igbot_base.agent_response import AgentResponse
|
4
4
|
|
5
|
+
from igbot_base.exception_handler import ExceptionHandler, ReturnFailedResponseGracefully
|
6
|
+
from igbot_base.logging_adapter import get_logger
|
7
|
+
|
8
|
+
logger = get_logger("application")
|
9
|
+
|
5
10
|
|
6
11
|
class Agent(ABC):
|
7
12
|
|
8
|
-
|
13
|
+
def __init__(self, name, exception_handler: ExceptionHandler = ReturnFailedResponseGracefully):
|
14
|
+
self.__name = name
|
15
|
+
self.__ex_handler = exception_handler
|
16
|
+
|
9
17
|
def invoke(self, query) -> AgentResponse:
|
18
|
+
try:
|
19
|
+
return self._invoke(query)
|
20
|
+
except Exception as e:
|
21
|
+
logger.exception("Exception occurred at %s for query %s: %s", self.describe(), query, e)
|
22
|
+
return self.__ex_handler.handle(e)
|
23
|
+
|
24
|
+
@abstractmethod
|
25
|
+
def _invoke(self, query) -> AgentResponse:
|
10
26
|
pass
|
11
27
|
|
12
28
|
@abstractmethod
|
@@ -14,4 +30,4 @@ class Agent(ABC):
|
|
14
30
|
pass
|
15
31
|
|
16
32
|
def __str__(self):
|
17
|
-
return self.describe()
|
33
|
+
return self.describe()
|
igbot_base/exception_handler.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
|
3
|
+
from igbot_base.agent_response import AgentResponse
|
4
|
+
|
3
5
|
|
4
6
|
class ExceptionHandler(ABC):
|
5
7
|
|
@@ -18,3 +20,9 @@ class PrintingExceptionHandler(ExceptionHandler):
|
|
18
20
|
|
19
21
|
def handle(self, e: Exception):
|
20
22
|
print(e)
|
23
|
+
|
24
|
+
|
25
|
+
class ReturnFailedResponseGracefully(ExceptionHandler):
|
26
|
+
|
27
|
+
def handle(self, e: Exception):
|
28
|
+
return AgentResponse.error(str(e), e)
|
igbot_base/llm.py
CHANGED
@@ -36,6 +36,7 @@ class Llm(ABC):
|
|
36
36
|
history.revert_to_snapshot()
|
37
37
|
|
38
38
|
def call(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
39
|
+
logger.debug("Call to %s with question: %s", self.__str__(), user_query)
|
39
40
|
history.set_snapshot()
|
40
41
|
try:
|
41
42
|
response = self._call(user_query, history, params)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
igbot_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
igbot_base/agent.py,sha256=
|
2
|
+
igbot_base/agent.py,sha256=FwQ5nvk5rLm5F-QaxsghhqDZcus_at7AehXIWDIk8dw,932
|
3
3
|
igbot_base/agent_response.py,sha256=eAps47djL_aWYn8P_BMpVGkPwO6m8nhltWWyh8qSG6E,1042
|
4
|
-
igbot_base/exception_handler.py,sha256=
|
5
|
-
igbot_base/llm.py,sha256=
|
4
|
+
igbot_base/exception_handler.py,sha256=9DFAW0K0U7Y2vKGiUW-j1C0_zp48UCyO8jL3oRj9yJQ,535
|
5
|
+
igbot_base/llm.py,sha256=wFHe-0bdONC2ZRzFzhR9FwZGuXGBdzdjlxwjYCekF7Y,1994
|
6
6
|
igbot_base/llmmemory.py,sha256=I6eSBPW1DK8UNiHhayon-DLbSbWSinO_EwM5S8C3tHA,1090
|
7
7
|
igbot_base/logging_adapter.py,sha256=kMuAaQPCba2luk0-WPxAbPNJaBL1yZsaff35ltKWgww,256
|
8
8
|
igbot_base/models.py,sha256=15bitUZy4Z4JhZbLd_SMx5pD7m8YuZiIq-wYGumf0ws,622
|
@@ -19,7 +19,7 @@ igbot_base/exception/memory_exception.py,sha256=ZGKw3dN2tMf9XHacYaVTXgvYpWi14z7u
|
|
19
19
|
igbot_base/exception/prompt_exception.py,sha256=_u-O9E2Z1DK_OT4StyOmIDLfr_Mmk4k0GLe67kIoQNc,413
|
20
20
|
igbot_base/exception/retriever_exception.py,sha256=A46sBV6_1N3jgBl-nFRw4KgEcz3oPb8d5Eb83YWDEPo,431
|
21
21
|
igbot_base/exception/tool_exception.py,sha256=1EX7R90MplT4Vqv1-zzPslFrNvDwcrh7wgEWun2Ba6k,386
|
22
|
-
igbot_base-0.0.
|
23
|
-
igbot_base-0.0.
|
24
|
-
igbot_base-0.0.
|
25
|
-
igbot_base-0.0.
|
22
|
+
igbot_base-0.0.12.dist-info/METADATA,sha256=_FLtvgekegWVYmfUjRCCqBIBReoqgqV3joe3bKE9oks,211
|
23
|
+
igbot_base-0.0.12.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
24
|
+
igbot_base-0.0.12.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
|
25
|
+
igbot_base-0.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|