Python bindings for the intent-verification Rust library.
- Install maturin:
pip install maturin- Build and install the package in development mode:
maturin developOr build for release:
maturin build --releasepip install -r requirements-dev.txtfrom intent_verification_py import verify_intent_py
result = verify_intent_py(
test_repo_url="https://github.com/example/test-repo",
test_commit="abc123",
solution_repo_url="https://github.com/example/solution-repo",
solution_commit1="def456",
solution_commit2="ghi789",
user_intent="I want to ensure the tests work correctly",
api_key="your-openai-api-key",
base_url=None, # Optional
model=None, # Optional, e.g., "gpt-4"
)
print(f"Intent fulfilled: {result['is_intent_fulfilled']}")
print(f"Confidence: {result['confidence']:.2f}")
print(f"Explanation: {result['explanation']}")- Set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"- Build the package:
maturin develop- Run the tests:
pytest test_intent_verification.py -v -sOr run all tests:
pytest -v -s-v: Verbose output-s: Show print statements-k test_name: Run specific test by name--tb=short: Short traceback format
Example:
pytest test_intent_verification.py -v -s -k test_verify_intent_basicThe verify_intent_py function returns a dictionary with the following structure:
{
"is_intent_fulfilled": bool, # Whether the intent was fulfilled
"confidence": float, # Confidence score (0.0 to 1.0)
"explanation": str, # Explanation of the result
"overall_assessment": str, # Overall assessment text
"files_analyzed": [ # List of analyzed files
{
"file_path": str, # Path to the file
"change_type": str, # Type of change (e.g., "Modified")
"supports_intent": bool, # Whether this file supports the intent
"reasoning": str, # Reasoning for the assessment
"relevant_changes": [str] # List of relevant changes
}
]
}Same as the intent-verification Rust library.