igbot-base 0.0.9__py3-none-any.whl → 0.0.10__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/llm.py CHANGED
@@ -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):
@@ -32,8 +35,12 @@ class Llm(ABC):
32
35
  def call(self, user_query: str, history: LlmMemory, params: dict) -> str:
33
36
  history.set_snapshot()
34
37
  try:
35
- return self._call(user_query, history, params)
38
+ response = self._call(user_query, history, params)
39
+ logger.debug("LLM %s %s responded: %s", self._name, self._model.get_name(), response)
40
+ return response
36
41
  except Exception as e:
42
+ logger.error("Error occurred in LLM %s, Model %s at calling the API: %s",
43
+ self._name, self._model.get_name(), e)
37
44
  self._revert_memory(history)
38
45
  self._exception_handler.handle(e)
39
46
 
@@ -0,0 +1,15 @@
1
+ import logging
2
+
3
+ try:
4
+ import structlog
5
+
6
+ USE_STRUCTLOG = True
7
+ except ImportError:
8
+ USE_STRUCTLOG = False
9
+
10
+
11
+ def get_logger(name: str):
12
+ if USE_STRUCTLOG:
13
+ return structlog.get_logger(name)
14
+ else:
15
+ return logging.getLogger(name)
@@ -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:
@@ -30,9 +33,16 @@ class Prompt:
30
33
  try:
31
34
  return self.replace_placeholders(self.__content, params)
32
35
  except KeyError as e:
36
+ logger.exception("Exception occurred when parsing prompt %s... %s", self.__get_content_short(), e)
33
37
  self.__exception_handler.handle(e)
34
38
 
35
39
  raise Exception(f"Error while substituting values for prompt")
36
40
 
37
41
  def get_content(self) -> str:
38
42
  return self.__content
43
+
44
+ def __get_content_short(self):
45
+ if len(self.__content) > 15:
46
+ return self.__content[:15]
47
+ else:
48
+ return self.__content
igbot_base/vectorstore.py CHANGED
@@ -1,6 +1,9 @@
1
1
  from abc import ABC, abstractmethod
2
2
 
3
3
  from igbot_base.retriever import Retriever
4
+ from igbot_base.logging_adapter import get_logger
5
+
6
+ logger = get_logger("application")
4
7
 
5
8
 
6
9
  class Metadata:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: igbot_base
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: Base classes for igbot
5
5
  Author-email: Igor Kopeć <igor.kopec95@gmail.com>
6
6
  License: LGPL-3.0-or-later
@@ -2,16 +2,17 @@ igbot_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  igbot_base/agent.py,sha256=186kf599wrK4z41RVddeh0dH_iJ-_fCTqxM7J00P8IE,188
3
3
  igbot_base/agent_response.py,sha256=eAps47djL_aWYn8P_BMpVGkPwO6m8nhltWWyh8qSG6E,1042
4
4
  igbot_base/exception_handler.py,sha256=BMzQpgP4jnnRuTcEItx0oMljTZmKgMRCHzpybHn88Ig,341
5
- igbot_base/llm.py,sha256=XNd_HyR2jK_7XlDW-2rdSaSCmVjRLAl_fdVTC2sW0HU,1461
5
+ igbot_base/llm.py,sha256=Tuj8DJtHIDnG0ebbcQfeWHV0rheI-5MvfW3Vi-yytrA,1827
6
6
  igbot_base/llmmemory.py,sha256=KslOeTSZwvHVyFglbFhPcb6_GCCXZOqHz5YBTzJ2mew,977
7
+ igbot_base/logging_adapter.py,sha256=kMuAaQPCba2luk0-WPxAbPNJaBL1yZsaff35ltKWgww,256
7
8
  igbot_base/models.py,sha256=15bitUZy4Z4JhZbLd_SMx5pD7m8YuZiIq-wYGumf0ws,622
8
9
  igbot_base/persistable_memory.py,sha256=867Z4l_awD23QSTFDK3uN9TEttKfDpxx9g19c7ULG1Y,167
9
- igbot_base/prompt_template.py,sha256=YHJDbe-33Zs202DMh6gLY_lLDejcyqB9xmek6xnyE0Q,1106
10
+ igbot_base/prompt_template.py,sha256=hw5oZDYRpjllso8J0TYf9MrsppnqkSfwBpuMIu9e6OU,1463
10
11
  igbot_base/response_formats.py,sha256=Sp679VfkcyxsR19ddFEHTOM7Ox0u2WBhdji_Y9pVc2M,94
11
12
  igbot_base/retriever.py,sha256=TeHWi6Sy5EvmmXOnNXuWLJO1Imlj0i6CEihv3WVN0SI,523
12
13
  igbot_base/tool.py,sha256=8QwzQuokkVSITCjZuZJeEbCvJU-n2yh9D-QauQex4Ko,319
13
- igbot_base/vectorstore.py,sha256=Q1ZRlsJ45ckgFZuPPQVMWuYl3W_L-HiX9VJIJ0wnjU8,842
14
- igbot_base-0.0.9.dist-info/METADATA,sha256=Vp252wgk01DCuFYmC6KxzXzpu1_h0QRVDSXNVNsLZh8,210
15
- igbot_base-0.0.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
16
- igbot_base-0.0.9.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
17
- igbot_base-0.0.9.dist-info/RECORD,,
14
+ igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
15
+ igbot_base-0.0.10.dist-info/METADATA,sha256=klA4DKfpsEshdzy5MAIwyLpGnYYwN4nJqb0bIp47oG4,211
16
+ igbot_base-0.0.10.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
17
+ igbot_base-0.0.10.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
18
+ igbot_base-0.0.10.dist-info/RECORD,,