stores 0.1.7.dev2__tar.gz → 0.1.7.dev4__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.
Files changed (54) hide show
  1. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/PKG-INFO +1 -1
  2. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/pyproject.toml +1 -1
  3. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/venv_utils.py +41 -23
  4. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/uv.lock +1 -1
  5. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/.gitignore +0 -0
  6. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/.python-version +0 -0
  7. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/LICENSE +0 -0
  8. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/README.md +0 -0
  9. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/README.md +0 -0
  10. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/anthropic_api.py +0 -0
  11. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/google_gemini_auto_call.py +0 -0
  12. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/google_gemini_manual_call.py +0 -0
  13. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/langchain_w_tool_calling.py +0 -0
  14. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/langgraph_agent.py +0 -0
  15. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/litellm_w_tool_calling.py +0 -0
  16. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/llamaindex_agent.py +0 -0
  17. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/openai_agent.py +0 -0
  18. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/openai_chat_completions.py +0 -0
  19. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/examples/quickstarts/openai_responses.py +0 -0
  20. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/local_generator.py +0 -0
  21. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/run_browser_use.py +0 -0
  22. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/run_remote_tool.py +0 -0
  23. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/__init__.py +0 -0
  24. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/constants.py +0 -0
  25. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/format.py +0 -0
  26. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/__init__.py +0 -0
  27. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/base_index.py +0 -0
  28. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/index.py +0 -0
  29. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/local_index.py +0 -0
  30. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/indexes/remote_index.py +0 -0
  31. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/parse.py +0 -0
  32. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/stores/utils.py +0 -0
  33. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/README.md +0 -0
  34. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index/hello/__init__.py +0 -0
  35. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index/tools.py +0 -0
  36. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index/tools.toml +0 -0
  37. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_custom_class/foo.py +0 -0
  38. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_custom_class/tools.toml +0 -0
  39. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_function_error/foo.py +0 -0
  40. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_function_error/tools.toml +0 -0
  41. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_w_deps/mock_index/__init__.py +0 -0
  42. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_w_deps/pyproject.toml +0 -0
  43. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_w_deps/requirements.txt +0 -0
  44. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/mock_index_w_deps/tools.toml +0 -0
  45. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_format/conftest.py +0 -0
  46. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_format/test_format.py +0 -0
  47. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/conftest.py +0 -0
  48. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/test_base_index.py +0 -0
  49. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/test_index.py +0 -0
  50. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/test_local_index.py +0 -0
  51. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/test_remote_index.py +0 -0
  52. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_indexes/test_venv_utils.py +0 -0
  53. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_parse/conftest.py +0 -0
  54. {stores-0.1.7.dev2 → stores-0.1.7.dev4}/tests/test_parse/test_parse.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stores
3
- Version: 0.1.7.dev2
3
+ Version: 0.1.7.dev4
4
4
  Summary: Repository of Python functions and tools for LLMs
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "stores"
3
- version = "0.1.7dev2"
3
+ version = "0.1.7dev4"
4
4
  description = "Repository of Python functions and tools for LLMs"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -151,8 +151,14 @@ def get_tool_signature(
151
151
  tool_name = tool_id.split(".")[-1]
152
152
  env_var = env_var or {}
153
153
 
154
+ # We use sockets to pass pass function metadata
155
+ listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
156
+ listener.bind(("localhost", 0))
157
+ listener.listen(1)
158
+ _, port = listener.getsockname()
159
+
154
160
  runner = f"""
155
- import pickle, sys, traceback, inspect, enum
161
+ import pickle, sys, traceback, inspect, enum, socket
156
162
  from typing import Any, Dict, List, Literal, Tuple, Union, get_args, get_origin, get_type_hints
157
163
  import types as T
158
164
 
@@ -206,8 +212,9 @@ def extract_type_info(typ, custom_types: list[str] | None = None):
206
212
 
207
213
  try:
208
214
  from {module_name} import {tool_name}
209
- sig = inspect.signature({tool_name})
210
- hints = get_type_hints({tool_name})
215
+ func = {tool_name}
216
+ sig = inspect.signature(func)
217
+ hints = get_type_hints(func)
211
218
  params = {{}}
212
219
  for name, param in sig.parameters.items():
213
220
  hint = hints.get(name, param.annotation)
@@ -218,33 +225,44 @@ try:
218
225
  return_type = hints.get('return', sig.return_annotation)
219
226
  return_info = extract_type_info(return_type)
220
227
 
221
- pickle.dump(
222
- {{
223
- "ok": True,
224
- "result": {{
225
- "tool_id": "{tool_id}",
226
- "params": params,
227
- "return": return_info,
228
- "iscoroutinefunction": inspect.iscoroutinefunction({tool_name}),
229
- "isgeneratorfunction": inspect.isgeneratorfunction({tool_name}),
230
- "isasyncgenfunction": inspect.isasyncgenfunction({tool_name}),
231
- "doc": inspect.getdoc({tool_name}),
232
- }},
228
+ payload = {{
229
+ "ok": True,
230
+ "result": {{
231
+ "tool_id": "{tool_id}",
232
+ "params": params,
233
+ "return": return_info,
234
+ "iscoroutinefunction": inspect.iscoroutinefunction(func),
235
+ "isgeneratorfunction": inspect.isgeneratorfunction(func),
236
+ "isasyncgenfunction": inspect.isasyncgenfunction(func),
237
+ "doc": inspect.getdoc(func),
233
238
  }},
234
- sys.stdout.buffer,
235
- )
239
+ }}
236
240
  except Exception as e:
237
- err = traceback.format_exc()
238
- pickle.dump({{"ok": False, "error": err}}, sys.stdout.buffer)
241
+ payload = {{"ok": False, "error": traceback.format_exc()}}
242
+
243
+ with socket.create_connection(("localhost", {port})) as s:
244
+ s.sendall(pickle.dumps(payload))
239
245
  """
240
- result = subprocess.run(
246
+ proc = subprocess.Popen(
241
247
  [get_python_command(Path(index_folder) / venv), "-c", runner],
242
- capture_output=True,
243
248
  cwd=index_folder,
244
249
  env=env_var or None,
245
250
  )
251
+
252
+ conn, _ = listener.accept()
253
+ with conn:
254
+ data = b""
255
+ while True:
256
+ chunk = conn.recv(4096)
257
+ if not chunk:
258
+ break
259
+ data += chunk
260
+
261
+ listener.close()
262
+ proc.wait()
263
+
246
264
  try:
247
- response = pickle.loads(result.stdout)
265
+ response = pickle.loads(data)
248
266
  except ModuleNotFoundError as e:
249
267
  raise RuntimeError(
250
268
  f"Error loading tool {tool_id}:\nThe tool most likely has a parameter of a custom type that cannot be exported"
@@ -462,7 +480,7 @@ def run_remote_tool(
462
480
  conn.close()
463
481
 
464
482
  if not stream:
465
- thread = threading.Thread(target=lambda: list(handle_connection_sync()))
483
+ thread = threading.Thread(target=lambda: handle_connection_sync())
466
484
  thread.start()
467
485
 
468
486
  runner = f"""
@@ -2963,7 +2963,7 @@ wheels = [
2963
2963
 
2964
2964
  [[package]]
2965
2965
  name = "stores"
2966
- version = "0.1.7.dev1"
2966
+ version = "0.1.7.dev3"
2967
2967
  source = { editable = "." }
2968
2968
  dependencies = [
2969
2969
  { name = "dirtyjson" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes