-
Notifications
You must be signed in to change notification settings - Fork 0
Replace InspectAI with OpenAI proxy and use vector's proxy #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dac2035
Replace InspectAI with OpenAI SDK via Vector proxy.
lotif 44a6415
Simplify model prompts to plain strings.
lotif c854491
Update model IDs for the Vector proxy and drop api_key_name.
lotif 204a4f6
Merge main and regenerate uv.lock.
lotif cc20028
Updated click v8.2.1 -> v8.4.2
lotif 40625e3
📝 Add docstrings to `replace-inspectai-with-openai-proxy`
coderabbitai[bot] e16b5bd
Revert "📝 Add docstrings to `replace-inspectai-with-openai-proxy`"
lotif 69b8f4b
Address code review feedback on the OpenAI proxy migration.
lotif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Plan: Replace InspectAI with OpenAI SDK via Vector Proxy | ||
|
|
||
| **Date:** 2026-08-10 | ||
| **Branch:** `replace-inspectai-with-openai-proxy` | ||
| **Status:** complete | ||
|
|
||
| ## Goal | ||
|
|
||
| Replace InspectAI-based LLM calls with the official OpenAI SDK, routed through `https://proxy.vectorinstitute.ai/v1`, while keeping multi-provider models and safe concurrent API-key handling. | ||
|
|
||
| ## Decisions (from clarification) | ||
|
|
||
| 1. **Multi-provider:** Keep Gemini/Claude/OpenAI models; the Vector proxy supports all of them via the OpenAI-compatible API. | ||
| 2. **Auth:** Keep the existing pattern of passing `api_key` into call sites (UI/API). Do **not** write keys into process `os.environ` (unsafe under concurrency). Prefer per-call `OpenAI(api_key=..., base_url=...)` clients. | ||
| 3. **Client:** Official `openai` SDK (not `langchain-openai`). | ||
| 4. **Threading:** Remove `ThreadPoolExecutor` unless verification shows Streamlit still requires it. The old thread pool existed for InspectAI + Streamlit main-thread issues. | ||
| 5. **Lockfile:** After `pyproject.toml` dependency changes, regenerate `uv.lock` with `uv` (e.g. `uv lock` / `uv sync`). **Never hand-edit `uv.lock`.** | ||
|
|
||
| ## Steps | ||
|
|
||
| ### 1. Branch | ||
|
|
||
| - Work on `replace-inspectai-with-openai-proxy` (created from `main`). | ||
|
|
||
| ### 2. New LLM client layer (`inferencer.py` core) | ||
|
|
||
| - Add an OpenAI client factory that always creates a **new per-call client**: | ||
| - `OpenAI(api_key=<caller-provided key>, base_url="https://proxy.vectorinstitute.ai/v1")` | ||
| - Never set `os.environ` for keys. | ||
| - Replace InspectAI `Task` / `eval` / `generate` / `model_graded_qa` with `client.chat.completions.create(...)`. | ||
| - Replace InspectAI `Sample` inputs with prompt strings. | ||
| - Keep `ModelInfo` and multi-provider model IDs; send those model IDs to the proxy. | ||
| - Adapt `extract_string_output` to OpenAI response content shapes as needed. | ||
| - Drop `ThreadPoolExecutor` if direct sync OpenAI calls are safe with Streamlit. | ||
|
|
||
| ### 3. Call sites / API surface | ||
|
|
||
| - Update `systematization.py`, API, UI, and helpers for the new sample/client path. | ||
| - Preserve “pass `api_key` into the function” from UI form + API form. | ||
|
|
||
| ### 4. Dependencies | ||
|
|
||
| - Add official `openai` SDK. | ||
| - Remove `inspect-ai`. | ||
| - Remove now-unused provider SDKs only if nothing else imports them after the switch (`anthropic`, `google-genai` are candidates to audit). | ||
| - Regenerate `uv.lock` via `uv` from `pyproject.toml` changes (no manual lock edits). | ||
| - Update CI notes that mention InspectAI (e.g. click pin comment in code checks). | ||
|
|
||
| ### 5. Tests | ||
|
|
||
| - Rewrite tests that mock `inspect_ai_eval` to mock the OpenAI client instead. | ||
| - Remove InspectAI imports from tests. | ||
| - Cover that API keys are passed into the client constructor (not env), so concurrent calls cannot share/override keys. | ||
|
|
||
| ### 6. Docs / misc | ||
|
|
||
| - Light README/CONTRIBUTING updates if they describe InspectAI or key setup incorrectly. | ||
| - Leave `.env` alone (secrets); wire default base URL in code (optional non-secret env override if useful). | ||
|
|
||
| ### 7. Quality gate | ||
|
|
||
| - Coding agent implements + runs project checks/tests. | ||
| - Separate code-review agent reviews. | ||
| - Commit only after a clean review. | ||
| - Verify clean `git status` and summarize. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - No InspectAI proxy workaround. | ||
| - No shared global client / env-based key for request auth. | ||
| - No full project re-spec; this is a `/spec task`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.