hyperpocket-llamaindex 0.0.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.1
2
+ Name: hyperpocket-llamaindex
3
+ Version: 0.0.1
4
+ Summary:
5
+ Author: moon
6
+ Author-email: moon@vessl.ai
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Requires-Dist: hyperpocket (==0.0.3)
13
+ Requires-Dist: llama-index (>=0.12.5,<0.13.0)
14
+ Description-Content-Type: text/markdown
15
+
16
+ ## Anthropic extensions
17
+
18
+ ### Get Pocket Tools
19
+
20
+ ```python
21
+ import hyperpocket as pk
22
+ from pocket_llamaindex import PocketLlamaindex
23
+
24
+ #
25
+ pocket = PocketLlamaindex(tools=[
26
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
27
+ *pk.curated_tools.LINEAR,
28
+ "https://github.com/my-org/some-awesome-tool"]
29
+ )
30
+
31
+ # get tools from pocket
32
+ tools = pocket.get_tools()
33
+ ```
34
+
35
+
36
+ ### Examples
37
+
38
+ ```python
39
+ from llama_index.core.agent import FunctionCallingAgent
40
+ from llama_index.llms.openai import OpenAI
41
+
42
+ import hyperpocket as pk
43
+ from pocket_llamaindex import PocketLlamaindex
44
+
45
+ pocket = PocketLlamaindex(tools=[
46
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
47
+ *pk.curated_tools.LINEAR,
48
+ "https://github.com/my-org/some-awesome-tool"]
49
+ )
50
+
51
+ # get tools from pocket
52
+ tools = pocket.get_tools()
53
+
54
+ llm = OpenAI()
55
+ # pass tools get by pocket to an argument
56
+ agent = FunctionCallingAgent.from_tools(
57
+ tools=tools, llm=llm, verbose=True
58
+ )
59
+ ```
@@ -0,0 +1,44 @@
1
+ ## Anthropic extensions
2
+
3
+ ### Get Pocket Tools
4
+
5
+ ```python
6
+ import hyperpocket as pk
7
+ from pocket_llamaindex import PocketLlamaindex
8
+
9
+ #
10
+ pocket = PocketLlamaindex(tools=[
11
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
12
+ *pk.curated_tools.LINEAR,
13
+ "https://github.com/my-org/some-awesome-tool"]
14
+ )
15
+
16
+ # get tools from pocket
17
+ tools = pocket.get_tools()
18
+ ```
19
+
20
+
21
+ ### Examples
22
+
23
+ ```python
24
+ from llama_index.core.agent import FunctionCallingAgent
25
+ from llama_index.llms.openai import OpenAI
26
+
27
+ import hyperpocket as pk
28
+ from pocket_llamaindex import PocketLlamaindex
29
+
30
+ pocket = PocketLlamaindex(tools=[
31
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
32
+ *pk.curated_tools.LINEAR,
33
+ "https://github.com/my-org/some-awesome-tool"]
34
+ )
35
+
36
+ # get tools from pocket
37
+ tools = pocket.get_tools()
38
+
39
+ llm = OpenAI()
40
+ # pass tools get by pocket to an argument
41
+ agent = FunctionCallingAgent.from_tools(
42
+ tools=tools, llm=llm, verbose=True
43
+ )
44
+ ```
@@ -0,0 +1,3 @@
1
+ from hyperpocket_llamaindex.pocket_llamaindex import PocketLlamaindex
2
+
3
+ __all__ = ["PocketLlamaindex"]
@@ -0,0 +1,44 @@
1
+ from typing import List, Any
2
+
3
+ try:
4
+ from llama_index.core.tools import FunctionTool, BaseTool, ToolMetadata
5
+ except ImportError:
6
+ raise ImportError(
7
+ "You need to install llama-index to use pocket llamaindex"
8
+ )
9
+
10
+ from hyperpocket import Pocket
11
+ from hyperpocket.tool import Tool
12
+
13
+
14
+ class PocketLlamaindex(Pocket):
15
+ def get_tools(self) -> List[BaseTool]:
16
+ tools = [self.get_tool(pk) for pk in self.tools.values()]
17
+ return tools
18
+
19
+ def get_tool(self, pocket_tool: Tool) -> BaseTool:
20
+ def _invoke(body: Any, thread_id: str = 'default', profile: str = 'default', **kwargs) -> str:
21
+ result, interrupted = self.invoke_with_state(pocket_tool.name, body=body, thread_id=thread_id,
22
+ profile=profile, **kwargs)
23
+ say = result
24
+ if interrupted:
25
+ say = f'{say}\n\nThe tool execution interrupted. Please talk to me to resume.'
26
+ return say
27
+
28
+ async def _ainvoke(body: Any, thread_id: str = 'default', profile: str = 'default', **kwargs) -> str:
29
+ result, interrupted = await self.ainvoke_with_state(pocket_tool.name, body=body,
30
+ thread_id=thread_id, profile=profile, **kwargs)
31
+ say = result
32
+ if interrupted:
33
+ say = f'{say}\n\nThe tool execution interrupted. Please talk to me to resume.'
34
+ return say
35
+
36
+ return FunctionTool.from_defaults(
37
+ fn=_invoke,
38
+ async_fn=_ainvoke,
39
+ tool_metadata=ToolMetadata(
40
+ description=pocket_tool.description,
41
+ name=pocket_tool.name,
42
+ fn_schema=pocket_tool.schema_model(),
43
+ )
44
+ )
@@ -0,0 +1,16 @@
1
+ [tool.poetry]
2
+ name = "hyperpocket-llamaindex"
3
+ version = "0.0.1"
4
+ description = ""
5
+ authors = ["moon <moon@vessl.ai>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.11"
10
+ llama-index = "^0.12.5"
11
+ hyperpocket = "0.0.3"
12
+
13
+
14
+ [build-system]
15
+ requires = ["poetry-core"]
16
+ build-backend = "poetry.core.masonry.api"