igbot-base 0.0.39__py3-none-any.whl → 0.0.41__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/tool.py CHANGED
@@ -7,6 +7,11 @@ from pydantic import BaseModel
7
7
  class ToolResponse(BaseModel):
8
8
  message: Optional[str] = None
9
9
  data: Optional[Any] = None
10
+ tool_name: str
11
+
12
+ class ToolCall(BaseModel):
13
+ args: Optional[dict] = None
14
+ tool_name: str
10
15
 
11
16
  class Tool(ABC):
12
17
 
@@ -0,0 +1,16 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ from igbot_base.tool import ToolResponse
4
+
5
+
6
+ class ToolMerger(ABC):
7
+ def __init__(self):
8
+ pass
9
+
10
+ @abstractmethod
11
+ def supports_tools(self) -> list[str]:
12
+ pass
13
+
14
+ @abstractmethod
15
+ def process_tool_results(self, tool_responses: list[ToolResponse]):
16
+ pass
@@ -0,0 +1,14 @@
1
+ from igbot_base.tool_merger import ToolMerger
2
+ from igbot_base.tool import ToolResponse
3
+
4
+
5
+ class ToolMergerChain:
6
+ def __init__(self, mergers: list[ToolMerger]):
7
+ self.__mergers = mergers
8
+
9
+ def process(self, tool_responses: list[ToolResponse]):
10
+ for merger in self.__mergers:
11
+ supported_tools = merger.supports_tools()
12
+ matching_responses = [r for r in tool_responses if r.tool_name in supported_tools]
13
+ if len(matching_responses) != 0:
14
+ merger.process_tool_results(matching_responses)
@@ -0,0 +1,16 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ from igbot_base.tool import ToolCall
4
+
5
+
6
+ class ToolPreMerger(ABC):
7
+ def __init__(self):
8
+ pass
9
+
10
+ @abstractmethod
11
+ def supports_tools(self) -> list[str]:
12
+ pass
13
+
14
+ @abstractmethod
15
+ def process_tool_results(self, tool_calls: list[ToolCall]):
16
+ pass
@@ -0,0 +1,14 @@
1
+ from igbot_base.tool_pre_merger import ToolPreMerger
2
+ from igbot_base.tool import ToolCall
3
+
4
+
5
+ class ToolPreMergerChain:
6
+ def __init__(self, mergers: list[ToolPreMerger]):
7
+ self.__mergers = mergers
8
+
9
+ def process(self, tool_responses: list[ToolCall]):
10
+ for merger in self.__mergers:
11
+ supported_tools = merger.supports_tools()
12
+ matching_responses = [r for r in tool_responses if r.tool_name in supported_tools]
13
+ if len(matching_responses) != 0:
14
+ merger.process_tool_results(matching_responses)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: igbot_base
3
- Version: 0.0.39
3
+ Version: 0.0.41
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
@@ -14,9 +14,13 @@ igbot_base/prompt_template.py,sha256=q7bnU2Rp2Cvm4ixEmKHCyuolTPan6CHfYVAomT5kp10
14
14
  igbot_base/response_formats.py,sha256=Sp679VfkcyxsR19ddFEHTOM7Ox0u2WBhdji_Y9pVc2M,94
15
15
  igbot_base/retriever.py,sha256=YHBHxiuPttsIAtjwwIz0fa9q2uFtsg0WoMRCorCt1PM,635
16
16
  igbot_base/tokenizer.py,sha256=WSR0GFc1eoMmyL58RAxtpb2iWCrqu9vQ2Ui-hqs4plw,1032
17
- igbot_base/tool.py,sha256=r0YV9KDVLyXyt2TnC4RLxK0r0llFPgDNwXw5TfhH_JA,634
17
+ igbot_base/tool.py,sha256=Nc491Dp78g2uQLKqjHjIlFV_gzbtr9k1FM36LaUE2f8,732
18
+ igbot_base/tool_merger.py,sha256=_skJwyz8yuYjJ6oIvIp8QQlcgjdId3HtofUGLZgp-6s,322
19
+ igbot_base/tool_merger_chain.py,sha256=Qhi0IUyb-TXv3tv3ZBMQb2-fAmCnHGBNKwWEzZSFjRY,552
20
+ igbot_base/tool_pre_merger.py,sha256=wgBy-Wny8cxsNJR5biaVdYjBjAC91C9owbLaGddKD7g,313
21
+ igbot_base/tool_pre_merger_chain.py,sha256=qNuQHRZp6r-5j8GA8FOucTsUJ7G6IqVisGW3TaqdAm4,557
18
22
  igbot_base/vectorstore.py,sha256=f-S9DmOuehC0rtVAPGz22Guo7ddb1jVw7BygzFJM624,928
19
- igbot_base-0.0.39.dist-info/METADATA,sha256=0tx5AFH4T3wXbLg6hvVBiRtvZmeiA1sNt4MVeV7t43Y,235
20
- igbot_base-0.0.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- igbot_base-0.0.39.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
22
- igbot_base-0.0.39.dist-info/RECORD,,
23
+ igbot_base-0.0.41.dist-info/METADATA,sha256=eoOCg_EsGPzNxUP_pzxN6vgnSrTNMZ_UYyMGzwOLQLE,235
24
+ igbot_base-0.0.41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ igbot_base-0.0.41.dist-info/top_level.txt,sha256=RGpEN0pLsnfNLoLfpw1D_nLSyZwi3ggSaDq07o4ZEAI,11
26
+ igbot_base-0.0.41.dist-info/RECORD,,