stores 0.1.0__tar.gz → 0.1.1__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 (52) hide show
  1. {stores-0.1.0 → stores-0.1.1}/PKG-INFO +1 -1
  2. {stores-0.1.0 → stores-0.1.1}/pyproject.toml +1 -1
  3. stores-0.1.1/run_complex.py +123 -0
  4. {stores-0.1.0 → stores-0.1.1}/stores/indexes/base_index.py +20 -6
  5. {stores-0.1.0 → stores-0.1.1}/uv.lock +9 -9
  6. {stores-0.1.0 → stores-0.1.1}/.gitignore +0 -0
  7. {stores-0.1.0 → stores-0.1.1}/.python-version +0 -0
  8. {stores-0.1.0 → stores-0.1.1}/LICENSE +0 -0
  9. {stores-0.1.0 → stores-0.1.1}/README.md +0 -0
  10. {stores-0.1.0 → stores-0.1.1}/examples/README.md +0 -0
  11. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/anthropic_api.py +0 -0
  12. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/google_gemini_auto_call.py +0 -0
  13. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/google_gemini_manual_call.py +0 -0
  14. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/langchain_w_tool_calling.py +0 -0
  15. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/langgraph_agent.py +0 -0
  16. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/litellm_w_tool_calling.py +0 -0
  17. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/llamaindex_agent.py +0 -0
  18. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/openai_agent.py +0 -0
  19. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/openai_chat_completions.py +0 -0
  20. {stores-0.1.0 → stores-0.1.1}/examples/quickstarts/openai_responses.py +0 -0
  21. {stores-0.1.0 → stores-0.1.1}/stores/__init__.py +0 -0
  22. {stores-0.1.0 → stores-0.1.1}/stores/constants.py +0 -0
  23. {stores-0.1.0 → stores-0.1.1}/stores/format.py +0 -0
  24. {stores-0.1.0 → stores-0.1.1}/stores/indexes/__init__.py +0 -0
  25. {stores-0.1.0 → stores-0.1.1}/stores/indexes/index.py +0 -0
  26. {stores-0.1.0 → stores-0.1.1}/stores/indexes/local_index.py +0 -0
  27. {stores-0.1.0 → stores-0.1.1}/stores/indexes/remote_index.py +0 -0
  28. {stores-0.1.0 → stores-0.1.1}/stores/indexes/venv_utils.py +0 -0
  29. {stores-0.1.0 → stores-0.1.1}/stores/parse.py +0 -0
  30. {stores-0.1.0 → stores-0.1.1}/stores/utils.py +0 -0
  31. {stores-0.1.0 → stores-0.1.1}/tests/README.md +0 -0
  32. {stores-0.1.0 → stores-0.1.1}/tests/mock_index/hello/__init__.py +0 -0
  33. {stores-0.1.0 → stores-0.1.1}/tests/mock_index/tools.py +0 -0
  34. {stores-0.1.0 → stores-0.1.1}/tests/mock_index/tools.toml +0 -0
  35. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_custom_class/foo.py +0 -0
  36. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_custom_class/tools.toml +0 -0
  37. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_function_error/foo.py +0 -0
  38. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_function_error/tools.toml +0 -0
  39. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_w_deps/mock_index/__init__.py +0 -0
  40. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_w_deps/pyproject.toml +0 -0
  41. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_w_deps/requirements.txt +0 -0
  42. {stores-0.1.0 → stores-0.1.1}/tests/mock_index_w_deps/tools.toml +0 -0
  43. {stores-0.1.0 → stores-0.1.1}/tests/test_format/conftest.py +0 -0
  44. {stores-0.1.0 → stores-0.1.1}/tests/test_format/test_format.py +0 -0
  45. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/conftest.py +0 -0
  46. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/test_base_index.py +0 -0
  47. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/test_index.py +0 -0
  48. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/test_local_index.py +0 -0
  49. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/test_remote_index.py +0 -0
  50. {stores-0.1.0 → stores-0.1.1}/tests/test_indexes/test_venv_utils.py +0 -0
  51. {stores-0.1.0 → stores-0.1.1}/tests/test_parse/conftest.py +0 -0
  52. {stores-0.1.0 → stores-0.1.1}/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.0
3
+ Version: 0.1.1
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.0"
3
+ version = "0.1.1"
4
4
  description = "Repository of Python functions and tools for LLMs"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -0,0 +1,123 @@
1
+ # import anthropic
2
+ import inspect
3
+
4
+ import dotenv
5
+ from langchain_core.tools import tool as callable_as_lc_tool
6
+ from langchain_google_genai import ChatGoogleGenerativeAI
7
+
8
+ # from openai import OpenAI
9
+ # from google import genai
10
+ # from google.genai import types
11
+ # from litellm import completion
12
+ # from stores.indexes import LocalIndex
13
+ import stores
14
+
15
+ dotenv.load_dotenv()
16
+
17
+
18
+ # def foo(bar: str = "test"):
19
+ # return bar
20
+
21
+
22
+ # index = stores.Index([foo])
23
+ # print(inspect.signature(index.tools[0]))
24
+ # print(index.tools[0]())
25
+ # quit()
26
+
27
+
28
+ index = stores.Index(
29
+ ["silanthro/todoist"],
30
+ env_var={
31
+ "silanthro/todoist": {
32
+ "TODOIST_API_TOKEN": "6a0815ff164d7ebd6d45d433bdbd32fcb164e1ec",
33
+ }
34
+ },
35
+ )
36
+
37
+ sig = inspect.signature(index.tools[0])
38
+ print(sig)
39
+
40
+ wrap = callable_as_lc_tool()(index.tools[0])
41
+ sig_wrap = inspect.signature(wrap)
42
+ print(sig_wrap)
43
+ # quit()
44
+
45
+ for argname, arg in sig.parameters.items():
46
+ print(argname)
47
+ print(arg.annotation)
48
+ print([arg.default])
49
+
50
+ # print(sig)
51
+ # quit()
52
+
53
+ # result = index.execute(
54
+ # "todoist.get_tasks",
55
+ # {
56
+ # "project_id": None,
57
+ # "search_query": None,
58
+ # "due_date_filter": "today",
59
+ # "priority": None,
60
+ # "other_filters": None,
61
+ # "limit": None,
62
+ # },
63
+ # )
64
+ # print(result)
65
+ # quit()
66
+
67
+
68
+ task = "Find tasks of priority 1"
69
+
70
+ # print(index.tools)
71
+
72
+ # print(index.format_tools("openai-chat-completions"))
73
+ # quit()
74
+
75
+ # client = OpenAI()
76
+ # response = client.responses.create(
77
+ # model="gpt-4o-mini-2024-07-18",
78
+ # input=[{"role": "user", "content": task}],
79
+ # tools=index.format_tools("openai-responses"),
80
+ # )
81
+ # client = anthropic.Anthropic()
82
+ # response = client.messages.create(
83
+ # model="claude-3-5-sonnet-20241022",
84
+ # max_tokens=1024,
85
+ # messages=[{"role": "user", "content": task}],
86
+ # tools=index.format_tools("anthropic"),
87
+ # )
88
+ # response = completion(
89
+ # model="gemini/gemini-2.0-flash-001",
90
+ # messages=[
91
+ # {
92
+ # "role": "user",
93
+ # "content": task,
94
+ # }
95
+ # ],
96
+ # tools=index.format_tools("google-gemini"),
97
+ # )
98
+ # client = genai.Client(
99
+ # # api_key=os.environ["GEMINI_API_KEY"],
100
+ # )
101
+ # config = types.GenerateContentConfig(
102
+ # tools=index.tools,
103
+ # automatic_function_calling=types.AutomaticFunctionCallingConfig(
104
+ # disable=True # Gemini automatically executes tool calls. This script shows how to manually execute tool calls.
105
+ # ),
106
+ # )
107
+
108
+ # # Get the response from the model
109
+ # response = client.models.generate_content(
110
+ # model="gemini-2.0-flash",
111
+ # contents=task,
112
+ # config=config,
113
+ # )
114
+ # tool_call = response.candidates[0].content.parts[0].function_call
115
+
116
+ model = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001")
117
+ model_with_tools = model.bind_tools(index.tools)
118
+ response = model_with_tools.invoke(task)
119
+ tool_call = response.tool_calls[0]
120
+
121
+ print(tool_call)
122
+ # Execute the tool call
123
+ # print(response)
@@ -1,5 +1,4 @@
1
1
  import asyncio
2
- import functools
3
2
  import inspect
4
3
  import logging
5
4
  import re
@@ -18,6 +17,8 @@ from typing import (
18
17
  get_type_hints,
19
18
  )
20
19
 
20
+ from makefun import create_function
21
+
21
22
  from stores.format import ProviderFormat, format_tools
22
23
  from stores.parse import llm_parse_json
23
24
  from stores.utils import check_duplicates
@@ -209,8 +210,15 @@ def wrap_tool(tool: Callable):
209
210
  # Inject default values within wrapper
210
211
  bound_args = original_signature.bind(*args, **kwargs)
211
212
  bound_args.apply_defaults()
212
- _cast_bound_args(bound_args)
213
213
  # Inject correct Literals
214
+ for k, v in bound_args.arguments.items():
215
+ if (
216
+ v is None
217
+ and original_signature.parameters[k].default is not Parameter.empty
218
+ ):
219
+ bound_args.arguments[k] = original_signature.parameters[k].default
220
+
221
+ _cast_bound_args(bound_args)
214
222
  for k, v in bound_args.arguments.items():
215
223
  if k in literal_maps:
216
224
  param = original_signature.parameters[k]
@@ -219,11 +227,17 @@ def wrap_tool(tool: Callable):
219
227
  )
220
228
  return tool(*bound_args.args, **bound_args.kwargs)
221
229
 
222
- functools.update_wrapper(wrapper, tool)
223
- wrapper.__signature__ = new_sig
224
- wrapper._wrapped = True
230
+ wrapped = create_function(
231
+ new_sig,
232
+ wrapper,
233
+ qualname=tool.__name__,
234
+ doc=inspect.getdoc(tool),
235
+ )
236
+
237
+ wrapped.__name__ = tool.__name__
238
+ wrapped._wrapped = True
225
239
 
226
- return wrapper
240
+ return wrapped
227
241
 
228
242
 
229
243
  class BaseIndex:
@@ -1156,7 +1156,7 @@ wheels = [
1156
1156
 
1157
1157
  [[package]]
1158
1158
  name = "langsmith"
1159
- version = "0.3.24"
1159
+ version = "0.3.26"
1160
1160
  source = { registry = "https://pypi.org/simple" }
1161
1161
  dependencies = [
1162
1162
  { name = "httpx" },
@@ -1167,9 +1167,9 @@ dependencies = [
1167
1167
  { name = "requests-toolbelt" },
1168
1168
  { name = "zstandard" },
1169
1169
  ]
1170
- sdist = { url = "https://files.pythonhosted.org/packages/b5/7f/74218413724e8d8783452a45db0e6808f171c91a7ce52f8fa3aefcf96ebf/langsmith-0.3.24.tar.gz", hash = "sha256:ee353dae8e59ec91eee8d3b601bc48e9d0e96722d1af14269b314ecb71e22088", size = 338075 }
1170
+ sdist = { url = "https://files.pythonhosted.org/packages/be/2e/9748883c40e8a3c5d628d5a81a531e1a5ae3a2bfced429ffdf86a437b269/langsmith-0.3.26.tar.gz", hash = "sha256:3bd5b952a5fc82d69b0e2c030e502ee081a8ccf20468e96fd3d53e1572aef6fc", size = 342721 }
1171
1171
  wheels = [
1172
- { url = "https://files.pythonhosted.org/packages/d0/b7/83bdddd466c04f9c5914e5941f2c8180bc2b65c4f78b79f2d9530620a3e7/langsmith-0.3.24-py3-none-any.whl", hash = "sha256:24930d34970281950338f6e2724d04a69804ccb3e89dba9314e6086653dc8bc9", size = 352776 },
1172
+ { url = "https://files.pythonhosted.org/packages/13/14/f2e972ac0cf9b4ff4d405f7843b0f14a1ef686544a54f91ac4d5ac723140/langsmith-0.3.26-py3-none-any.whl", hash = "sha256:3ae49e49d6f3c980a524d15ac2fd895896e709ecedc83ac150c38e1ead776e1b", size = 357325 },
1173
1173
  ]
1174
1174
 
1175
1175
  [[package]]
@@ -1825,7 +1825,7 @@ wheels = [
1825
1825
 
1826
1826
  [[package]]
1827
1827
  name = "openai"
1828
- version = "1.70.0"
1828
+ version = "1.71.0"
1829
1829
  source = { registry = "https://pypi.org/simple" }
1830
1830
  dependencies = [
1831
1831
  { name = "anyio" },
@@ -1837,14 +1837,14 @@ dependencies = [
1837
1837
  { name = "tqdm" },
1838
1838
  { name = "typing-extensions" },
1839
1839
  ]
1840
- sdist = { url = "https://files.pythonhosted.org/packages/87/f5/ae0f3cd226c2993b4ac1cc4b5f6ca099764689f403c14922c9356accec66/openai-1.70.0.tar.gz", hash = "sha256:e52a8d54c3efeb08cf58539b5b21a5abef25368b5432965e4de88cdf4e091b2b", size = 409640 }
1840
+ sdist = { url = "https://files.pythonhosted.org/packages/d9/19/b8f0347090a649dce55a008ec54ac6abb50553a06508cdb5e7abb2813e99/openai-1.71.0.tar.gz", hash = "sha256:52b20bb990a1780f9b0b8ccebac93416343ebd3e4e714e3eff730336833ca207", size = 409926 }
1841
1841
  wheels = [
1842
- { url = "https://files.pythonhosted.org/packages/e2/39/c4b38317d2c702c4bc763957735aaeaf30dfc43b5b824121c49a4ba7ba0f/openai-1.70.0-py3-none-any.whl", hash = "sha256:f6438d053fd8b2e05fd6bef70871e832d9bbdf55e119d0ac5b92726f1ae6f614", size = 599070 },
1842
+ { url = "https://files.pythonhosted.org/packages/c4/f7/049e85faf6a000890e5ca0edca8e9183f8a43c9e7bba869cad871da0caba/openai-1.71.0-py3-none-any.whl", hash = "sha256:e1c643738f1fff1af52bce6ef06a7716c95d089281e7011777179614f32937aa", size = 598975 },
1843
1843
  ]
1844
1844
 
1845
1845
  [[package]]
1846
1846
  name = "openai-agents"
1847
- version = "0.0.8"
1847
+ version = "0.0.9"
1848
1848
  source = { registry = "https://pypi.org/simple" }
1849
1849
  dependencies = [
1850
1850
  { name = "griffe" },
@@ -1855,9 +1855,9 @@ dependencies = [
1855
1855
  { name = "types-requests" },
1856
1856
  { name = "typing-extensions" },
1857
1857
  ]
1858
- sdist = { url = "https://files.pythonhosted.org/packages/23/9b/ad40458b8cf1cd1f6ba8f06859d44351f83e0e38f9bda3c47d0c3d074837/openai_agents-0.0.8.tar.gz", hash = "sha256:65c06d4ae6bfb27da50111df577e7d04ebef667eaac255a6fee5459a7a8692d8", size = 984793 }
1858
+ sdist = { url = "https://files.pythonhosted.org/packages/e3/ec/dc701417f2b58f66e938abb3acd11de39454ac5d3fe3164a05dd9bc0ce92/openai_agents-0.0.9.tar.gz", hash = "sha256:e6923395ae9afd463e6e0c25cbf2b2d42f8fbe5ad79e244aa9c362b62f335981", size = 985467 }
1859
1859
  wheels = [
1860
- { url = "https://files.pythonhosted.org/packages/9a/97/fc19f0839a8c6ceb8b648b47b9e1862c005b444207c728a2e7bcc40db9c2/openai_agents-0.0.8-py3-none-any.whl", hash = "sha256:8e8777a4dd089e0e4d47884e974cad0b7a5f0e8ede633702dd09167ced13aaba", size = 107146 },
1860
+ { url = "https://files.pythonhosted.org/packages/cb/ff/2b378aeb531b1937fe6f98cbdb934155ee185be15455c065dc949ed3e6c1/openai_agents-0.0.9-py3-none-any.whl", hash = "sha256:f4a4798d876db2f47e0cd86791bcdbfc24a37fd20504accde267b682b75d5af7", size = 107300 },
1861
1861
  ]
1862
1862
 
1863
1863
  [[package]]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes