igbot-base 0.0.11__tar.gz → 0.0.13__tar.gz
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-0.0.11 → igbot_base-0.0.13}/PKG-INFO +1 -1
- igbot_base-0.0.13/igbot_base/agent.py +33 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception_handler.py +8 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/llm.py +4 -3
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base.egg-info/PKG-INFO +1 -1
- {igbot_base-0.0.11 → igbot_base-0.0.13}/pyproject.toml +1 -1
- igbot_base-0.0.11/igbot_base/agent.py +0 -17
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/__init__.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/agent_response.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/agent_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/base_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/llm_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/memory_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/prompt_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/retriever_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/exception/tool_exception.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/llmmemory.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/logging_adapter.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/models.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/persistable_memory.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/prompt_template.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/response_formats.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/retriever.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/tool.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base/vectorstore.py +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base.egg-info/SOURCES.txt +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base.egg-info/dependency_links.txt +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base.egg-info/requires.txt +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/igbot_base.egg-info/top_level.txt +0 -0
- {igbot_base-0.0.11 → igbot_base-0.0.13}/setup.cfg +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
|
3
|
+
from igbot_base.agent_response import AgentResponse
|
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
|
+
|
10
|
+
|
11
|
+
class Agent(ABC):
|
12
|
+
|
13
|
+
def __init__(self, name, exception_handler: ExceptionHandler = ReturnFailedResponseGracefully):
|
14
|
+
self.__name = name
|
15
|
+
self.__ex_handler = exception_handler
|
16
|
+
|
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:
|
26
|
+
pass
|
27
|
+
|
28
|
+
@abstractmethod
|
29
|
+
def describe(self):
|
30
|
+
pass
|
31
|
+
|
32
|
+
def __str__(self):
|
33
|
+
return self.describe()
|
@@ -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)
|
@@ -26,7 +26,7 @@ class Llm(ABC):
|
|
26
26
|
self._exception_handler = llm_exception_handler
|
27
27
|
|
28
28
|
def __str__(self):
|
29
|
-
return f"Llm({self._name} {self._model.get_name()})"
|
29
|
+
return f"Llm({self._name} {self._model.value.get_name()})"
|
30
30
|
|
31
31
|
@abstractmethod
|
32
32
|
def _call(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
@@ -36,14 +36,15 @@ 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)
|
42
|
-
logger.debug("LLM %s %s responded: %s", self._name, self._model.get_name(), response)
|
43
|
+
logger.debug("LLM %s %s responded: %s", self._name, self._model.value.get_name(), response)
|
43
44
|
return response
|
44
45
|
except Exception as e:
|
45
46
|
logger.error("Error occurred in LLM %s, Model %s at calling the API: %s",
|
46
|
-
self._name, self._model.get_name(), e)
|
47
|
+
self._name, self._model.value.get_name(), e)
|
47
48
|
self._revert_memory(history)
|
48
49
|
self._exception_handler.handle(e)
|
49
50
|
|
@@ -1,17 +0,0 @@
|
|
1
|
-
from abc import ABC, abstractmethod
|
2
|
-
|
3
|
-
from igbot_base.agent_response import AgentResponse
|
4
|
-
|
5
|
-
|
6
|
-
class Agent(ABC):
|
7
|
-
|
8
|
-
@abstractmethod
|
9
|
-
def invoke(self, query) -> AgentResponse:
|
10
|
-
pass
|
11
|
-
|
12
|
-
@abstractmethod
|
13
|
-
def describe(self):
|
14
|
-
pass
|
15
|
-
|
16
|
-
def __str__(self):
|
17
|
-
return self.describe()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|