igbot-base 0.0.22__py3-none-any.whl → 0.0.24__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/notifier.py ADDED
@@ -0,0 +1,20 @@
1
+ from abc import ABC
2
+
3
+ from pydantic import BaseModel, field_validator
4
+
5
+
6
+ class Notification(BaseModel):
7
+ message: str
8
+
9
+ @field_validator("message")
10
+ @classmethod
11
+ def validate_message(cls, v: str) -> str:
12
+ if not v or not v.strip():
13
+ raise ValueError("Message cannot be empty or blank")
14
+ return v
15
+
16
+
17
+ class Notifier(ABC):
18
+
19
+ def notify(self, notification: Notification):
20
+ pass
igbot_base/tokenizer.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from abc import ABC, abstractmethod
2
- from typing import Union, Dict
2
+ from typing import Union, Dict, List
3
3
  import json
4
4
  import tiktoken
5
5
 
@@ -15,7 +15,7 @@ class OpenAiTokenizer(BaseTokenizer):
15
15
  def __init__(self, model_name):
16
16
  self.__tokenizer = tiktoken.encoding_for_model(model_name)
17
17
 
18
- def count_tokens(self, data: Union[str: Dict, None]) -> int:
18
+ def count_tokens(self, data: Union[str: Dict, List, None]) -> int:
19
19
  if data is None:
20
20
  return 0
21
21
  elif isinstance(data, str):
@@ -23,5 +23,10 @@ class OpenAiTokenizer(BaseTokenizer):
23
23
  elif isinstance(data, dict):
24
24
  dict_as_str = json.dumps(data, separators=(",", ":"))
25
25
  return len(self.__tokenizer.encode(dict_as_str))
26
+ elif isinstance(data, list):
27
+ token_number = 0
28
+ for datum in data:
29
+ token_number += self.count_tokens(datum)
30
+ return token_number
26
31
  else:
27
- raise TypeError("Expected either a string, a dictionary, or None.")
32
+ raise TypeError("Expected either a string, a dictionary, a list, or None.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: igbot_base
3
- Version: 0.0.22
3
+ Version: 0.0.24
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
@@ -7,14 +7,15 @@ igbot_base/llm.py,sha256=0zul2Q3aiCpdhcLbTcpdSPkLdX7Dvwhhiv2V_KH7YRo,2157
7
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
+ igbot_base/notifier.py,sha256=hDrKqq-Q6upq5vqsRnF1M-Hw34lzAg7Yy3dyqy7nI_8,419
10
11
  igbot_base/persistable_memory.py,sha256=867Z4l_awD23QSTFDK3uN9TEttKfDpxx9g19c7ULG1Y,167
11
12
  igbot_base/prompt_template.py,sha256=q7bnU2Rp2Cvm4ixEmKHCyuolTPan6CHfYVAomT5kp10,1573
12
13
  igbot_base/response_formats.py,sha256=Sp679VfkcyxsR19ddFEHTOM7Ox0u2WBhdji_Y9pVc2M,94
13
14
  igbot_base/retriever.py,sha256=YHBHxiuPttsIAtjwwIz0fa9q2uFtsg0WoMRCorCt1PM,635
14
- igbot_base/tokenizer.py,sha256=uvDNr3UOeNL7Hg9HTfcFd-Fzf04SRSyEoOgYoo077Qs,825
15
+ igbot_base/tokenizer.py,sha256=WSR0GFc1eoMmyL58RAxtpb2iWCrqu9vQ2Ui-hqs4plw,1032
15
16
  igbot_base/tool.py,sha256=ghjuU3cK_VElHGStUl3IYf9dlRDOGM_aQucUQNUH3mU,431
16
17
  igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
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,,
18
+ igbot_base-0.0.24.dist-info/METADATA,sha256=S9qJQxKPuJPNJghfxIkJn7GxXHanpwoB6TsW21K-uDA,235
19
+ igbot_base-0.0.24.dist-info/WHEEL,sha256=GHB6lJx2juba1wDgXDNlMTyM13ckjBMKf-OnwgKOCtA,91
20
+ igbot_base-0.0.24.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
21
+ igbot_base-0.0.24.dist-info/RECORD,,