Human-in-the-loop LangChain integration for CodeVF
Project description
LangChain Human In The Loop (CodeVF)
Minimal LangChain tool integration for routing review, debugging, and verification requests to CodeVF using the official Python SDK.
Quick Start
- Install
pip install langchain-human-in-the-loop
Dependencies (codevf-sdk, langchain-core, pydantic) are installed automatically.
- Set your API key
export CODEVF_API_KEY="cvf_live_..."
- Run a direct review (no agent needed)
from langchain_human_in_the_loop import HumanInTheLoop
hitl = HumanInTheLoop(
api_key="CODEVF_API_KEY",
project_id=123,
max_credits=50,
mode="fast",
timeout=300,
)
result = hitl.invoke(
"Review this function for security issues and suggest fixes.",
attachments=[
{
"file_name": "app.py",
"mime_type": "text/x-python",
"content": "def login(user, pwd): ...",
}
],
)
print(result)
Install page:
https://pypi.org/project/langchain-human-in-the-loop/
Install From Source
pip install -e .
Usage
Attachment Format
Each attachment accepts either content (plain text) or base64 (for binary files). The SDK enforces limits and supported file types.
Example: Multiple Files
from langchain_human_in_the_loop import HumanInTheLoop
hitl = HumanInTheLoop(project_id=123, max_credits=50)
result = hitl.invoke(
"Find concurrency bugs and propose fixes.",
attachments=[
{
"file_name": "worker.py",
"mime_type": "text/x-python",
"content": "def run(queue): ...",
},
{
"file_name": "README.md",
"mime_type": "text/plain",
"content": "# Worker\n\nHow it is supposed to work...",
},
],
)
print(result)
Example: Binary Attachment (Base64)
import base64
from langchain_human_in_the_loop import HumanInTheLoop
with open("diagram.png", "rb") as f:
encoded = base64.b64encode(f.read()).decode("ascii")
hitl = HumanInTheLoop(project_id=123, max_credits=50)
result = hitl.invoke(
"Review the architecture diagram for missing components.",
attachments=[
{
"file_name": "diagram.png",
"mime_type": "image/png",
"base64": encoded,
}
],
)
print(result)
LangChain Tool Helper
You can expose CodeVF as a LangChain structured tool via:
from langchain_human_in_the_loop import HumanInTheLoop, HumanInTheLoopInput
hitl = HumanInTheLoop(project_id=123)
codevf_tool = hitl.as_langchain_tool()
# Optional: use the tool input schema for structured calls
schema = HumanInTheLoopInput.schema()
See examples/human_in_the_loop.py for a complete runnable snippet.
If you want to test CodeVF with LangChain, use examples/codevf_tool_agent.py.
Research / University Samples
examples/reproducibility_audit.pyreviews an ML experiment for reproducibility gaps.examples/data_privacy_review.pychecks a student-data pipeline for privacy and policy risks.examples/paper_review.pyreviews methods/results for missing baselines and reporting issues.examples/irb_protocol_review.pyreviews a study protocol, consent, and survey for IRB gaps.examples/bias_fairness_audit.pyaudits an admissions model for sampling bias and fairness risk.examples/replication_package_review.pychecks a replication package for release readiness.
Testing
pip install -e .[dev]
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_human_in_the_loop-0.2.0.tar.gz.
File metadata
- Download URL: langchain_human_in_the_loop-0.2.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4de5ce879f5abc92a1b1c9779cd2dc45e954e43d6f54edb0d833efd9d7a420b
|
|
| MD5 |
d5fbb99172de0d3af0982122f3acd052
|
|
| BLAKE2b-256 |
182e67bb4cb7acb294e1f7cbfc414e0911b1fa5d6befb03a8e1138d1a1bd62c8
|
File details
Details for the file langchain_human_in_the_loop-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_human_in_the_loop-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6265d9249baa877c209f552cf937d5e85968f963634204b0194e718bc0125976
|
|
| MD5 |
f57c140c1cb416deb85ad2d5541182c2
|
|
| BLAKE2b-256 |
ab2afcc8c0e0bd00cf1e1502fabf1c3e627b9425c07e5ee4727d351ad38b25cb
|