rosa-llm 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.
rosa_llm-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,459 @@
1
+ Metadata-Version: 2.4
2
+ Name: rosa-llm
3
+ Version: 0.1.0
4
+ Summary: Standalone Ollama and ChatGPT OAuth clients with a shared Python API and CLI
5
+ Author: levii831
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Dist: httpx>=0.28.1
9
+ Requires-Dist: pyjwt[crypto]>=2.15.1
10
+ Requires-Dist: python-dotenv>=1.2.4
11
+ Requires-Dist: langchain-core==0.3.86 ; extra == 'langchain'
12
+ Requires-Python: >=3.11
13
+ Project-URL: Repository, https://github.com/Lelevinson/rosa-llm-package
14
+ Project-URL: Issues, https://github.com/Lelevinson/rosa-llm-package/issues
15
+ Provides-Extra: langchain
16
+ Description-Content-Type: text/markdown
17
+
18
+ # rosa-llm
19
+
20
+ **OpenAI through ChatGPT OAuth and local Ollama, behind one Python interface.**
21
+
22
+ Use it as a standalone client or supply `ChatRosaLLM` to LangChain and ROSA.
23
+ The package handles model communication; your application executes tools and
24
+ owns its agent logic, experiment design, and outcome checks.
25
+
26
+ **v0.1.0** · **Python ≥3.11** · **[Apache-2.0](LICENSE)**
27
+
28
+ [Install](#install) · [Provider setup](#provider-setup) · [Python API](#python-api) ·
29
+ [LangChain and ROSA](#langchain-and-rosa) · [Docker](#docker) ·
30
+ [Configuration](#configuration) · [Troubleshooting](#troubleshooting)
31
+
32
+ | Use case | What you need |
33
+ | --- | --- |
34
+ | Standalone client | Python and a configured provider; ROS and LangChain are optional |
35
+ | OpenAI | Your own ChatGPT account with eligible model access and plan-use permission; no OpenAI API key |
36
+ | Ollama | A reachable server and an already installed model |
37
+ | LangChain / ROSA | The `langchain` extra and your existing agent/ROS environment |
38
+
39
+ ## Install
40
+
41
+ ### In an existing uv project
42
+
43
+ For the base client:
44
+
45
+ ```bash
46
+ uv add "rosa-llm==0.1.0"
47
+ ```
48
+
49
+ For LangChain or ROSA, use this dependency instead:
50
+
51
+ ```bash
52
+ uv add "rosa-llm[langchain]==0.1.0"
53
+ ```
54
+
55
+ These commands install the [PyPI release](https://pypi.org/project/rosa-llm/0.1.0/).
56
+ `uv add` updates the consuming project's dependencies and lockfile; `==0.1.0`
57
+ selects this exact version. No PyPI or GitHub sign-in is required to install it.
58
+ If your project already declares this dependency, use its `uv sync --locked`;
59
+ a separate package clone is unnecessary.
60
+
61
+ Version 0.1.0 renumbers the initial release with the same runtime code previously
62
+ published as 0.2.0. That earlier upload remains available. Use the explicit pin
63
+ above: an unpinned install can select 0.2.0 because it sorts higher.
64
+
65
+ > **Python compatibility:** the base package and adapter require ≥3.11 and have
66
+ > been tested on 3.11 and 3.12 under Linux/WSL x86_64. This checkout and Docker use 3.12.
67
+ > Use Python 3.12 for the installed ROS 2 Jazzy bindings; the package does not
68
+ > install ROS. See [verified versions and limits](docs/python-compatibility.md).
69
+
70
+ <details>
71
+ <summary>Pinning a research dependency or keeping a Python ≥3.9 project</summary>
72
+
73
+ To install directly from Git instead of PyPI, use the release tag:
74
+
75
+ ```bash
76
+ uv add "rosa-llm[langchain] @ git+https://github.com/Lelevinson/rosa-llm-package.git@v0.1.0"
77
+ ```
78
+
79
+ A tag installation records its resolved commit in `uv.lock`. Use the full commit
80
+ SHA instead of the tag in the Git URL when an immutable source reference is required.
81
+
82
+ uv checks the consumer's declared Python range, not just its active interpreter.
83
+ For a project that retains ≥3.9 support, a conditional dependency can omit this
84
+ adapter on Python 3.9/3.10:
85
+
86
+ ```bash
87
+ uv add --marker "python_version >= '3.11'" \
88
+ "rosa-llm[langchain]==0.1.0"
89
+ ```
90
+
91
+ `--marker` makes the dependency conditional. Older interpreters will not receive
92
+ the adapter. Existing ROS bindings and dependency groups may require a newer
93
+ Python version independently. Lowering this package's minimum alone does not
94
+ resolve every consumer's compatibility constraints.
95
+
96
+ </details>
97
+
98
+ ### Run the CLI from a checkout
99
+
100
+ With Git, Python 3.12, and [uv](https://docs.astral.sh/uv/getting-started/installation/)
101
+ available, run in your Linux or WSL terminal:
102
+
103
+ ```bash
104
+ git clone https://github.com/Lelevinson/rosa-llm-package.git
105
+ cd rosa-llm-package
106
+ uv sync --locked
107
+ uv run rosa-llm init
108
+ ```
109
+
110
+ `git clone` downloads the project; `cd` enters it. `uv sync --locked` installs the
111
+ locked environment in `.venv`; `uv run` executes a command there. `init` creates
112
+ `.env` and refuses to overwrite it. Skip `init` if you already have configuration.
113
+ See [uv's sync behavior](https://docs.astral.sh/uv/concepts/projects/sync/).
114
+
115
+ ## Provider setup
116
+
117
+ Choose a provider below. `YOUR_OLLAMA_MODEL` and `YOUR_OPENAI_MODEL` are
118
+ placeholders: replace them with names returned by the relevant catalog command.
119
+
120
+ ### Ollama
121
+
122
+ **1. Configure the server address** in your local `.env`:
123
+
124
+ ```dotenv
125
+ LLM_PROVIDER=ollama
126
+ OLLAMA_BASE_URL=http://localhost:11434
127
+ ```
128
+
129
+ In WSL, a Windows-hosted server may need the Windows host address instead.
130
+ Use the address reachable from your own machine; the client does not switch
131
+ endpoints, start servers, or download models.
132
+
133
+ **2. Discover a model and make a request:**
134
+
135
+ ```bash
136
+ uv run rosa-llm models --provider ollama --json
137
+ uv run rosa-llm ask "Say hello" --provider ollama --model YOUR_OLLAMA_MODEL --json
138
+ ```
139
+
140
+ Save that model as `OLLAMA_MODEL` in `.env` to avoid repeating `--model`.
141
+ Tool use requires a tool-capable model.
142
+
143
+ ### OpenAI — Sign in with ChatGPT
144
+
145
+ **1. Authorize your own account:**
146
+
147
+ ```bash
148
+ uv run rosa-llm login --provider openai
149
+ uv run rosa-llm status --provider openai --json
150
+ ```
151
+
152
+ Login opens a browser and listens on `127.0.0.1:1455/auth/callback`.
153
+ Identity login and plan-use permission are separate; inference needs both.
154
+ `status` reads local state and does not confirm current remote access.
155
+
156
+ **2. Discover a model, then request it explicitly:**
157
+
158
+ ```bash
159
+ ROSA_LLM_REQUIRE_EXPLICIT_MODEL=false uv run rosa-llm models --provider openai --json
160
+ uv run rosa-llm ask "Say hello" --provider openai --model YOUR_OPENAI_MODEL --json
161
+ ```
162
+
163
+ The assignment before `models` disables the explicit-model guard for that command
164
+ only, allowing discovery before a model is configured. It does not change `.env`.
165
+ `--provider` and `--model` override configuration for one command.
166
+
167
+ **3. Save your selection** in `.env`:
168
+
169
+ ```dotenv
170
+ LLM_PROVIDER=openai
171
+ OPENAI_MODEL=YOUR_OPENAI_MODEL
172
+ ROSA_LLM_REQUIRE_EXPLICIT_MODEL=true
173
+ ```
174
+
175
+ Credentials are saved outside the repository. Each teammate signs in separately;
176
+ GitHub access does not provide model access. An OpenAI API key is not used here.
177
+
178
+ <details>
179
+ <summary>Browser forwarding, profiles, consent, and logout</summary>
180
+
181
+ - **No browser window?** Run `uv run rosa-llm login --no-browser` and open the
182
+ printed authorization URL on the browser host while login remains running.
183
+ Keep the URL private; do not paste callback URLs into chat.
184
+ - **WSL:** Windows-to-WSL localhost forwarding must reach the listener. Keep the
185
+ callback host as `127.0.0.1`; do not replace it with `localhost` or expose it
186
+ publicly. `--port 0` selects a free loopback port.
187
+ - **Existing SSH access:** on the browser host, run
188
+ `ssh -N -L 1455:127.0.0.1:1455 user@your-linux-host`, then run login on that
189
+ Linux host with `--no-browser --port 1455`. `-N` runs only forwarding; `-L`
190
+ forwards the local port to the remote loopback listener. SSH setup is external.
191
+ - **Separate accounts/workspaces:** use `--profile lab` on login and subsequent
192
+ commands, or set `ROSA_LLM_PROFILE=lab`. Labels accept letters, digits, `_`,
193
+ and `-`. Returning logins reuse the registration and verify its subject.
194
+ - **Missing plan permission:** `uv run rosa-llm login --consent` requests consent
195
+ again. A new identity-only registration retains inference-disabled state;
196
+ failed login does not replace an existing valid session.
197
+ - **Sign out:** `uv run rosa-llm logout --json` attempts remote revocation and
198
+ clears the selected profile's tokens, retaining its registration and host ID.
199
+ If revocation cannot be confirmed, disconnect the app in ChatGPT Settings.
200
+
201
+ </details>
202
+
203
+ ## Python API
204
+
205
+ The base API needs no ROS, LangChain, database, or agent runtime:
206
+
207
+ ```python
208
+ from rosa_llm import create_client
209
+
210
+ with create_client() as client:
211
+ response = client.generate("Explain a ROS 2 node briefly.")
212
+ print(response.text)
213
+ print(response.model, response.usage)
214
+ ```
215
+
216
+ `create_client()` loads configuration from the calling directory. For explicit
217
+ settings, pass `Config(...)`, or use `create_client(env_file="path/to/.env")`.
218
+ Keep client use inside `with` so its HTTP resources close afterward.
219
+
220
+ | Interface | Contract |
221
+ | --- | --- |
222
+ | `client.generate(prompt)` | Returns a validated completed `Response`; partial output is not returned as success |
223
+ | `client.generate(messages)` | Uses explicit history; retain `response.message` to preserve native reasoning and tool-call items |
224
+ | `client.stream(prompt)` | Yields text events and a final completed response; exhaust or close the iterator and handle `LLMError` |
225
+ | `Tool(...)` / `response.tool_calls` | Declares tools and receives requests; your code validates arguments and executes them |
226
+ | `create_client(observer=callback)` | Captures request records; the application owns thread-safe, durable storage and task scoring |
227
+
228
+ Plain text history is portable across providers; opaque provider history is not.
229
+ OpenAI maps system instructions to developer messages. Ollama accepts system
230
+ messages and rejects developer messages. Tool arguments are complete only after
231
+ provider completion; do not execute partial streamed arguments.
232
+
233
+ Recipes: [chat/history](examples/chat.py) · [native tool loop](examples/tool_call.py) ·
234
+ [request recording and timing](docs/experiment-recording.md).
235
+
236
+ ## LangChain and ROSA
237
+
238
+ Install with `[langchain]` as shown above. In this checkout, enable the extra with
239
+ `uv sync --locked --extra langchain`; it pins `langchain-core==0.3.86`.
240
+
241
+ ```python
242
+ from rosa_llm import create_client
243
+ from rosa_llm.langchain import ChatRosaLLM
244
+
245
+ with create_client() as client:
246
+ model = ChatRosaLLM(client=client)
247
+ print(model.invoke("Say hello").content)
248
+ ```
249
+
250
+ Use ordinary LangChain tools through `model.bind_tools(...)` or an agent's normal
251
+ model interface. LangChain/your application executes tools; this adapter does not.
252
+ Keep the client open until all agent calls finish.
253
+
254
+ <details>
255
+ <summary>Pass the same adapter to an existing ROSA application</summary>
256
+
257
+ Install ROSA separately and source your ROS environment first. The package's
258
+ Docker image does not supply ROS. With those dependencies available:
259
+
260
+ ```python
261
+ from rosa import ROSA
262
+ from rosa_llm import create_client
263
+ from rosa_llm.langchain import ChatRosaLLM
264
+
265
+ with create_client() as client:
266
+ model = ChatRosaLLM(client=client)
267
+ agent = ROSA(ros_version=2, llm=model, streaming=False)
268
+ print(agent.invoke("List the current ROS 2 nodes."))
269
+ ```
270
+
271
+ The model adapter is infrastructure. Your research code still owns policies,
272
+ tool permissions, observations, experimental conditions, and outcome validation.
273
+
274
+ </details>
275
+
276
+ | Capability | OpenAI ChatGPT OAuth | Ollama |
277
+ | --- | --- | --- |
278
+ | Text/history and streamed text | Supported | Supported |
279
+ | JSON function tools | Supported; native API wraps tools in namespaces | Supported; JSON-object arguments |
280
+ | Custom text tools | Native API only | Unsupported |
281
+ | LangChain tools | Text/function-tool contract | Text/function-tool contract |
282
+ | Per-call options | `tool_choice` (`auto`, `none`, `required`), `parallel_tool_calls` | `options`, `think`, `format`, `keep_alive` |
283
+ | Async | LangChain worker-thread interface; base client uses synchronous HTTP | Same |
284
+
285
+ Unsupported options fail explicitly. Do not assume temperature/seed controls,
286
+ strict schemas, hosted tools, images/files, or arbitrary OpenAI parameters are
287
+ portable across providers. There are no constructor-level decoding defaults on
288
+ `ChatRosaLLM` in v0.1.0; supplying per-call options and retaining them through an
289
+ agent's tool-binding step is the caller's responsibility.
290
+
291
+ See [integration examples](docs/langchain-integration.md),
292
+ [custom LangChain tools](examples/langchain_tools.py), and the
293
+ [compatibility report](docs/langchain-compatibility.md) for exact supported scope.
294
+
295
+ ## Docker
296
+
297
+ **Status:** Dockerfiles/Compose configuration are provided. Image build, runtime,
298
+ and credential persistence have not been live-verified in this environment.
299
+ See [verification limits](docs/hardening-report.md).
300
+
301
+ The image is a standalone Python 3.12 client, not a complete ROS/Jazzy environment.
302
+ For an existing ROS container, install the Git dependency into that application's
303
+ environment. This image defaults to the base client; build with
304
+ `--build-arg INSTALL_LANGCHAIN=true` to include the optional adapter.
305
+
306
+ Create a local `.env` from `.env.example` if one does not already exist, then:
307
+
308
+ ```bash
309
+ docker compose build
310
+ docker compose run --rm rosa-llm models --provider ollama --json
311
+ docker compose run --rm rosa-llm ask "Say hello" --provider ollama --model YOUR_OLLAMA_MODEL --json
312
+ ```
313
+
314
+ `build` creates the image. `run --rm` removes the command container when it exits;
315
+ the named credential volume persists. Compose loads `.env`.
316
+
317
+ | Setting | Container behavior |
318
+ | --- | --- |
319
+ | Ollama endpoint | `DOCKER_OLLAMA_BASE_URL`, default `http://host.docker.internal:11434`; server must listen on a reachable interface |
320
+ | Credential directory | `/home/app/.config/rosa-llm`, persisted in the `auth` named volume |
321
+ | Runtime user | Non-root UID 10001; bind-mounted credential directories must be owned by that UID and mode 700 |
322
+
323
+ ### OAuth login in Docker
324
+
325
+ On native Linux, or Docker Desktop with [host networking enabled](https://docs.docker.com/engine/network/drivers/host/):
326
+
327
+ ```bash
328
+ docker compose -f compose.yaml -f compose.login.yaml run --rm rosa-llm login --no-browser
329
+ docker compose run --rm -e ROSA_LLM_REQUIRE_EXPLICIT_MODEL=false rosa-llm models --provider openai --json
330
+ docker compose run --rm rosa-llm ask "Say hello" --provider openai --model YOUR_OPENAI_MODEL --json
331
+ ```
332
+
333
+ `-f` selects Compose files; the later file overrides the earlier one. `-e` sets
334
+ an environment variable inside that command's container. Open the printed URL in the browser on that host while login waits. The listener remains
335
+ on loopback. Bridge networking and publishing a port do not make a listener bound
336
+ to the container's `127.0.0.1` reachable from the host. The project does not enable
337
+ host networking or change host firewalls/Ollama bindings for you.
338
+
339
+ If host networking is unavailable, use an existing SSH tunnel, or complete WSL
340
+ login and securely move **your own** credential/host-identity directory into your
341
+ private volume with the correct ownership. Move the runtime identity together;
342
+ do not operate concurrent independent copies. Never share credential volumes
343
+ between teammates. Use the same Compose project/volume across commands, and avoid
344
+ `docker compose down -v` unless credential deletion is intentional (`-v` deletes
345
+ named volumes). Native Windows Python is outside this release's tested scope.
346
+
347
+ ## Configuration
348
+
349
+ Edit the `.env` in the directory from which your application runs. No tokens or
350
+ API keys belong in this file.
351
+
352
+ | Variable | Default | Purpose |
353
+ | --- | --- | --- |
354
+ | `LLM_PROVIDER` | `ollama` | `ollama` or `openai` |
355
+ | `OLLAMA_MODEL` | `qwen3:8b` | Installed model name |
356
+ | `OLLAMA_BASE_URL` | `http://localhost:11434` | Endpoint reachable from this process |
357
+ | `OPENAI_MODEL` | Empty | Account-visible model name; empty otherwise selects the first visible catalog entry on each request |
358
+ | `ROSA_LLM_REQUIRE_EXPLICIT_MODEL` | `false` | Set `true` for controlled OpenAI runs to reject missing model selection |
359
+ | `ROSA_LLM_PROFILE` | `default` | Saved OAuth registration label |
360
+ | `ROSA_LLM_AUTH_DIR` | User configuration directory | Credential/host storage outside the repository; empty uses the default |
361
+ | `ROSA_LLM_TIMEOUT` | `120` | HTTP phase timeout in seconds, not a total trial deadline |
362
+
363
+ **Precedence, highest first:** process environment → local `.env` → user
364
+ `config.env` → defaults. The user directory is `$XDG_CONFIG_HOME/rosa-llm`, normally
365
+ `~/.config/rosa-llm`. `uv run rosa-llm init --user` creates its `config.env`.
366
+ The loader does not change process environment or expand `${...}` in dotenv values.
367
+ For reproducible runs, select a named model rather than relying on catalog order.
368
+
369
+ ## CLI reference
370
+
371
+ All options follow the subcommand; for example, `uv run rosa-llm ask --help`.
372
+
373
+ | Command | What it does |
374
+ | --- | --- |
375
+ | `init` | Creates configuration without overwriting an existing file |
376
+ | `login` / `logout` | Signs in / clears the selected profile's tokens, attempting remote revocation |
377
+ | `status --json` | Reads local authentication state; does not contact OpenAI |
378
+ | `models --json` | Queries the selected provider's model catalog |
379
+ | `ask "prompt" --json` | Performs real inference; JSON includes provider/model, text, tool calls, usage, and available metadata |
380
+ | `ask "prompt" --stream` | Prints text deltas; incompatible with `--json` |
381
+ | `test --json` | Makes one real request and checks an exact short marker |
382
+ | `test --tool --json` | Checks one harmless echo tool round trip, arguments, and final marker; at most two model requests |
383
+
384
+ Common overrides: `--provider`, `--model`, `--profile`, `--env-file PATH`.
385
+ Diagnostics go to stderr. JSON-mode failures emit an `error` object and exit 1.
386
+ Inference never opens a login prompt or automatically retries/falls back.
387
+ Partial streaming output is not proof of success; check the exit status.
388
+
389
+ ## Credentials and transport
390
+
391
+ - Default storage: `~/.config/rosa-llm/credentials.json` and `host.json`.
392
+ Profiles belong to this package; it does not reuse Codex credentials.
393
+ Files are plaintext protected by OS permissions, not encrypted.
394
+ - Storage directories use mode 700; credential, host, temporary, and lock files
395
+ use mode 600. Refreshes atomically rotate tokens under a Linux process lock.
396
+ Local filesystems are required; NFS/distributed locking is outside scope.
397
+ - Expired tokens renew automatically when possible. Revoked sessions need login
398
+ again; temporary network failures preserve credentials. Keep credentials and
399
+ authorization URLs private. Never put GitHub/model tokens in Git URLs or logs.
400
+ - Redirects and environment proxy variables are disabled on internally created
401
+ HTTP clients; TLS verification stays enabled. Do not enable HTTP wire/debug
402
+ logging around OAuth, because it can expose secrets.
403
+
404
+ ## Troubleshooting
405
+
406
+ | Symptom | First check |
407
+ | --- | --- |
408
+ | Ollama connection refused | Verify the server, installed model, and endpoint from this WSL/container; localhost may address the wrong machine |
409
+ | Browser callback fails | Keep login running; check WSL forwarding or Docker host networking and port conflicts |
410
+ | Logged in, inference disabled | Check plan eligibility/permission; use `login --consent` to request permission again |
411
+ | OpenAI model unavailable | Refresh the catalog using the command in [OpenAI setup](#openai--sign-in-with-chatgpt); select a listed model |
412
+ | Explicit-model error during discovery | Prefix the catalog command with `ROSA_LLM_REQUIRE_EXPLICIT_MODEL=false`; keep inference guard enabled afterward |
413
+ | Usage limit or provider unavailable | Review [ChatGPT Usage](https://chatgpt.com/settings/usage); stop or defer requests rather than bypassing limits |
414
+ | Credential permission error | Check user ownership, file mode 600, directory mode 700, and Docker UID 10001 |
415
+ | Stream ends with an error | Record failure even if text was already printed; `generate()` does not return that partial result as completed |
416
+ | Unsupported option/tool/message | Check the [compatibility contract](docs/langchain-compatibility.md); capabilities differ by provider |
417
+
418
+ ## Development and reference
419
+
420
+ ```bash
421
+ uv sync --locked --extra langchain
422
+ uv run --locked pytest -q
423
+ uv run --locked ruff check .
424
+ uv run --locked ruff format --check .
425
+ uv build
426
+ ```
427
+
428
+ `pytest -q` runs automated tests with concise output; it does not authorize accounts
429
+ or run live model requests. Third-party pytest plugin auto-loading is disabled.
430
+ Optional ROSA executor checks also need the `integration` group and sourced Jazzy;
431
+ see the [integration guide](docs/langchain-integration.md).
432
+ `ruff check` checks code; `format --check` checks formatting without editing.
433
+ `uv build` creates a wheel and source distribution under `dist/`.
434
+
435
+ | Reference | Contents |
436
+ | --- | --- |
437
+ | [LangChain / ROSA](docs/langchain-integration.md) | Optional installation, agent examples, ROS environment requirements |
438
+ | [Compatibility](docs/langchain-compatibility.md) | Tool/message contracts, supported interfaces, provider restrictions |
439
+ | [Experiment recording](docs/experiment-recording.md) | Native records, timing definitions, provenance, runner responsibilities |
440
+ | [Python support](docs/python-compatibility.md) | Tested versions, wheel checks, dependency-resolution boundaries |
441
+ | [Protocol](docs/protocol.md) | Official OAuth/protocol sources |
442
+ | [Publishing](docs/publishing.md) | Maintainer setup, dry runs, and PyPI Trusted Publishing |
443
+ | [Hardening](docs/hardening-report.md) / [validation](docs/validation.md) | Dated evidence and remaining manual checks |
444
+
445
+ <details>
446
+ <summary>Source layout</summary>
447
+
448
+ | Module | Responsibility |
449
+ | --- | --- |
450
+ | `client.py`, `types.py` | Shared client API and message/tool/response types |
451
+ | `providers.py`, `http.py` | Provider wire formats, stream parsing, safe error classification |
452
+ | `auth.py`, `storage.py` | OAuth, token validation/refresh, protected credential storage |
453
+ | `config.py`, `cli.py` | Configuration precedence and command-line interface |
454
+ | `langchain.py`, `provenance.py` | Optional model adapter and package/source identity |
455
+
456
+ Runtime dependencies are `httpx`, `python-dotenv`, and `PyJWT[crypto]`.
457
+ Development uses pytest and Ruff; `uv_build` builds the package.
458
+
459
+ </details>