igbot-base 0.0.9__tar.gz → 0.0.11__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.9 → igbot_base-0.0.11}/PKG-INFO +1 -1
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/agent.py +8 -1
- igbot_base-0.0.11/igbot_base/exception/agent_exception.py +14 -0
- igbot_base-0.0.11/igbot_base/exception/base_exception.py +12 -0
- igbot_base-0.0.11/igbot_base/exception/llm_exception.py +13 -0
- igbot_base-0.0.11/igbot_base/exception/memory_exception.py +14 -0
- igbot_base-0.0.11/igbot_base/exception/prompt_exception.py +14 -0
- igbot_base-0.0.11/igbot_base/exception/retriever_exception.py +14 -0
- igbot_base-0.0.11/igbot_base/exception/tool_exception.py +14 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/llm.py +12 -1
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/llmmemory.py +7 -0
- igbot_base-0.0.11/igbot_base/logging_adapter.py +15 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/prompt_template.py +13 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/retriever.py +7 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/tool.py +7 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/vectorstore.py +3 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base.egg-info/PKG-INFO +1 -1
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base.egg-info/SOURCES.txt +9 -1
- {igbot_base-0.0.9 → igbot_base-0.0.11}/pyproject.toml +1 -1
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/__init__.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/agent_response.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/exception_handler.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/models.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/persistable_memory.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base/response_formats.py +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base.egg-info/dependency_links.txt +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base.egg-info/requires.txt +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/igbot_base.egg-info/top_level.txt +0 -0
- {igbot_base-0.0.9 → igbot_base-0.0.11}/setup.cfg +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
from igbot_base.agent import Agent
|
2
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
3
|
+
|
4
|
+
|
5
|
+
class BaseAgentException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, agent: Agent, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.agent = agent
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at agent {self.agent}"
|
14
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class IgBotBaseException(Exception):
|
2
|
+
|
3
|
+
def __init__(self, message, cause: Exception = None):
|
4
|
+
super().__init__(message)
|
5
|
+
self.cause = cause
|
6
|
+
|
7
|
+
def __str__(self):
|
8
|
+
result = self.args[0]
|
9
|
+
if self.cause:
|
10
|
+
result += f" Caused by: {self.cause}"
|
11
|
+
|
12
|
+
return result
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
2
|
+
from igbot_base.llm import Llm
|
3
|
+
|
4
|
+
|
5
|
+
class BaseLlmException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, llm: Llm, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.llm = llm
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at llm {self.llm}"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
2
|
+
from igbot_base.llmmemory import LlmMemory
|
3
|
+
|
4
|
+
|
5
|
+
class BaseMemoryException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, memory: LlmMemory, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.memory = memory
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at memory {self.memory}"
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
2
|
+
from igbot_base.prompt_template import Prompt
|
3
|
+
|
4
|
+
|
5
|
+
class BasePromptException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, prompt: Prompt, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.prompt = prompt
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at prompt {self.prompt}"
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
2
|
+
from igbot_base.retriever import Retriever
|
3
|
+
|
4
|
+
|
5
|
+
class BaseRetrieverException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, retriever: Retriever, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.retriever = retriever
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at retriever {self.retriever}"
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from igbot_base.exception.base_exception import IgBotBaseException
|
2
|
+
from igbot_base.tool import Tool
|
3
|
+
|
4
|
+
|
5
|
+
class BaseToolException(IgBotBaseException):
|
6
|
+
|
7
|
+
def __init__(self, message, tool: Tool, cause: Exception = None):
|
8
|
+
super().__init__(message, cause)
|
9
|
+
self.tool = tool
|
10
|
+
|
11
|
+
def __str__(self):
|
12
|
+
result = super().__str__()
|
13
|
+
result += f" at tool {self.tool}"
|
14
|
+
|
@@ -5,6 +5,9 @@ from typing import Optional
|
|
5
5
|
from igbot_base.exception_handler import ExceptionHandler, NoopExceptionHandler
|
6
6
|
from igbot_base.llmmemory import LlmMemory
|
7
7
|
from igbot_base.models import Model
|
8
|
+
from igbot_base.logging_adapter import get_logger
|
9
|
+
|
10
|
+
logger = get_logger("application")
|
8
11
|
|
9
12
|
|
10
13
|
class Llm(ABC):
|
@@ -22,6 +25,9 @@ class Llm(ABC):
|
|
22
25
|
self._format = response_format
|
23
26
|
self._exception_handler = llm_exception_handler
|
24
27
|
|
28
|
+
def __str__(self):
|
29
|
+
return f"Llm({self._name} {self._model.get_name()})"
|
30
|
+
|
25
31
|
@abstractmethod
|
26
32
|
def _call(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
27
33
|
pass
|
@@ -32,8 +38,12 @@ class Llm(ABC):
|
|
32
38
|
def call(self, user_query: str, history: LlmMemory, params: dict) -> str:
|
33
39
|
history.set_snapshot()
|
34
40
|
try:
|
35
|
-
|
41
|
+
response = self._call(user_query, history, params)
|
42
|
+
logger.debug("LLM %s %s responded: %s", self._name, self._model.get_name(), response)
|
43
|
+
return response
|
36
44
|
except Exception as e:
|
45
|
+
logger.error("Error occurred in LLM %s, Model %s at calling the API: %s",
|
46
|
+
self._name, self._model.get_name(), e)
|
37
47
|
self._revert_memory(history)
|
38
48
|
self._exception_handler.handle(e)
|
39
49
|
|
@@ -45,3 +55,4 @@ class Llm(ABC):
|
|
45
55
|
args["response_format"] = self._format
|
46
56
|
|
47
57
|
return args
|
58
|
+
|
@@ -2,6 +2,9 @@ import re
|
|
2
2
|
from typing import Optional
|
3
3
|
|
4
4
|
from igbot_base.exception_handler import ExceptionHandler, PrintingExceptionHandler
|
5
|
+
from igbot_base.logging_adapter import get_logger
|
6
|
+
|
7
|
+
logger = get_logger("application")
|
5
8
|
|
6
9
|
|
7
10
|
class Prompt:
|
@@ -15,6 +18,9 @@ class Prompt:
|
|
15
18
|
self.__variables = variables
|
16
19
|
self.__exception_handler = exception_handler
|
17
20
|
|
21
|
+
def __str__(self):
|
22
|
+
return f"Prompt({self.__get_content_short()} ({",".join(self.__variables)}))"
|
23
|
+
|
18
24
|
@staticmethod
|
19
25
|
def replace_placeholders(text: str, values: dict) -> str:
|
20
26
|
def replacer(match):
|
@@ -30,9 +36,16 @@ class Prompt:
|
|
30
36
|
try:
|
31
37
|
return self.replace_placeholders(self.__content, params)
|
32
38
|
except KeyError as e:
|
39
|
+
logger.exception("Exception occurred when parsing prompt %s... %s", self.__get_content_short(), e)
|
33
40
|
self.__exception_handler.handle(e)
|
34
41
|
|
35
42
|
raise Exception(f"Error while substituting values for prompt")
|
36
43
|
|
37
44
|
def get_content(self) -> str:
|
38
45
|
return self.__content
|
46
|
+
|
47
|
+
def __get_content_short(self):
|
48
|
+
if len(self.__content) > 15:
|
49
|
+
return self.__content[:15]
|
50
|
+
else:
|
51
|
+
return self.__content
|
@@ -5,6 +5,7 @@ igbot_base/agent_response.py
|
|
5
5
|
igbot_base/exception_handler.py
|
6
6
|
igbot_base/llm.py
|
7
7
|
igbot_base/llmmemory.py
|
8
|
+
igbot_base/logging_adapter.py
|
8
9
|
igbot_base/models.py
|
9
10
|
igbot_base/persistable_memory.py
|
10
11
|
igbot_base/prompt_template.py
|
@@ -16,4 +17,11 @@ igbot_base.egg-info/PKG-INFO
|
|
16
17
|
igbot_base.egg-info/SOURCES.txt
|
17
18
|
igbot_base.egg-info/dependency_links.txt
|
18
19
|
igbot_base.egg-info/requires.txt
|
19
|
-
igbot_base.egg-info/top_level.txt
|
20
|
+
igbot_base.egg-info/top_level.txt
|
21
|
+
igbot_base/exception/agent_exception.py
|
22
|
+
igbot_base/exception/base_exception.py
|
23
|
+
igbot_base/exception/llm_exception.py
|
24
|
+
igbot_base/exception/memory_exception.py
|
25
|
+
igbot_base/exception/prompt_exception.py
|
26
|
+
igbot_base/exception/retriever_exception.py
|
27
|
+
igbot_base/exception/tool_exception.py
|
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
|