stores 0.0.0__tar.gz → 0.1.0__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 (58) hide show
  1. stores-0.1.0/.gitignore +177 -0
  2. stores-0.1.0/.python-version +1 -0
  3. stores-0.1.0/LICENSE +21 -0
  4. stores-0.1.0/PKG-INFO +85 -0
  5. stores-0.1.0/README.md +50 -0
  6. stores-0.1.0/examples/README.md +75 -0
  7. stores-0.1.0/examples/quickstarts/anthropic_api.py +32 -0
  8. stores-0.1.0/examples/quickstarts/google_gemini_auto_call.py +29 -0
  9. stores-0.1.0/examples/quickstarts/google_gemini_manual_call.py +40 -0
  10. stores-0.1.0/examples/quickstarts/langchain_w_tool_calling.py +26 -0
  11. stores-0.1.0/examples/quickstarts/langgraph_agent.py +31 -0
  12. stores-0.1.0/examples/quickstarts/litellm_w_tool_calling.py +32 -0
  13. stores-0.1.0/examples/quickstarts/llamaindex_agent.py +28 -0
  14. stores-0.1.0/examples/quickstarts/openai_agent.py +33 -0
  15. stores-0.1.0/examples/quickstarts/openai_chat_completions.py +38 -0
  16. stores-0.1.0/examples/quickstarts/openai_responses.py +38 -0
  17. stores-0.1.0/pyproject.toml +53 -0
  18. stores-0.1.0/stores/__init__.py +9 -0
  19. stores-0.1.0/stores/constants.py +2 -0
  20. stores-0.1.0/stores/format.py +214 -0
  21. stores-0.1.0/stores/indexes/__init__.py +11 -0
  22. stores-0.1.0/stores/indexes/base_index.py +269 -0
  23. stores-0.1.0/stores/indexes/index.py +56 -0
  24. stores-0.1.0/stores/indexes/local_index.py +84 -0
  25. stores-0.1.0/stores/indexes/remote_index.py +76 -0
  26. stores-0.1.0/stores/indexes/venv_utils.py +376 -0
  27. stores-0.1.0/stores/parse.py +144 -0
  28. stores-0.1.0/stores/utils.py +8 -0
  29. stores-0.1.0/tests/README.md +6 -0
  30. stores-0.1.0/tests/mock_index/hello/__init__.py +2 -0
  31. stores-0.1.0/tests/mock_index/tools.py +48 -0
  32. stores-0.1.0/tests/mock_index/tools.toml +10 -0
  33. stores-0.1.0/tests/mock_index_custom_class/foo.py +7 -0
  34. stores-0.1.0/tests/mock_index_custom_class/tools.toml +5 -0
  35. stores-0.1.0/tests/mock_index_function_error/foo.py +2 -0
  36. stores-0.1.0/tests/mock_index_function_error/tools.toml +5 -0
  37. stores-0.1.0/tests/mock_index_w_deps/mock_index/__init__.py +57 -0
  38. stores-0.1.0/tests/mock_index_w_deps/pyproject.toml +10 -0
  39. stores-0.1.0/tests/mock_index_w_deps/requirements.txt +1 -0
  40. stores-0.1.0/tests/mock_index_w_deps/tools.toml +14 -0
  41. stores-0.1.0/tests/test_format/conftest.py +176 -0
  42. stores-0.1.0/tests/test_format/test_format.py +237 -0
  43. stores-0.1.0/tests/test_indexes/conftest.py +468 -0
  44. stores-0.1.0/tests/test_indexes/test_base_index.py +199 -0
  45. stores-0.1.0/tests/test_indexes/test_index.py +54 -0
  46. stores-0.1.0/tests/test_indexes/test_local_index.py +66 -0
  47. stores-0.1.0/tests/test_indexes/test_remote_index.py +42 -0
  48. stores-0.1.0/tests/test_indexes/test_venv_utils.py +96 -0
  49. stores-0.1.0/tests/test_parse/conftest.py +60 -0
  50. stores-0.1.0/tests/test_parse/test_parse.py +38 -0
  51. stores-0.1.0/uv.lock +3628 -0
  52. stores-0.0.0/PKG-INFO +0 -19
  53. stores-0.0.0/setup.cfg +0 -4
  54. stores-0.0.0/setup.py +0 -30
  55. stores-0.0.0/stores.egg-info/PKG-INFO +0 -19
  56. stores-0.0.0/stores.egg-info/SOURCES.txt +0 -5
  57. stores-0.0.0/stores.egg-info/dependency_links.txt +0 -1
  58. stores-0.0.0/stores.egg-info/top_level.txt +0 -1
@@ -0,0 +1,177 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
172
+
173
+ # Cloned tools
174
+ .tools/
175
+
176
+ # macOS metadata file
177
+ .DS_Store
@@ -0,0 +1 @@
1
+ 3.10
stores-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Silanthro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
stores-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: stores
3
+ Version: 0.1.0
4
+ Summary: Repository of Python functions and tools for LLMs
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: dirtyjson>=1.0.8
8
+ Requires-Dist: dotenv>=0.9.9
9
+ Requires-Dist: fuzzywuzzy>=0.18.0
10
+ Requires-Dist: gitpython>=3.1.44
11
+ Requires-Dist: makefun>=1.15.6
12
+ Requires-Dist: python-levenshtein>=0.27.1
13
+ Requires-Dist: requests>=2.32.3
14
+ Requires-Dist: tomli>=1.1.0; python_version < '3.11'
15
+ Provides-Extra: anthropic
16
+ Requires-Dist: anthropic>=0.49.0; extra == 'anthropic'
17
+ Provides-Extra: google
18
+ Requires-Dist: google-genai>=1.7.0; extra == 'google'
19
+ Provides-Extra: langchain
20
+ Requires-Dist: langchain-google-genai>=2.1.0; extra == 'langchain'
21
+ Provides-Extra: langgraph
22
+ Requires-Dist: langchain-core>=0.3.45; extra == 'langgraph'
23
+ Requires-Dist: langchain-google-genai>=2.1.0; extra == 'langgraph'
24
+ Requires-Dist: langgraph>=0.3.16; extra == 'langgraph'
25
+ Provides-Extra: litellm
26
+ Requires-Dist: litellm>=1.63.11; extra == 'litellm'
27
+ Provides-Extra: llamaindex
28
+ Requires-Dist: llama-index-llms-google-genai>=0.1.4; extra == 'llamaindex'
29
+ Requires-Dist: llama-index>=0.12.25; extra == 'llamaindex'
30
+ Provides-Extra: openai
31
+ Requires-Dist: openai>=1.66.5; extra == 'openai'
32
+ Provides-Extra: openai-agent
33
+ Requires-Dist: openai-agents>=0.0.7; extra == 'openai-agent'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # stores
37
+
38
+ Repository of Python functions and tools for LLMs
39
+
40
+ ## Why we built Stores
41
+
42
+ Just as tool use is often cited as a key development in human civilization, we believe that tool use represents a major transition in AI development.
43
+
44
+ **The aim of Stores is to make it super simple to build LLM Agents that use tools.**
45
+
46
+ There are two main elements:
47
+ 1. A public repository of [tools](https://stores-tools.vercel.app) that anyone can contribute to
48
+ 2. This Python library that handles tool installation and formatting
49
+
50
+ For more details, check out the [documentation](https://stores-tools.vercel.app/docs).
51
+
52
+ ## Design principles
53
+
54
+ - **Open-source**: Each set of tools in the Stores collection is a public git repository. In the event the Stores database is no longer operational, the library and tools will still work as long as the git repositories exist.
55
+ - **Isolation**: Tools are isolated in their own virtual environments. This makes it trivial to manage tools with conflicting dependencies and reduces unnecessary access to sensitive environment variables.
56
+ - **Framework compatibility**: In order to pass information about tools, LLM providers often require different formats that can make it cumbersome to switch between providers. Stores makes it easy to output the required formats across providers.
57
+
58
+ ## Usage
59
+
60
+ ```sh
61
+ pip install stores
62
+ ```
63
+
64
+ Or if you are using `uv`:
65
+
66
+ ```sh
67
+ uv add stores
68
+ ```
69
+
70
+ Then load one of the available indexes and use it with your favorite LLM package.
71
+
72
+ ```python {6, 11}
73
+ import anthropic
74
+ import stores
75
+
76
+ client = anthropic.Anthropic()
77
+
78
+ index = stores.Index(["silanthro/hackernews"])
79
+
80
+ response = client.messages.create(
81
+ model=model,
82
+ messages=messages,
83
+ tools=index.format_tools("anthropic"),
84
+ )
85
+ ```
stores-0.1.0/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # stores
2
+
3
+ Repository of Python functions and tools for LLMs
4
+
5
+ ## Why we built Stores
6
+
7
+ Just as tool use is often cited as a key development in human civilization, we believe that tool use represents a major transition in AI development.
8
+
9
+ **The aim of Stores is to make it super simple to build LLM Agents that use tools.**
10
+
11
+ There are two main elements:
12
+ 1. A public repository of [tools](https://stores-tools.vercel.app) that anyone can contribute to
13
+ 2. This Python library that handles tool installation and formatting
14
+
15
+ For more details, check out the [documentation](https://stores-tools.vercel.app/docs).
16
+
17
+ ## Design principles
18
+
19
+ - **Open-source**: Each set of tools in the Stores collection is a public git repository. In the event the Stores database is no longer operational, the library and tools will still work as long as the git repositories exist.
20
+ - **Isolation**: Tools are isolated in their own virtual environments. This makes it trivial to manage tools with conflicting dependencies and reduces unnecessary access to sensitive environment variables.
21
+ - **Framework compatibility**: In order to pass information about tools, LLM providers often require different formats that can make it cumbersome to switch between providers. Stores makes it easy to output the required formats across providers.
22
+
23
+ ## Usage
24
+
25
+ ```sh
26
+ pip install stores
27
+ ```
28
+
29
+ Or if you are using `uv`:
30
+
31
+ ```sh
32
+ uv add stores
33
+ ```
34
+
35
+ Then load one of the available indexes and use it with your favorite LLM package.
36
+
37
+ ```python {6, 11}
38
+ import anthropic
39
+ import stores
40
+
41
+ client = anthropic.Anthropic()
42
+
43
+ index = stores.Index(["silanthro/hackernews"])
44
+
45
+ response = client.messages.create(
46
+ model=model,
47
+ messages=messages,
48
+ tools=index.format_tools("anthropic"),
49
+ )
50
+ ```
@@ -0,0 +1,75 @@
1
+ # Examples and Tutorials
2
+
3
+ This directory contains examples and tutorials to help you get started with the `stores` package.
4
+
5
+ ## Tutorials
6
+
7
+ The `tutorials` directory contains example scripts demonstrating how to use Stores with the different LLM providers and frameworks.
8
+
9
+ The example scripts are tool calling or agent workflows to generate a haiku about dreams and email it to a recipient. They leverage the LLM's ability to generate text and call tools (added via Stores) to send the email.
10
+
11
+ | API or Framework | File Name |
12
+ | --------------------------------------------- | ------------------------------ |
13
+ | OpenAI's Chat Completions API | `openai_chat_completions.py` |
14
+ | OpenAI's Response API | `openai_responses.py` |
15
+ | OpenAI's Agents SDK | `openai_agents.py` |
16
+ | Anthropic's Claude API | `anthropic_api.py` |
17
+ | Google Gemini API with automatic tool calling | `google_gemini_auto_call.py` |
18
+ | Google Gemini API with manual tool calling | `google_gemini_manual_call.py` |
19
+ | LangChain with tool calling | `langchain_w_tool_calling.py` |
20
+ | LangGraph agent | `langgraph_agent.py` |
21
+ | LiteLLM with tool calling | `litellm_w_tool_calling.py` |
22
+ | LlamaIndex agent | `llamaindex_agent.py` |
23
+
24
+ ## How to test the tutorials
25
+
26
+ 1. Install the required dependencies for the example you want to run (see Installation section below)
27
+ 2. Add GMAIL_ADDRESS and GMAIL_PASSWORD to your `.env` file (see Environment Variables section below)
28
+ 3. Run `python examples/tutorials/<file_name>.py`
29
+
30
+ ## Installation
31
+
32
+ First, install the package with the optional dependencies you need. The package supports several LLM providers and frameworks:
33
+
34
+ ```bash
35
+ # For Anthropic (Claude)
36
+ pip install -e ".[anthropic]"
37
+
38
+ # For Google (Gemini)
39
+ pip install -e ".[google]"
40
+
41
+ # For OpenAI
42
+ pip install -e ".[openai]"
43
+
44
+ # For OpenAI Agents
45
+ pip install -e ".[openai-agent]"
46
+
47
+ # For LangChain
48
+ pip install -e ".[langchain]"
49
+
50
+ # For LangGraph
51
+ pip install -e ".[langgraph]"
52
+
53
+ # For LiteLLM
54
+ pip install -e ".[litellm]"
55
+
56
+ # For LlamaIndex
57
+ pip install -e ".[llamaindex]"
58
+ ```
59
+
60
+ ## Environment variables
61
+
62
+ The tutorial scripts require the following environment variables:
63
+
64
+ - GMAIL_ADDRESS: The Gmail address for sending emails.
65
+ - GMAIL_PASSWORD: This is NOT your regular Gmail password, but a 16-character App Password created via https://myaccount.google.com/apppasswords (see below). Treat this like you would treat your regular password e.g. do not upload this in plaintext or share this publicly
66
+
67
+ You will also need the API keys for the respective LLM providers that you are using.
68
+
69
+ ### App Passwords
70
+
71
+ In the event that the App Password is no longer required, it can be revoked without affecting your regular password.
72
+
73
+ In order to create a 16-character App Password, 2-Step Verification must be set up.
74
+
75
+ See the Gmail Help article at https://support.google.com/mail/answer/185833?hl=en for detailed instructions.
@@ -0,0 +1,32 @@
1
+ """
2
+ This example shows how to use stores with Anthropic's API.
3
+ """
4
+
5
+ import anthropic
6
+ from dotenv import load_dotenv
7
+
8
+ import stores
9
+
10
+ # Load environment variables
11
+ load_dotenv()
12
+
13
+ # Initialize Anthropic client
14
+ client = anthropic.Anthropic()
15
+
16
+ # Load the Hacker News tool index
17
+ index = stores.Index(["silanthro/hackernews"])
18
+
19
+ # Get the response from the model
20
+ response = client.messages.create(
21
+ model="claude-3-5-sonnet-20241022",
22
+ max_tokens=1024,
23
+ messages=[
24
+ {"role": "user", "content": "What are the top 10 posts on Hacker News today?"}
25
+ ],
26
+ tools=index.format_tools("anthropic"), # Format tools for Anthropic
27
+ )
28
+
29
+ # Execute the tool call
30
+ tool_call = response.content[-1]
31
+ result = index.execute(tool_call.name, tool_call.input)
32
+ print(f"Tool output: {result}")
@@ -0,0 +1,29 @@
1
+ """
2
+ This example shows how to use stores with Google's Gemini API with automatic tool calling.
3
+ """
4
+
5
+ import os
6
+
7
+ from dotenv import load_dotenv
8
+ from google import genai
9
+ from google.genai import types
10
+
11
+ import stores
12
+
13
+ # Load environment variables
14
+ load_dotenv()
15
+
16
+ # Initialize Google Gemini client
17
+ client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
18
+
19
+ # Load the Hacker News tool index
20
+ index = stores.Index(["silanthro/hackernews"])
21
+
22
+ # Initialize the chat with the model
23
+ config = types.GenerateContentConfig(tools=index.tools)
24
+ chat = client.chats.create(model="gemini-2.0-flash", config=config)
25
+
26
+ # Get the response from the model. Gemini will automatically execute tool calls
27
+ # and generate a response.
28
+ response = chat.send_message("What are the top 10 posts on Hacker News today?")
29
+ print(f"Assistant response: {response.candidates[0].content.parts[0].text}")
@@ -0,0 +1,40 @@
1
+ """
2
+ This example shows how to use stores with Google's Gemini API with manual tool calling.
3
+ """
4
+
5
+ import os
6
+
7
+ from dotenv import load_dotenv
8
+ from google import genai
9
+ from google.genai import types
10
+
11
+ import stores
12
+
13
+ # Load environment variables
14
+ load_dotenv()
15
+
16
+ # Initialize Google Gemini client
17
+ client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
18
+
19
+ # Load the Hacker News tool index
20
+ index = stores.Index(["silanthro/hackernews"])
21
+
22
+ # Configure the model with tools
23
+ config = types.GenerateContentConfig(
24
+ tools=index.tools,
25
+ automatic_function_calling=types.AutomaticFunctionCallingConfig(
26
+ disable=True # Disable automatic function calling to manually execute tool calls
27
+ ),
28
+ )
29
+
30
+ # Get the response from the model
31
+ response = client.models.generate_content(
32
+ model="gemini-2.0-flash",
33
+ contents="What are the top 10 posts on Hacker News today?",
34
+ config=config,
35
+ )
36
+
37
+ # Execute the tool call
38
+ tool_call = response.candidates[0].content.parts[0].function_call
39
+ result = index.execute(tool_call.name, tool_call.args)
40
+ print(f"Tool output: {result}")
@@ -0,0 +1,26 @@
1
+ """
2
+ This example shows how to use stores with LangChain with native function calls.
3
+ """
4
+
5
+ from dotenv import load_dotenv
6
+ from langchain_google_genai import ChatGoogleGenerativeAI
7
+
8
+ import stores
9
+
10
+ # Load environment variables
11
+ load_dotenv()
12
+
13
+ # Load the Hacker News tool index
14
+ index = stores.Index(["silanthro/hackernews"])
15
+
16
+ # Initialize the model with tools
17
+ model = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001")
18
+ model_with_tools = model.bind_tools(index.tools)
19
+
20
+ # Get the response from the model
21
+ response = model_with_tools.invoke("What are the top 10 posts on Hacker News today?")
22
+
23
+ # Execute the tool call
24
+ tool_call = response.tool_calls[0]
25
+ result = index.execute(tool_call["name"], tool_call["args"])
26
+ print(f"Tool output: {result}")
@@ -0,0 +1,31 @@
1
+ """
2
+ This example shows how to use stores with LangChain and a LangGraph agent.
3
+ """
4
+
5
+ from dotenv import load_dotenv
6
+ from langchain_core.messages import HumanMessage
7
+ from langchain_google_genai import ChatGoogleGenerativeAI
8
+ from langgraph.prebuilt import create_react_agent
9
+
10
+ import stores
11
+
12
+ # Load environment variables
13
+ load_dotenv()
14
+
15
+ # Load the Hacker News tool index
16
+ index = stores.Index(["silanthro/hackernews"])
17
+
18
+ # Initialize the LangGraph agent
19
+ agent_model = ChatGoogleGenerativeAI(model="gemini-2.0-flash-001")
20
+ agent_executor = create_react_agent(agent_model, index.tools)
21
+
22
+ # Get the response from the agent. The LangGraph agent will automatically execute
23
+ # tool calls and generate a response.
24
+ response = agent_executor.invoke(
25
+ {
26
+ "messages": [
27
+ HumanMessage(content="What are the top 10 posts on Hacker News today?")
28
+ ]
29
+ }
30
+ )
31
+ print(f"Assistant response: {response['messages'][-1].content}")
@@ -0,0 +1,32 @@
1
+ """
2
+ This example shows how to use stores with LiteLLM with native function calls.
3
+ """
4
+
5
+ import json
6
+
7
+ from litellm import completion
8
+
9
+ import stores
10
+
11
+ # Load the Hacker News tool index
12
+ index = stores.Index(["silanthro/hackernews"])
13
+
14
+ # Get the response from the model
15
+ response = completion(
16
+ model="gemini/gemini-2.0-flash-001",
17
+ messages=[
18
+ {
19
+ "role": "user",
20
+ "content": "What are the top 10 posts on Hacker News today?",
21
+ }
22
+ ],
23
+ tools=index.format_tools("google-gemini"), # Format tools for Google Gemini
24
+ )
25
+
26
+ # Execute the tool call
27
+ tool_call = response.choices[0].message.tool_calls[0]
28
+ result = index.execute(
29
+ tool_call.function.name,
30
+ json.loads(tool_call.function.arguments),
31
+ )
32
+ print(f"Tool output: {result}")
@@ -0,0 +1,28 @@
1
+ """
2
+ This example shows how to use stores with a LlamaIndex agent.
3
+ """
4
+
5
+ from dotenv import load_dotenv
6
+ from llama_index.core.agent import AgentRunner
7
+ from llama_index.core.tools import FunctionTool
8
+ from llama_index.llms.google_genai import GoogleGenAI
9
+
10
+ import stores
11
+
12
+ # Load environment variables
13
+ load_dotenv()
14
+
15
+ # Load the Hacker News tool index
16
+ index = stores.Index(["silanthro/hackernews"])
17
+
18
+ # Initialize the LlamaIndex agent with tools
19
+ llm = GoogleGenAI(model="models/gemini-2.0-flash-001")
20
+ tools = [
21
+ FunctionTool.from_defaults(fn=fn) for fn in index.tools
22
+ ] # Use LlamaIndex FunctionTool
23
+ agent = AgentRunner.from_llm(tools, llm=llm, verbose=True)
24
+
25
+ # Get the response from the agent. The LlamaIndex agent will automatically execute
26
+ # tool calls and generate a response.
27
+ response = agent.chat("What are the top 10 posts on Hacker News today?")
28
+ print(f"Assistant response: {response}")
@@ -0,0 +1,33 @@
1
+ """
2
+ This example shows how to use stores with OpenAI's Agent SDK.
3
+ """
4
+
5
+ from agents import Agent, Runner, function_tool
6
+ from dotenv import load_dotenv
7
+
8
+ import stores
9
+
10
+ # Load environment variables
11
+ load_dotenv()
12
+
13
+ # Load the Hacker News tool index
14
+ index = stores.Index(["silanthro/hackernews"])
15
+
16
+ # Set up the tools with Agents SDK's function_tool
17
+ formatted_tools = [
18
+ # OpenAI only supports ^[a-zA-Z0-9_-]{1,64}$
19
+ function_tool(name_override=fn.__name__.replace(".", "_"))(fn)
20
+ for fn in index.tools
21
+ ]
22
+
23
+ # Initialize OpenAI agent
24
+ agent = Agent(
25
+ name="Hacker News Agent",
26
+ model="gpt-4o-mini-2024-07-18",
27
+ tools=formatted_tools,
28
+ )
29
+
30
+ # Get the response from the agent. The OpenAI agent will automatically execute
31
+ # tool calls and generate a response.
32
+ result = Runner.run_sync(agent, "What are the top 10 posts on Hacker News today?")
33
+ print(f"Agent output: {result.final_output}")