Python wrapper for Q Developer CLI
Project description
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
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 q_developer_wrapper-0.0.1.tar.gz.
File metadata
- Download URL: q_developer_wrapper-0.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac61bd34ed3acffbe158b73734e29060e039e6d41ad95d52f8bd244cf704b24a
|
|
| MD5 |
f6a4ca93eadfa23dd07f4821ed38772c
|
|
| BLAKE2b-256 |
70826bea98b4f43e0a95f7946c6e3a65d6416685d0d49e4c70c76d0761cba2b2
|
File details
Details for the file q_developer_wrapper-0.0.1-py3-none-any.whl.
File metadata
- Download URL: q_developer_wrapper-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77585f55e5c3ae3f4a74184e5a2b38fe508de8fa41e94e34b768bed5a9e6304b
|
|
| MD5 |
0c74aba7c0d3ec700fd6c75edc75cdcf
|
|
| BLAKE2b-256 |
36292ee187be78965d9c5b637688796b307466b3a107f4261ad56b18874d2203
|