Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@ MIT License - see [LICENSE](LICENSE) file for details.
1. Run `python examples/simple_test.py` to try it out
2. Read [docs/QUICKSTART.md](docs/QUICKSTART.md) for more details
3. Check [examples/](examples/) folder for more use cases
hello
12 changes: 3 additions & 9 deletions examples/async_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async def create_and_track_session(client, prompt, source):
"""Create a session and track it to completion."""
print(f"\nCreating session: {prompt[:50]}...")

session = await client.sessions.create(
prompt=prompt, source=source, starting_branch="main"
)
session = await client.sessions.create(prompt=prompt, source=source, starting_branch="main")

print(f"Session created: {session.id}")

Expand Down Expand Up @@ -70,12 +68,8 @@ async def main():
# Example 2: Multiple concurrent sessions
print("\n=== Example 2: Concurrent Sessions ===")
tasks = [
create_and_track_session(
client, "Improve database query performance", source_id
),
create_and_track_session(
client, "Add unit tests for authentication module", source_id
),
create_and_track_session(client, "Improve database query performance", source_id),
create_and_track_session(client, "Add unit tests for authentication module", source_id),
create_and_track_session(
client, "Update documentation with latest API changes", source_id
),
Expand Down
9 changes: 6 additions & 3 deletions examples/interactive_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def demo_sessions(client, sources):
prompt="Add comprehensive unit tests for the authentication module with edge cases",
source=source.name,
starting_branch=branch,
title="Unit Tests - Authentication Module"
title="Unit Tests - Authentication Module",
)

print(f"✅ Session created!")
Expand Down Expand Up @@ -232,7 +232,8 @@ def demo_advanced_features(client):

def main():
"""Run the interactive demo."""
print("""
print(
"""
╔══════════════════════════════════════════════════════════╗
║ ║
║ JULES AGENT SDK - INTERACTIVE DEMO ║
Expand All @@ -241,7 +242,8 @@ def main():
║ actual API credentials. ║
║ ║
╚══════════════════════════════════════════════════════════╝
""")
"""
)

with JulesClient(api_key=API_KEY) as client:
try:
Expand Down Expand Up @@ -270,6 +272,7 @@ def main():
except Exception as e:
print(f"\n❌ Error: {e}")
import traceback

traceback.print_exc()


Expand Down
7 changes: 5 additions & 2 deletions examples/simple_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def main():
if source.github_repo:
print(f" {i}. {source.github_repo.owner}/{source.github_repo.repo}")
print(f" Source ID: {source.id}")
print(f" Default branch: {source.github_repo.default_branch.display_name if source.github_repo.default_branch else 'N/A'}")
print(
f" Default branch: {source.github_repo.default_branch.display_name if source.github_repo.default_branch else 'N/A'}"
)
print()

# 2. Create a session
Expand All @@ -44,7 +46,7 @@ def main():
prompt="Add comprehensive error handling and logging to all API endpoints",
source=source.name,
starting_branch=branch,
title="API Enhancement - Error Handling & Logging"
title="API Enhancement - Error Handling & Logging",
)

print("✅ Session created successfully!")
Expand Down Expand Up @@ -84,6 +86,7 @@ def main():
except Exception as e:
print(f"❌ Error: {e}")
import traceback

traceback.print_exc()


Expand Down
12 changes: 3 additions & 9 deletions src/jules_agent_sdk/async_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def __init__(self, api_key: str, base_url: Optional[str] = None) -> None:
async def _get_session(self) -> aiohttp.ClientSession:
"""Get or create the aiohttp session."""
if self._session is None or self._session.closed:
self._session = aiohttp.ClientSession(
headers={"X-Goog-Api-Key": self.api_key}
)
self._session = aiohttp.ClientSession(headers={"X-Goog-Api-Key": self.api_key})
return self._session

async def _handle_error(self, response: aiohttp.ClientResponse) -> None:
Expand Down Expand Up @@ -94,9 +92,7 @@ async def _request(
session = await self._get_session()
url = f"{self.base_url}/{path.lstrip('/')}"

async with session.request(
method=method, url=url, params=params, json=json
) as response:
async with session.request(method=method, url=url, params=params, json=json) as response:
if not response.ok:
await self._handle_error(response)

Expand All @@ -105,9 +101,7 @@ async def _request(

return await response.json()

async def get(
self, path: str, params: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
async def get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
"""Make an async GET request.

Args:
Expand Down
10 changes: 6 additions & 4 deletions src/jules_agent_sdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ def __init__(

# Create session with connection pooling
self.session = requests.Session()
self.session.headers.update({
"X-Goog-Api-Key": self.api_key,
"User-Agent": "jules-agent-sdk/0.1.0 (Python)",
})
self.session.headers.update(
{
"X-Goog-Api-Key": self.api_key,
"User-Agent": "jules-agent-sdk/0.1.0 (Python)",
}
)

# Configure connection pool
adapter = requests.adapters.HTTPAdapter(
Expand Down
4 changes: 1 addition & 3 deletions src/jules_agent_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ def from_dict(cls, data: Dict[str, Any]) -> "Plan":
if data.get("steps"):
steps = [PlanStep.from_dict(s) for s in data["steps"]]

return cls(
id=data.get("id", ""), steps=steps, create_time=data.get("createTime", "")
)
return cls(id=data.get("id", ""), steps=steps, create_time=data.get("createTime", ""))

def to_dict(self) -> Dict[str, Any]:
"""Convert to API request dictionary."""
Expand Down