hyperpocket-llamaindex 0.0.1__tar.gz → 0.1.8__tar.gz

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.
@@ -0,0 +1,157 @@
1
+ .vs/
2
+ .vscode/
3
+ .idea/
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ pip-wheel-metadata/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # Google GitHub Actions credentials files created by:
34
+ # https://github.com/google-github-actions/auth
35
+ #
36
+ # That action recommends adding this gitignore to prevent accidentally committing keys.
37
+ gha-creds-*.json
38
+
39
+ # PyInstaller
40
+ # Usually these files are written by a python script from a template
41
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
42
+ *.manifest
43
+ *.spec
44
+
45
+ # Unit test / coverage reports
46
+ htmlcov/
47
+ .tox/
48
+ .nox/
49
+ .coverage
50
+ .coverage.*
51
+ .cache
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ *.py,cover
56
+ .hypothesis/
57
+ .pytest_cache/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+ notebooks/
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ .python-version
87
+
88
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
89
+ __pypackages__/
90
+
91
+ # Celery stuff
92
+ celerybeat-schedule
93
+ celerybeat.pid
94
+
95
+ # SageMath parsed files
96
+ *.sage.py
97
+
98
+ # Environments
99
+ .env
100
+ .envrc
101
+ .venv*
102
+ venv*
103
+ env/
104
+ ENV/
105
+ env.bak/
106
+
107
+ # Spyder project settings
108
+ .spyderproject
109
+ .spyproject
110
+
111
+ # Rope project settings
112
+ .ropeproject
113
+
114
+ # mkdocs documentation
115
+ /site
116
+
117
+ # mypy
118
+ .mypy_cache/
119
+ .mypy_cache_test/
120
+ .dmypy.json
121
+ dmypy.json
122
+
123
+ # Pyre type checker
124
+ .pyre/
125
+
126
+ # macOS display setting files
127
+ .DS_Store
128
+
129
+ # Wandb directory
130
+ wandb/
131
+
132
+ # asdf tool versions
133
+ .tool-versions
134
+ /.ruff_cache/
135
+
136
+ *.pkl
137
+ *.bin
138
+
139
+ # integration test artifacts
140
+ data_map*
141
+ \[('_type', 'fake'), ('stop', None)]
142
+
143
+ # Replit files
144
+ *replit*
145
+
146
+
147
+ prof
148
+ virtualenv/
149
+
150
+ # Ignore dynaconf secret files
151
+ **/.secrets.toml
152
+ *.xml
153
+ *.iml
154
+ pocket.lock
155
+ .log/
156
+ .pocket/
157
+ _build/
@@ -1,16 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
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)
3
+ Version: 0.1.8
4
+ Author-email: moon <moon@vessl.ai>
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: hyperpocket>=0.0.3
7
+ Requires-Dist: llama-index>=0.12.5
14
8
  Description-Content-Type: text/markdown
15
9
 
16
10
  ## Anthropic extensions
@@ -56,4 +50,4 @@ llm = OpenAI()
56
50
  agent = FunctionCallingAgent.from_tools(
57
51
  tools=tools, llm=llm, verbose=True
58
52
  )
59
- ```
53
+ ```
File without changes
@@ -13,7 +13,7 @@ from hyperpocket.tool import Tool
13
13
 
14
14
  class PocketLlamaindex(Pocket):
15
15
  def get_tools(self) -> List[BaseTool]:
16
- tools = [self.get_tool(pk) for pk in self.tools.values()]
16
+ tools = [self.get_tool(pk) for pk in self.core.tools.values()]
17
17
  return tools
18
18
 
19
19
  def get_tool(self, pocket_tool: Tool) -> BaseTool:
@@ -0,0 +1,36 @@
1
+
2
+ [project]
3
+ name = "hyperpocket-llamaindex"
4
+ version = "0.1.8"
5
+ description = ""
6
+ authors = [{ name = "moon", email = "moon@vessl.ai" }]
7
+ requires-python = ">=3.10"
8
+ readme = "README.md"
9
+ dependencies = ["llama-index>=0.12.5", "hyperpocket>=0.0.3"]
10
+
11
+ [tool.uv.sources]
12
+ hyperpocket = { path = "../../hyperpocket", editable = true }
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8.3.4", "ruff>=0.8.6"]
16
+
17
+ [build-system]
18
+ requires = ["hatchling"]
19
+ build-backend = "hatchling.build"
20
+
21
+ [tool.ruff.lint]
22
+ select = [
23
+ "E", # pycodestyle errors,
24
+ "F", # pyflakes errors,
25
+ "I", # isort errors,
26
+ ]
27
+ ignore = [
28
+ "E501", # line too long, handled by formatting
29
+ ]
30
+
31
+ [tool.ruff]
32
+ line-length = 88
33
+ target-version = "py310"
34
+
35
+ [tool.ruff.lint.per-file-ignores]
36
+ "__init__.py" = ["F401"]
File without changes
@@ -0,0 +1,126 @@
1
+ import json
2
+ from unittest.async_case import IsolatedAsyncioTestCase
3
+
4
+ from llama_index.agent.openai import OpenAIAgent
5
+ from llama_index.llms.openai import OpenAI
6
+ from pydantic import BaseModel
7
+
8
+ from hyperpocket.config import config, secret
9
+ from hyperpocket.tool import from_git
10
+ from hyperpocket_llamaindex import PocketLlamaindex
11
+
12
+
13
+ class TestPocketLlamaindex(IsolatedAsyncioTestCase):
14
+
15
+ async def asyncSetUp(self):
16
+ config.public_server_port = "https"
17
+ config.public_hostname = "localhost"
18
+ config.public_server_port = 8001
19
+ config.internal_server_port = 8000
20
+ config.enable_local_callback_proxy = True
21
+
22
+ self.pocket = PocketLlamaindex(
23
+ tools=[
24
+ from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/simple-echo-tool"),
25
+ self.add,
26
+ self.sub_pydantic_args
27
+ ],
28
+ )
29
+
30
+ self.agent = OpenAIAgent.from_tools(
31
+ tools=self.pocket.get_tools(),
32
+ llm=OpenAI(model="gpt-4o", api_key=secret["OPENAI_API_KEY"]),
33
+ verbose=True
34
+ )
35
+
36
+ self.llm = OpenAI(model="gpt-4o", api_key=secret["OPENAI_API_KEY"])
37
+
38
+ async def asyncTearDown(self):
39
+ self.pocket._teardown_server()
40
+
41
+ async def test_function_tool(self):
42
+ # when
43
+ response = self.llm.chat_with_tools(user_msg="add 1, 2", tools=self.pocket.get_tools(), verbose=True)
44
+ message = response.message
45
+ tool_calls = message.additional_kwargs["tool_calls"]
46
+
47
+ tool_name = tool_calls[0].function.name
48
+ args = tool_calls[0].function.arguments
49
+ args = json.loads(args)
50
+
51
+ result = await self.pocket.ainvoke(tool_name=tool_name, **args)
52
+
53
+ # then
54
+ self.assertEqual(tool_name, "add")
55
+ self.assertEqual(args["body"], {
56
+ "a": 1,
57
+ "b": 2,
58
+ })
59
+ self.assertEqual(result, '3')
60
+
61
+ async def test_pydantic_function_tool(self):
62
+ # when
63
+ response = self.llm.chat_with_tools(user_msg="sub 1, 2", tools=self.pocket.get_tools(), verbose=True)
64
+ tool_calls = response.message.additional_kwargs["tool_calls"]
65
+
66
+ tool_name = tool_calls[0].function.name
67
+ args = tool_calls[0].function.arguments
68
+ args = json.loads(args)
69
+
70
+ result = await self.pocket.ainvoke(tool_name=tool_name, **args)
71
+
72
+ # then
73
+ self.assertEqual(tool_name, "sub_pydantic_args")
74
+ self.assertEqual(args["body"], {
75
+ "a": {"first": 1},
76
+ "b": {"second": 2},
77
+ })
78
+ self.assertEqual(result, '-1')
79
+
80
+ async def test_wasm_tool(self):
81
+ # when
82
+ response = self.llm.chat_with_tools(user_msg="echo 'hello world'", tools=self.pocket.get_tools(), verbose=True)
83
+ tool_calls = response.message.additional_kwargs["tool_calls"]
84
+
85
+ tool_name = tool_calls[0].function.name
86
+ args = tool_calls[0].function.arguments
87
+ args = json.loads(args)
88
+
89
+ result = await self.pocket.ainvoke(tool_name=tool_name, **args)
90
+
91
+ # then
92
+ self.assertEqual(tool_name, "simple_echo_text")
93
+ self.assertEqual(args["body"], {
94
+ "text": "hello world"
95
+ })
96
+ self.assertTrue(result.startswith("echo message : hello world"))
97
+
98
+ @staticmethod
99
+ def add(a: int, b: int) -> int:
100
+ """
101
+ Add two numbers
102
+
103
+ Args:
104
+ a(int): first number
105
+ b(int): second number
106
+
107
+ """
108
+
109
+ return a + b
110
+
111
+ class FirstNumber(BaseModel):
112
+ first: int
113
+
114
+ class SecondNumber(BaseModel):
115
+ second: int
116
+
117
+ @staticmethod
118
+ def sub_pydantic_args(a: FirstNumber, b: SecondNumber):
119
+ """
120
+ sub two numbers
121
+
122
+ Args:
123
+ a(FirstNumber): first number
124
+ b(SecondNumber): second number
125
+ """
126
+ return a.first - b.second