reminix-langchain 0.0.5__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,208 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
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
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ !.env.example
140
+ .envrc
141
+ .venv
142
+ env/
143
+ venv/
144
+ ENV/
145
+ env.bak/
146
+ venv.bak/
147
+
148
+ # Spyder project settings
149
+ .spyderproject
150
+ .spyproject
151
+
152
+ # Rope project settings
153
+ .ropeproject
154
+
155
+ # mkdocs documentation
156
+ /site
157
+
158
+ # mypy
159
+ .mypy_cache/
160
+ .dmypy.json
161
+ dmypy.json
162
+
163
+ # Pyre type checker
164
+ .pyre/
165
+
166
+ # pytype static type analyzer
167
+ .pytype/
168
+
169
+ # Cython debug symbols
170
+ cython_debug/
171
+
172
+ # PyCharm
173
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
174
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
175
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
176
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
177
+ #.idea/
178
+
179
+ # Abstra
180
+ # Abstra is an AI-powered process automation framework.
181
+ # Ignore directories containing user credentials, local state, and settings.
182
+ # Learn more at https://abstra.io/docs
183
+ .abstra/
184
+
185
+ # Visual Studio Code
186
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
187
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
188
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
189
+ # you could uncomment the following to ignore the entire vscode folder
190
+ # .vscode/
191
+
192
+ # Ruff stuff:
193
+ .ruff_cache/
194
+
195
+ # PyPI configuration file
196
+ .pypirc
197
+
198
+ # Cursor
199
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
200
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
201
+ # refer to https://docs.cursor.com/context/ignore-files
202
+ .cursorignore
203
+ .cursorindexingignore
204
+
205
+ # Marimo
206
+ marimo/_static/
207
+ marimo/_lsp/
208
+ __marimo__/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: reminix-langchain
3
+ Version: 0.0.5
4
+ Summary: Reminix adapter for LangChain - serve agents as REST APIs
5
+ Project-URL: Homepage, https://reminix.com
6
+ Project-URL: Documentation, https://reminix.com/docs
7
+ Project-URL: Repository, https://github.com/reminix-ai/runtime-python
8
+ Project-URL: Changelog, https://github.com/reminix-ai/runtime-python/blob/main/CHANGELOG.md
9
+ Project-URL: Bug Tracker, https://github.com/reminix-ai/runtime-python/issues
10
+ Author-email: Reminix Team <team@reminix.com>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: agents,ai,langchain,llm,reminix
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: langchain-core>=1.2.0
24
+ Requires-Dist: reminix-runtime~=0.0.5
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # reminix-langchain
31
+
32
+ Reminix Runtime adapter for [LangChain](https://langchain.com). Serve any LangChain runnable as a REST API.
33
+
34
+ > **Ready to go live?** [Deploy to Reminix Cloud](https://reminix.com/docs/deployment) for zero-config hosting, or [self-host](https://reminix.com/docs/deployment/self-hosting) on your own infrastructure.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install reminix-langchain
40
+ ```
41
+
42
+ This will also install `reminix-runtime` as a dependency.
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ from langchain_openai import ChatOpenAI
48
+ from reminix_langchain import wrap_and_serve
49
+
50
+ llm = ChatOpenAI(model="gpt-4o")
51
+ wrap_and_serve(llm, name="my-chatbot", port=8080)
52
+ ```
53
+
54
+ For more flexibility (e.g., serving multiple agents), use `wrap` and `serve` separately:
55
+
56
+ ```python
57
+ from langchain_openai import ChatOpenAI
58
+ from reminix_langchain import wrap
59
+ from reminix_runtime import serve
60
+
61
+ llm = ChatOpenAI(model="gpt-4o")
62
+ agent = wrap(llm, name="my-chatbot")
63
+ serve([agent], port=8080)
64
+ ```
65
+
66
+ Your agent is now available at:
67
+ - `POST /agents/my-chatbot/invoke` - Stateless invocation
68
+ - `POST /agents/my-chatbot/chat` - Conversational chat
69
+
70
+ ## API Reference
71
+
72
+ ### `wrap_and_serve(runnable, name, port, host)`
73
+
74
+ Wrap a LangChain runnable and serve it immediately. Combines `wrap` and `serve` for single-agent setups.
75
+
76
+ | Parameter | Type | Default | Description |
77
+ |-----------|------|---------|-------------|
78
+ | `runnable` | `Runnable` | required | Any LangChain runnable (LLM, chain, agent, etc.) |
79
+ | `name` | `str` | `"langchain-agent"` | Name for the agent (used in URL path) |
80
+ | `port` | `int` | `8080` | Port to serve on |
81
+ | `host` | `str` | `"0.0.0.0"` | Host to bind to |
82
+
83
+ ### `wrap(runnable, name)`
84
+
85
+ Wrap a LangChain runnable for use with Reminix Runtime. Use this with `serve` from `reminix_runtime` for multi-agent setups.
86
+
87
+ | Parameter | Type | Default | Description |
88
+ |-----------|------|---------|-------------|
89
+ | `runnable` | `Runnable` | required | Any LangChain runnable (LLM, chain, agent, etc.) |
90
+ | `name` | `str` | `"langchain-agent"` | Name for the agent (used in URL path) |
91
+
92
+ **Returns:** `LangChainAdapter` - A Reminix adapter instance
93
+
94
+ ### Example with a Chain
95
+
96
+ ```python
97
+ from langchain_openai import ChatOpenAI
98
+ from langchain_core.prompts import ChatPromptTemplate
99
+ from reminix_langchain import wrap
100
+ from reminix_runtime import serve
101
+
102
+ # Create a chain
103
+ prompt = ChatPromptTemplate.from_messages([
104
+ ("system", "You are a helpful assistant."),
105
+ ("human", "{input}")
106
+ ])
107
+ llm = ChatOpenAI(model="gpt-4o")
108
+ chain = prompt | llm
109
+
110
+ # Wrap and serve
111
+ agent = wrap(chain, name="my-chain")
112
+ serve([agent], port=8080)
113
+ ```
114
+
115
+ ## Endpoint Input/Output Formats
116
+
117
+ ### POST /agents/{name}/invoke
118
+
119
+ Stateless invocation for task-oriented operations.
120
+
121
+ **Request:**
122
+ ```json
123
+ {
124
+ "input": {
125
+ "prompt": "Summarize this text: ..."
126
+ }
127
+ }
128
+ ```
129
+
130
+ Or with messages:
131
+ ```json
132
+ {
133
+ "input": {
134
+ "messages": [
135
+ {"role": "user", "content": "Hello!"}
136
+ ]
137
+ }
138
+ }
139
+ ```
140
+
141
+ **Response:**
142
+ ```json
143
+ {
144
+ "output": "Hello! How can I help you today?"
145
+ }
146
+ ```
147
+
148
+ ### POST /agents/{name}/chat
149
+
150
+ Conversational chat with message history.
151
+
152
+ **Request:**
153
+ ```json
154
+ {
155
+ "messages": [
156
+ {"role": "user", "content": "What is the capital of France?"}
157
+ ]
158
+ }
159
+ ```
160
+
161
+ **Response:**
162
+ ```json
163
+ {
164
+ "output": "The capital of France is Paris.",
165
+ "messages": [
166
+ {"role": "user", "content": "What is the capital of France?"},
167
+ {"role": "assistant", "content": "The capital of France is Paris."}
168
+ ]
169
+ }
170
+ ```
171
+
172
+ ## Runtime Documentation
173
+
174
+ For information about the server, endpoints, request/response formats, and more, see the [`reminix-runtime`](https://pypi.org/project/reminix-runtime/) package.
175
+
176
+ ## Deployment
177
+
178
+ Ready to go live?
179
+
180
+ - **[Deploy to Reminix Cloud](https://reminix.com/docs/deployment)** - Zero-config cloud hosting
181
+ - **[Self-host](https://reminix.com/docs/deployment/self-hosting)** - Run on your own infrastructure
182
+
183
+ ## Links
184
+
185
+ - [GitHub Repository](https://github.com/reminix-ai/runtime-python)
186
+ - [LangChain Documentation](https://python.langchain.com)
187
+
188
+ ## License
189
+
190
+ Apache-2.0
@@ -0,0 +1,161 @@
1
+ # reminix-langchain
2
+
3
+ Reminix Runtime adapter for [LangChain](https://langchain.com). Serve any LangChain runnable as a REST API.
4
+
5
+ > **Ready to go live?** [Deploy to Reminix Cloud](https://reminix.com/docs/deployment) for zero-config hosting, or [self-host](https://reminix.com/docs/deployment/self-hosting) on your own infrastructure.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install reminix-langchain
11
+ ```
12
+
13
+ This will also install `reminix-runtime` as a dependency.
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ from langchain_openai import ChatOpenAI
19
+ from reminix_langchain import wrap_and_serve
20
+
21
+ llm = ChatOpenAI(model="gpt-4o")
22
+ wrap_and_serve(llm, name="my-chatbot", port=8080)
23
+ ```
24
+
25
+ For more flexibility (e.g., serving multiple agents), use `wrap` and `serve` separately:
26
+
27
+ ```python
28
+ from langchain_openai import ChatOpenAI
29
+ from reminix_langchain import wrap
30
+ from reminix_runtime import serve
31
+
32
+ llm = ChatOpenAI(model="gpt-4o")
33
+ agent = wrap(llm, name="my-chatbot")
34
+ serve([agent], port=8080)
35
+ ```
36
+
37
+ Your agent is now available at:
38
+ - `POST /agents/my-chatbot/invoke` - Stateless invocation
39
+ - `POST /agents/my-chatbot/chat` - Conversational chat
40
+
41
+ ## API Reference
42
+
43
+ ### `wrap_and_serve(runnable, name, port, host)`
44
+
45
+ Wrap a LangChain runnable and serve it immediately. Combines `wrap` and `serve` for single-agent setups.
46
+
47
+ | Parameter | Type | Default | Description |
48
+ |-----------|------|---------|-------------|
49
+ | `runnable` | `Runnable` | required | Any LangChain runnable (LLM, chain, agent, etc.) |
50
+ | `name` | `str` | `"langchain-agent"` | Name for the agent (used in URL path) |
51
+ | `port` | `int` | `8080` | Port to serve on |
52
+ | `host` | `str` | `"0.0.0.0"` | Host to bind to |
53
+
54
+ ### `wrap(runnable, name)`
55
+
56
+ Wrap a LangChain runnable for use with Reminix Runtime. Use this with `serve` from `reminix_runtime` for multi-agent setups.
57
+
58
+ | Parameter | Type | Default | Description |
59
+ |-----------|------|---------|-------------|
60
+ | `runnable` | `Runnable` | required | Any LangChain runnable (LLM, chain, agent, etc.) |
61
+ | `name` | `str` | `"langchain-agent"` | Name for the agent (used in URL path) |
62
+
63
+ **Returns:** `LangChainAdapter` - A Reminix adapter instance
64
+
65
+ ### Example with a Chain
66
+
67
+ ```python
68
+ from langchain_openai import ChatOpenAI
69
+ from langchain_core.prompts import ChatPromptTemplate
70
+ from reminix_langchain import wrap
71
+ from reminix_runtime import serve
72
+
73
+ # Create a chain
74
+ prompt = ChatPromptTemplate.from_messages([
75
+ ("system", "You are a helpful assistant."),
76
+ ("human", "{input}")
77
+ ])
78
+ llm = ChatOpenAI(model="gpt-4o")
79
+ chain = prompt | llm
80
+
81
+ # Wrap and serve
82
+ agent = wrap(chain, name="my-chain")
83
+ serve([agent], port=8080)
84
+ ```
85
+
86
+ ## Endpoint Input/Output Formats
87
+
88
+ ### POST /agents/{name}/invoke
89
+
90
+ Stateless invocation for task-oriented operations.
91
+
92
+ **Request:**
93
+ ```json
94
+ {
95
+ "input": {
96
+ "prompt": "Summarize this text: ..."
97
+ }
98
+ }
99
+ ```
100
+
101
+ Or with messages:
102
+ ```json
103
+ {
104
+ "input": {
105
+ "messages": [
106
+ {"role": "user", "content": "Hello!"}
107
+ ]
108
+ }
109
+ }
110
+ ```
111
+
112
+ **Response:**
113
+ ```json
114
+ {
115
+ "output": "Hello! How can I help you today?"
116
+ }
117
+ ```
118
+
119
+ ### POST /agents/{name}/chat
120
+
121
+ Conversational chat with message history.
122
+
123
+ **Request:**
124
+ ```json
125
+ {
126
+ "messages": [
127
+ {"role": "user", "content": "What is the capital of France?"}
128
+ ]
129
+ }
130
+ ```
131
+
132
+ **Response:**
133
+ ```json
134
+ {
135
+ "output": "The capital of France is Paris.",
136
+ "messages": [
137
+ {"role": "user", "content": "What is the capital of France?"},
138
+ {"role": "assistant", "content": "The capital of France is Paris."}
139
+ ]
140
+ }
141
+ ```
142
+
143
+ ## Runtime Documentation
144
+
145
+ For information about the server, endpoints, request/response formats, and more, see the [`reminix-runtime`](https://pypi.org/project/reminix-runtime/) package.
146
+
147
+ ## Deployment
148
+
149
+ Ready to go live?
150
+
151
+ - **[Deploy to Reminix Cloud](https://reminix.com/docs/deployment)** - Zero-config cloud hosting
152
+ - **[Self-host](https://reminix.com/docs/deployment/self-hosting)** - Run on your own infrastructure
153
+
154
+ ## Links
155
+
156
+ - [GitHub Repository](https://github.com/reminix-ai/runtime-python)
157
+ - [LangChain Documentation](https://python.langchain.com)
158
+
159
+ ## License
160
+
161
+ Apache-2.0
@@ -0,0 +1,52 @@
1
+ [project]
2
+ name = "reminix-langchain"
3
+ version = "0.0.5"
4
+ description = "Reminix adapter for LangChain - serve agents as REST APIs"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ requires-python = ">=3.10"
8
+ authors = [{ name = "Reminix Team", email = "team@reminix.com" }]
9
+ keywords = ["ai", "agents", "langchain", "llm", "reminix"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: Apache Software License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
19
+ ]
20
+ dependencies = [
21
+ "reminix-runtime~=0.0.5",
22
+ "langchain-core>=1.2.0",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://reminix.com"
27
+ Documentation = "https://reminix.com/docs"
28
+ Repository = "https://github.com/reminix-ai/runtime-python"
29
+ Changelog = "https://github.com/reminix-ai/runtime-python/blob/main/CHANGELOG.md"
30
+ "Bug Tracker" = "https://github.com/reminix-ai/runtime-python/issues"
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest>=8.0.0",
35
+ "pytest-asyncio>=0.24.0",
36
+ ]
37
+
38
+ [tool.pytest.ini_options]
39
+ asyncio_mode = "auto"
40
+ testpaths = ["tests"]
41
+ python_files = ["test_*.py"]
42
+ python_functions = ["test_*"]
43
+
44
+ [build-system]
45
+ requires = ["hatchling"]
46
+ build-backend = "hatchling.build"
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/reminix_langchain"]
50
+
51
+ [tool.uv.sources]
52
+ reminix-runtime = { workspace = true }
@@ -0,0 +1,3 @@
1
+ from .adapter import LangChainAdapter, wrap, wrap_and_serve
2
+
3
+ __all__ = ["LangChainAdapter", "wrap", "wrap_and_serve"]
@@ -0,0 +1,265 @@
1
+ """LangChain adapter for Reminix Runtime."""
2
+
3
+ import json
4
+ from collections.abc import AsyncIterator
5
+ from typing import Any
6
+
7
+ from langchain_core.messages import (
8
+ AIMessage,
9
+ AIMessageChunk,
10
+ BaseMessage,
11
+ HumanMessage,
12
+ SystemMessage,
13
+ ToolMessage,
14
+ )
15
+ from langchain_core.runnables import Runnable
16
+
17
+ from reminix_runtime import (
18
+ BaseAdapter,
19
+ ChatRequest,
20
+ ChatResponse,
21
+ InvokeRequest,
22
+ InvokeResponse,
23
+ Message,
24
+ serve,
25
+ )
26
+
27
+
28
+ class LangChainAdapter(BaseAdapter):
29
+ """Adapter for LangChain agents and runnables."""
30
+
31
+ adapter_name = "langchain"
32
+
33
+ def __init__(self, agent: Runnable, name: str = "langchain-agent") -> None:
34
+ """Initialize the adapter.
35
+
36
+ Args:
37
+ agent: A LangChain runnable (e.g., ChatModel, chain, agent).
38
+ name: Name for the agent.
39
+ """
40
+ self._agent = agent
41
+ self._name = name
42
+
43
+ @property
44
+ def name(self) -> str:
45
+ return self._name
46
+
47
+ def _to_langchain_message(self, message: Message) -> BaseMessage:
48
+ """Convert a Reminix message to a LangChain message."""
49
+ role = message.role
50
+ content = message.content or ""
51
+
52
+ if role == "user":
53
+ return HumanMessage(content=content)
54
+ elif role == "assistant":
55
+ return AIMessage(content=content)
56
+ elif role == "system":
57
+ return SystemMessage(content=content)
58
+ elif role == "tool":
59
+ # Tool messages require a tool_call_id
60
+ tool_call_id = getattr(message, "tool_call_id", None) or "unknown"
61
+ return ToolMessage(content=content, tool_call_id=tool_call_id)
62
+ else:
63
+ # Fallback to HumanMessage for unknown roles
64
+ return HumanMessage(content=content)
65
+
66
+ def _to_reminix_message(self, message: BaseMessage) -> dict[str, Any]:
67
+ """Convert a LangChain message to a Reminix message dict."""
68
+ if isinstance(message, HumanMessage):
69
+ role = "user"
70
+ elif isinstance(message, AIMessage):
71
+ role = "assistant"
72
+ elif isinstance(message, SystemMessage):
73
+ role = "system"
74
+ elif isinstance(message, ToolMessage):
75
+ role = "tool"
76
+ else:
77
+ role = "assistant"
78
+
79
+ content = message.content if isinstance(message.content, str) else str(message.content)
80
+ return {"role": role, "content": content}
81
+
82
+ async def invoke(self, request: InvokeRequest) -> InvokeResponse:
83
+ """Handle an invoke request.
84
+
85
+ For task-oriented operations. Expects input with 'messages' key
86
+ or a 'prompt' key for simple text generation.
87
+
88
+ Args:
89
+ request: The invoke request with input data.
90
+
91
+ Returns:
92
+ The invoke response with the output.
93
+ """
94
+ # Build input for the runnable
95
+ if "messages" in request.input:
96
+ # Convert message dicts to LangChain messages
97
+ lc_messages = []
98
+ for m in request.input["messages"]:
99
+ msg = Message(role=m.get("role", "user"), content=m.get("content", ""))
100
+ lc_messages.append(self._to_langchain_message(msg))
101
+ invoke_input = lc_messages
102
+ elif "prompt" in request.input:
103
+ invoke_input = request.input["prompt"]
104
+ else:
105
+ # Pass input directly to the runnable
106
+ invoke_input = request.input
107
+
108
+ response = await self._agent.ainvoke(invoke_input)
109
+
110
+ # Extract output from response
111
+ if isinstance(response, BaseMessage):
112
+ output = (
113
+ response.content if isinstance(response.content, str) else str(response.content)
114
+ )
115
+ elif isinstance(response, dict):
116
+ output = response
117
+ else:
118
+ output = str(response)
119
+
120
+ return InvokeResponse(output=output)
121
+
122
+ async def chat(self, request: ChatRequest) -> ChatResponse:
123
+ """Handle a chat request.
124
+
125
+ For conversational interactions. Converts messages to LangChain format.
126
+
127
+ Args:
128
+ request: The chat request with messages.
129
+
130
+ Returns:
131
+ The chat response with output and messages.
132
+ """
133
+ # Convert messages to LangChain format
134
+ lc_messages = [self._to_langchain_message(m) for m in request.messages]
135
+
136
+ # Call the runnable
137
+ response = await self._agent.ainvoke(lc_messages)
138
+
139
+ # Extract content from response
140
+ if isinstance(response, BaseMessage):
141
+ content = (
142
+ response.content if isinstance(response.content, str) else str(response.content)
143
+ )
144
+ response_message = self._to_reminix_message(response)
145
+ else:
146
+ content = str(response)
147
+ response_message = {"role": "assistant", "content": content}
148
+
149
+ # Build response messages (original + assistant response)
150
+ response_messages: list[dict[str, Any]] = [
151
+ {"role": m.role, "content": m.content} for m in request.messages
152
+ ]
153
+ response_messages.append(response_message)
154
+
155
+ return ChatResponse(output=content, messages=response_messages)
156
+
157
+ async def invoke_stream(self, request: InvokeRequest) -> AsyncIterator[str]:
158
+ """Handle a streaming invoke request.
159
+
160
+ Streams chunks from the LangChain runnable.
161
+
162
+ Args:
163
+ request: The invoke request with input data.
164
+
165
+ Yields:
166
+ JSON-encoded chunks from the stream.
167
+ """
168
+ # Build input for the runnable
169
+ if "messages" in request.input:
170
+ # Convert message dicts to LangChain messages
171
+ lc_messages = []
172
+ for m in request.input["messages"]:
173
+ msg = Message(role=m.get("role", "user"), content=m.get("content", ""))
174
+ lc_messages.append(self._to_langchain_message(msg))
175
+ stream_input = lc_messages
176
+ elif "prompt" in request.input:
177
+ stream_input = request.input["prompt"]
178
+ else:
179
+ stream_input = request.input
180
+
181
+ async for chunk in self._agent.astream(stream_input):
182
+ if isinstance(chunk, BaseMessage):
183
+ content = chunk.content if isinstance(chunk.content, str) else str(chunk.content)
184
+ elif isinstance(chunk, dict):
185
+ content = json.dumps(chunk)
186
+ else:
187
+ content = str(chunk)
188
+ yield json.dumps({"chunk": content})
189
+
190
+ async def chat_stream(self, request: ChatRequest) -> AsyncIterator[str]:
191
+ """Handle a streaming chat request.
192
+
193
+ Streams chunks from the LangChain runnable.
194
+
195
+ Args:
196
+ request: The chat request with messages.
197
+
198
+ Yields:
199
+ JSON-encoded chunks from the stream.
200
+ """
201
+ # Convert messages to LangChain format
202
+ lc_messages = [self._to_langchain_message(m) for m in request.messages]
203
+
204
+ # Stream from the runnable
205
+ async for chunk in self._agent.astream(lc_messages):
206
+ if isinstance(chunk, (BaseMessage, AIMessageChunk)):
207
+ content = chunk.content if isinstance(chunk.content, str) else str(chunk.content)
208
+ elif isinstance(chunk, dict):
209
+ content = json.dumps(chunk)
210
+ else:
211
+ content = str(chunk)
212
+ yield json.dumps({"chunk": content})
213
+
214
+
215
+ def wrap(agent: Runnable, name: str = "langchain-agent") -> LangChainAdapter:
216
+ """Wrap a LangChain agent for use with Reminix Runtime.
217
+
218
+ Args:
219
+ agent: A LangChain runnable (e.g., ChatModel, chain, agent).
220
+ name: Name for the agent.
221
+
222
+ Returns:
223
+ A LangChainAdapter instance.
224
+
225
+ Example:
226
+ ```python
227
+ from langchain_openai import ChatOpenAI
228
+ from reminix_langchain import wrap
229
+ from reminix_runtime import serve
230
+
231
+ llm = ChatOpenAI(model="gpt-4")
232
+ agent = wrap(llm, name="my-agent")
233
+ serve([agent], port=8080)
234
+ ```
235
+ """
236
+ return LangChainAdapter(agent, name=name)
237
+
238
+
239
+ def wrap_and_serve(
240
+ agent: Runnable,
241
+ name: str = "langchain-agent",
242
+ port: int = 8080,
243
+ host: str = "0.0.0.0",
244
+ ) -> None:
245
+ """Wrap a LangChain runnable and serve it immediately.
246
+
247
+ This is a convenience function that combines `wrap` and `serve` for single-agent setups.
248
+
249
+ Args:
250
+ agent: A LangChain runnable (e.g., ChatModel, chain, agent).
251
+ name: Name for the agent.
252
+ port: Port to serve on.
253
+ host: Host to bind to.
254
+
255
+ Example:
256
+ ```python
257
+ from langchain_openai import ChatOpenAI
258
+ from reminix_langchain import wrap_and_serve
259
+
260
+ llm = ChatOpenAI(model="gpt-4")
261
+ wrap_and_serve(llm, name="my-agent", port=8080)
262
+ ```
263
+ """
264
+ wrapped_agent = wrap(agent, name=name)
265
+ serve([wrapped_agent], port=port, host=host)
File without changes
@@ -0,0 +1 @@
1
+ """Tests for reminix-langchain."""
@@ -0,0 +1,207 @@
1
+ """Tests for the LangChain adapter."""
2
+
3
+ from unittest.mock import AsyncMock, MagicMock, patch
4
+
5
+ import pytest
6
+ from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
7
+ from langchain_core.runnables import Runnable
8
+
9
+ from reminix_langchain import LangChainAdapter, wrap, wrap_and_serve
10
+ from reminix_runtime import BaseAdapter, ChatRequest, InvokeRequest
11
+
12
+
13
+ class TestWrap:
14
+ """Tests for the wrap() function."""
15
+
16
+ def test_wrap_returns_adapter(self):
17
+ """wrap() should return a LangChainAdapter."""
18
+ mock_runnable = MagicMock(spec=Runnable)
19
+ adapter = wrap(mock_runnable)
20
+
21
+ assert isinstance(adapter, LangChainAdapter)
22
+ assert isinstance(adapter, BaseAdapter)
23
+
24
+ def test_wrap_with_custom_name(self):
25
+ """wrap() should accept a custom name."""
26
+ mock_runnable = MagicMock(spec=Runnable)
27
+ adapter = wrap(mock_runnable, name="my-custom-agent")
28
+
29
+ assert adapter.name == "my-custom-agent"
30
+
31
+ def test_wrap_default_name(self):
32
+ """wrap() should use default name if not provided."""
33
+ mock_runnable = MagicMock(spec=Runnable)
34
+ adapter = wrap(mock_runnable)
35
+
36
+ assert adapter.name == "langchain-agent"
37
+
38
+
39
+ class TestLangChainAdapterInvoke:
40
+ """Tests for the invoke() method."""
41
+
42
+ @pytest.mark.asyncio
43
+ async def test_invoke_calls_runnable(self):
44
+ """invoke() should call the underlying runnable with the input."""
45
+ mock_runnable = MagicMock(spec=Runnable)
46
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Hello!"))
47
+
48
+ adapter = wrap(mock_runnable)
49
+ request = InvokeRequest(input={"query": "What is AI?"})
50
+
51
+ response = await adapter.invoke(request)
52
+
53
+ mock_runnable.ainvoke.assert_called_once_with({"query": "What is AI?"})
54
+
55
+ @pytest.mark.asyncio
56
+ async def test_invoke_returns_output(self):
57
+ """invoke() should return the output from the runnable."""
58
+ mock_runnable = MagicMock(spec=Runnable)
59
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Hello from LangChain!"))
60
+
61
+ adapter = wrap(mock_runnable)
62
+ request = InvokeRequest(input={"query": "Hi"})
63
+
64
+ response = await adapter.invoke(request)
65
+
66
+ assert response.output == "Hello from LangChain!"
67
+
68
+ @pytest.mark.asyncio
69
+ async def test_invoke_handles_dict_response(self):
70
+ """invoke() should handle dict responses from the runnable."""
71
+ mock_runnable = MagicMock(spec=Runnable)
72
+ mock_runnable.ainvoke = AsyncMock(return_value={"result": "success", "value": 42})
73
+
74
+ adapter = wrap(mock_runnable)
75
+ request = InvokeRequest(input={"task": "compute"})
76
+
77
+ response = await adapter.invoke(request)
78
+
79
+ assert response.output == {"result": "success", "value": 42}
80
+
81
+ @pytest.mark.asyncio
82
+ async def test_invoke_handles_string_response(self):
83
+ """invoke() should handle string responses from the runnable."""
84
+ mock_runnable = MagicMock(spec=Runnable)
85
+ mock_runnable.ainvoke = AsyncMock(return_value="Simple string result")
86
+
87
+ adapter = wrap(mock_runnable)
88
+ request = InvokeRequest(input={"query": "test"})
89
+
90
+ response = await adapter.invoke(request)
91
+
92
+ assert response.output == "Simple string result"
93
+
94
+
95
+ class TestLangChainAdapterChat:
96
+ """Tests for the chat() method."""
97
+
98
+ @pytest.mark.asyncio
99
+ async def test_chat_calls_runnable(self):
100
+ """chat() should call the underlying runnable with converted messages."""
101
+ mock_runnable = MagicMock(spec=Runnable)
102
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Hello!"))
103
+
104
+ adapter = wrap(mock_runnable)
105
+ request = ChatRequest(messages=[{"role": "user", "content": "Hi"}])
106
+
107
+ response = await adapter.chat(request)
108
+
109
+ mock_runnable.ainvoke.assert_called_once()
110
+
111
+ @pytest.mark.asyncio
112
+ async def test_chat_converts_messages_to_langchain_format(self):
113
+ """chat() should convert Reminix messages to LangChain format."""
114
+ mock_runnable = MagicMock(spec=Runnable)
115
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Response"))
116
+
117
+ adapter = wrap(mock_runnable)
118
+ request = ChatRequest(
119
+ messages=[
120
+ {"role": "system", "content": "You are helpful"},
121
+ {"role": "user", "content": "Hello"},
122
+ {"role": "assistant", "content": "Hi there"},
123
+ {"role": "user", "content": "How are you?"},
124
+ ]
125
+ )
126
+
127
+ await adapter.chat(request)
128
+
129
+ # Check that messages were converted correctly
130
+ call_args = mock_runnable.ainvoke.call_args[0][0]
131
+ assert len(call_args) == 4
132
+ assert isinstance(call_args[0], SystemMessage)
133
+ assert isinstance(call_args[1], HumanMessage)
134
+ assert isinstance(call_args[2], AIMessage)
135
+ assert isinstance(call_args[3], HumanMessage)
136
+
137
+ @pytest.mark.asyncio
138
+ async def test_chat_returns_output_and_messages(self):
139
+ """chat() should return output and messages."""
140
+ mock_runnable = MagicMock(spec=Runnable)
141
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Chat response"))
142
+
143
+ adapter = wrap(mock_runnable)
144
+ request = ChatRequest(messages=[{"role": "user", "content": "Hi"}])
145
+
146
+ response = await adapter.chat(request)
147
+
148
+ assert response.output == "Chat response"
149
+ assert len(response.messages) == 2
150
+ assert response.messages[-1]["role"] == "assistant"
151
+ assert response.messages[-1]["content"] == "Chat response"
152
+
153
+
154
+ class TestMessageConversion:
155
+ """Tests for message format conversion."""
156
+
157
+ @pytest.mark.asyncio
158
+ async def test_tool_role_handled(self):
159
+ """Tool role messages should be handled appropriately."""
160
+ mock_runnable = MagicMock(spec=Runnable)
161
+ mock_runnable.ainvoke = AsyncMock(return_value=AIMessage(content="Response"))
162
+
163
+ adapter = wrap(mock_runnable)
164
+ request = ChatRequest(
165
+ messages=[
166
+ {"role": "user", "content": "Use a tool"},
167
+ {"role": "tool", "content": "Tool result"},
168
+ ]
169
+ )
170
+
171
+ # Should not raise an error
172
+ response = await adapter.chat(request)
173
+ assert response.output == "Response"
174
+
175
+
176
+ class TestWrapAndServe:
177
+ """Tests for the wrap_and_serve() function."""
178
+
179
+ def test_wrap_and_serve_is_callable(self):
180
+ """wrap_and_serve() should be callable."""
181
+ assert callable(wrap_and_serve)
182
+
183
+ @patch("reminix_langchain.adapter.serve")
184
+ def test_wrap_and_serve_calls_serve(self, mock_serve):
185
+ """wrap_and_serve() should call serve with wrapped adapter."""
186
+ mock_runnable = MagicMock(spec=Runnable)
187
+
188
+ wrap_and_serve(mock_runnable, name="test-agent")
189
+
190
+ mock_serve.assert_called_once()
191
+ call_args = mock_serve.call_args
192
+ agents = call_args[0][0]
193
+ assert len(agents) == 1
194
+ assert isinstance(agents[0], LangChainAdapter)
195
+ assert agents[0].name == "test-agent"
196
+
197
+ @patch("reminix_langchain.adapter.serve")
198
+ def test_wrap_and_serve_passes_serve_options(self, mock_serve):
199
+ """wrap_and_serve() should pass port and host to serve."""
200
+ mock_runnable = MagicMock(spec=Runnable)
201
+
202
+ wrap_and_serve(mock_runnable, name="test-agent", port=3000, host="localhost")
203
+
204
+ mock_serve.assert_called_once()
205
+ call_kwargs = mock_serve.call_args[1]
206
+ assert call_kwargs["port"] == 3000
207
+ assert call_kwargs["host"] == "localhost"