Q Developer Wrapper for Python
A Python wrapper for interacting with the Q Developer CLI.
Installation
From Source
Clone the repository and install the package:
git clone [repository-url]
cd q-developer-wrapper/python
pip install -e .
Usage
Basic Examples
import asyncio
from q_developer_wrapper import QDeveloperWrapper, QRequest, QResponse
async def simple_example():
# Initialize wrapper with default 'q' CLI path
q = QDeveloperWrapper()
# Check if Q CLI is available
if not await q.is_available():
print("Q Developer CLI is not available")
return
# Simple chat without tools
try:
response = await q.chat("What is the capital of France?")
print(f"Response: {response}")
except Exception as e:
print(f"Error: {e}")
# Execute with tools enabled
try:
response = await q.execute("Show me the weather in Paris")
print(f"Response: {response}")
except Exception as e:
print(f"Error: {e}")
# Run the example
asyncio.run(simple_example())
Advanced Configuration
import asyncio
from q_developer_wrapper import QDeveloperWrapper, QRequest
async def advanced_example():
# Use a custom path to the Q CLI executable
q = QDeveloperWrapper(q_cli_path="/usr/local/bin/q")
# Create a custom request
request = QRequest(
message="Write a Python class to manage user data",
accept_all_tools=True,
timeout=180000 # 3 minutes timeout
)
# Send the request
response = await q.ask(request)
if response.success:
print(f"Q Developer Response:\n{response.content}")
else:
print(f"Error: {response.error}")
asyncio.run(advanced_example())
API Reference
QRequest
@dataclass
class QRequest:
message: str # The message to send to Q Developer
accept_all_tools: bool = False # Whether to accept all tools
timeout: int = 120000 # Timeout in milliseconds (default: 2 minutes)
QResponse
@dataclass
class QResponse:
success: bool # Whether the request was successful
content: str # The response content
error: Optional[str] = None # Error message if any
QDeveloperWrapper
class QDeveloperWrapper:
def __init__(self, q_cli_path: str = 'q')
async def ask(self, request: QRequest) -> QResponse:
# Send a request to Q Developer and get response
async def chat(self, message: str) -> str:
# Quick helper - ask without tools
async def execute(self, message: str) -> str:
# Quick helper - ask with tools enabled
async def is_available(self) -> bool:
# Check if Q CLI is available
Requirements
- Python 3.7+
- Q Developer CLI installed and accessible in PATH
Differences from TypeScript Implementation
The Python implementation offers the same functionality as the TypeScript version with these implementation differences:
- Uses Python's
asynciofor asynchronous operations instead of JavaScript Promises - Uses Python dataclasses instead of TypeScript interfaces
- The Python version handles subprocess management using
asyncio.create_subprocess_exec - Error handling and timeout mechanisms are adapted to Python's async patterns
Metadata
Release files for q-developer-wrapper 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| q_developer_wrapper-0.0.2.tar.gz | 4.7 kB | Without provenance | Details for q_developer_wrapper-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| q_developer_wrapper-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for q_developer_wrapper-0.0.2-py3-none-any.whl |
Total release size: 10.2 kB
Release files / q_developer_wrapper-0.0.2.tar.gz
| Download URL | q_developer_wrapper-0.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03c06bdc4907e869bb9d257cd662b46111c129bf0612f2e1118d1e04b89d0826
|
|
BLAKE2b-256 checksum How to use checksums |
f956644eb745c89d3e6ef026851770a150cc1ec1760787f4a6bb054798850f2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / q_developer_wrapper-0.0.2-py3-none-any.whl
| Download URL | q_developer_wrapper-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
915ddc8a8d3439194d5acf2c913305564924588cd02e144c1d6e11148e6a91d3
|
|
BLAKE2b-256 checksum How to use checksums |
b0ae70da6bbb54c9c2735799ad76c1ae24dfc56229c47017212e3f0cef874b8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for q-developer-wrapper 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.