igbot-base 0.0.21__py3-none-any.whl → 0.0.22__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/llmmemory.py CHANGED
@@ -24,7 +24,7 @@ class LlmMemory(ABC):
24
24
  pass
25
25
 
26
26
  @abstractmethod
27
- def append_tool(self, tool_call_id: str, content: str):
27
+ def append_tool_response(self, tool_call_id: str, content: str):
28
28
  pass
29
29
 
30
30
  @abstractmethod
igbot_base/tokenizer.py CHANGED
@@ -1,16 +1,27 @@
1
1
  from abc import ABC, abstractmethod
2
+ from typing import Union, Dict
3
+ import json
2
4
  import tiktoken
3
5
 
4
6
 
5
7
  class BaseTokenizer(ABC):
6
8
  @abstractmethod
7
- def count_tokens(self, text: str):
9
+ def count_tokens(self, data: Union[str, Dict, None]) -> int:
8
10
  pass
9
11
 
10
12
 
11
13
  class OpenAiTokenizer(BaseTokenizer):
14
+
12
15
  def __init__(self, model_name):
13
16
  self.__tokenizer = tiktoken.encoding_for_model(model_name)
14
17
 
15
- def count_tokens(self, text: str):
16
- return len(self.__tokenizer.encode(text))
18
+ def count_tokens(self, data: Union[str: Dict, None]) -> int:
19
+ if data is None:
20
+ return 0
21
+ elif isinstance(data, str):
22
+ return len(self.__tokenizer.encode(data))
23
+ elif isinstance(data, dict):
24
+ dict_as_str = json.dumps(data, separators=(",", ":"))
25
+ return len(self.__tokenizer.encode(dict_as_str))
26
+ else:
27
+ raise TypeError("Expected either a string, a dictionary, or None.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: igbot_base
3
- Version: 0.0.21
3
+ Version: 0.0.22
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
@@ -4,17 +4,17 @@ igbot_base/agent_response.py,sha256=fmZLaPlpnolXWrPVtNah20nI3Cble21DMQybPJxMvrs,
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
6
  igbot_base/llm.py,sha256=0zul2Q3aiCpdhcLbTcpdSPkLdX7Dvwhhiv2V_KH7YRo,2157
7
- igbot_base/llmmemory.py,sha256=I6eSBPW1DK8UNiHhayon-DLbSbWSinO_EwM5S8C3tHA,1090
7
+ igbot_base/llmmemory.py,sha256=fhHrqYi3VTDsCc5riK0pbcIUH4rC_xYOJdFKZ_9zndM,1099
8
8
  igbot_base/logging_adapter.py,sha256=kMuAaQPCba2luk0-WPxAbPNJaBL1yZsaff35ltKWgww,256
9
9
  igbot_base/models.py,sha256=cgZwQ2GEeM_hCUxSwyls0b9CsjIsgImjzq7b3c289g4,1226
10
10
  igbot_base/persistable_memory.py,sha256=867Z4l_awD23QSTFDK3uN9TEttKfDpxx9g19c7ULG1Y,167
11
11
  igbot_base/prompt_template.py,sha256=q7bnU2Rp2Cvm4ixEmKHCyuolTPan6CHfYVAomT5kp10,1573
12
12
  igbot_base/response_formats.py,sha256=Sp679VfkcyxsR19ddFEHTOM7Ox0u2WBhdji_Y9pVc2M,94
13
13
  igbot_base/retriever.py,sha256=YHBHxiuPttsIAtjwwIz0fa9q2uFtsg0WoMRCorCt1PM,635
14
- igbot_base/tokenizer.py,sha256=VfCBZeI8DLJalguUc1e9XdeCmK8VAgyMHxssv0D5Y1M,385
14
+ igbot_base/tokenizer.py,sha256=uvDNr3UOeNL7Hg9HTfcFd-Fzf04SRSyEoOgYoo077Qs,825
15
15
  igbot_base/tool.py,sha256=ghjuU3cK_VElHGStUl3IYf9dlRDOGM_aQucUQNUH3mU,431
16
16
  igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
17
- igbot_base-0.0.21.dist-info/METADATA,sha256=rArIPQG-sLfUfqhDm3q1b3CKD90Bpjef_WwozBBkQt8,235
18
- igbot_base-0.0.21.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
19
- igbot_base-0.0.21.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
20
- igbot_base-0.0.21.dist-info/RECORD,,
17
+ igbot_base-0.0.22.dist-info/METADATA,sha256=78jnUQdCKgRLQe165z5TBeMDX1BlLdzVOl96ldamszE,235
18
+ igbot_base-0.0.22.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
19
+ igbot_base-0.0.22.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
20
+ igbot_base-0.0.22.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.1)
2
+ Generator: setuptools (80.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5