igbot-base 0.0.19__py3-none-any.whl → 0.0.20__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/models.py +19 -5
- igbot_base/tokenizer.py +16 -0
- {igbot_base-0.0.19.dist-info → igbot_base-0.0.20.dist-info}/METADATA +2 -1
- {igbot_base-0.0.19.dist-info → igbot_base-0.0.20.dist-info}/RECORD +6 -5
- {igbot_base-0.0.19.dist-info → igbot_base-0.0.20.dist-info}/WHEEL +1 -1
- {igbot_base-0.0.19.dist-info → igbot_base-0.0.20.dist-info}/top_level.txt +0 -0
igbot_base/models.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
from enum import Enum
|
2
2
|
from openai import OpenAI
|
3
3
|
|
4
|
+
from tokenizer import BaseTokenizer, OpenAiTokenizer
|
5
|
+
|
4
6
|
|
5
7
|
class ModelInfo:
|
6
8
|
|
7
|
-
def __init__(self, name, client):
|
9
|
+
def __init__(self, name, client, tokenizer: BaseTokenizer, max_tokens):
|
8
10
|
self.__name = name
|
9
11
|
self.__client = client
|
12
|
+
self.__tokenizer = tokenizer
|
13
|
+
self.__max_tokens = max_tokens
|
10
14
|
|
11
15
|
def get_name(self):
|
12
16
|
return self.__name
|
@@ -14,9 +18,19 @@ class ModelInfo:
|
|
14
18
|
def get_client(self):
|
15
19
|
return self.__client()
|
16
20
|
|
21
|
+
def get_tokenizer(self) -> BaseTokenizer:
|
22
|
+
return self.__tokenizer
|
23
|
+
|
24
|
+
def get_max_tokens(self):
|
25
|
+
return self.__max_tokens
|
26
|
+
|
17
27
|
|
18
28
|
class Model(Enum):
|
19
|
-
OLLAMA_3_2_LOCAL = ModelInfo("llama3.2", lambda: OpenAI(base_url="http://localhost:11434/v1", api_key='ollama')
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
OLLAMA_3_2_LOCAL = ModelInfo("llama3.2", lambda: OpenAI(base_url="http://localhost:11434/v1", api_key='ollama'),
|
30
|
+
OpenAiTokenizer("gpt-4o"), 128_000)
|
31
|
+
OPENAI_GPT_4o_MINI = ModelInfo("gpt-4o-mini", lambda: OpenAI(),
|
32
|
+
OpenAiTokenizer("gpt-4o"), 128_000)
|
33
|
+
OPENAI_GPT_4o = ModelInfo("gpt-4o", lambda: OpenAI(),
|
34
|
+
OpenAiTokenizer("gpt-4o"), 128_000)
|
35
|
+
OPENAI_GPT_4o_MINI_JSON = ModelInfo("gpt-4o-mini-2024-07-18", lambda: OpenAI(),
|
36
|
+
OpenAiTokenizer("gpt-4o"), 128_000)
|
igbot_base/tokenizer.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
import tiktoken
|
3
|
+
|
4
|
+
|
5
|
+
class BaseTokenizer(ABC):
|
6
|
+
@abstractmethod
|
7
|
+
def count_tokens(self, text: str):
|
8
|
+
pass
|
9
|
+
|
10
|
+
|
11
|
+
class OpenAiTokenizer(BaseTokenizer):
|
12
|
+
def __init__(self, model_name):
|
13
|
+
self.__tokenizer = tiktoken.encoding_for_model(model_name)
|
14
|
+
|
15
|
+
def count_tokens(self, text: str):
|
16
|
+
return len(self.__tokenizer.encode(text))
|
@@ -1,8 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: igbot_base
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.20
|
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
7
|
Requires-Python: >=3.12
|
8
8
|
Requires-Dist: openai
|
9
|
+
Requires-Dist: tiktoken
|
@@ -6,14 +6,15 @@ igbot_base/exception_handler.py,sha256=Er5LbNt2ga2-e0GSzkJw66E-NS1dN_2msTRyyac1q
|
|
6
6
|
igbot_base/llm.py,sha256=0zul2Q3aiCpdhcLbTcpdSPkLdX7Dvwhhiv2V_KH7YRo,2157
|
7
7
|
igbot_base/llmmemory.py,sha256=I6eSBPW1DK8UNiHhayon-DLbSbWSinO_EwM5S8C3tHA,1090
|
8
8
|
igbot_base/logging_adapter.py,sha256=kMuAaQPCba2luk0-WPxAbPNJaBL1yZsaff35ltKWgww,256
|
9
|
-
igbot_base/models.py,sha256=
|
9
|
+
igbot_base/models.py,sha256=n3mxd9-WjVuLbTG3bWDVRauc8YhhBZew4_0Is9oQQgk,1215
|
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
15
|
igbot_base/tool.py,sha256=ghjuU3cK_VElHGStUl3IYf9dlRDOGM_aQucUQNUH3mU,431
|
15
16
|
igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
|
16
|
-
igbot_base-0.0.
|
17
|
-
igbot_base-0.0.
|
18
|
-
igbot_base-0.0.
|
19
|
-
igbot_base-0.0.
|
17
|
+
igbot_base-0.0.20.dist-info/METADATA,sha256=q_M4Ul2sCNwaeI2vwC7725Nmd9rdsVpns5D5pMT-tC8,235
|
18
|
+
igbot_base-0.0.20.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
19
|
+
igbot_base-0.0.20.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
|
20
|
+
igbot_base-0.0.20.dist-info/RECORD,,
|
File without changes
|