Skip to content
Merged
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
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
name: Format & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install linters
run: pip install black flake8

- name: black
run: black --check governs_ai/ tests/

- name: flake8
run: flake8 governs_ai/ tests/ --max-line-length=88 --extend-ignore=E203,W503

typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install package with dev extras
run: pip install -e ".[dev]"

- name: mypy
run: mypy governs_ai/ --ignore-missing-imports

test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip

- name: Install package with dev extras
run: pip install -e ".[dev]"

- name: pytest
run: pytest tests/ -v --tb=short

secret-scan:
name: Secret Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to PyPI

on:
push:
tags:
- "v*"

jobs:
publish:
name: Build & Publish
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # OIDC trusted publishing

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install build tools
run: pip install build

- name: Build distribution
run: python -m build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ from governs_ai import GovernsAIClient
# Create client with organization context
client = GovernsAIClient(
api_key="your-api-key",
base_url="http://localhost:3002",
base_url="https://api.governsai.com",
org_id="org-456" # Organization context (static)
)

Expand Down
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from governs_ai import GovernsAIClient
# Create client with organization context
client = GovernsAIClient(
api_key="your-api-key",
base_url="http://localhost:3002",
base_url="https://api.governsai.com",
org_id="org-456" # Organization context (static)
)

Expand Down Expand Up @@ -70,7 +70,7 @@ elif precheck_response.decision == "confirm":

```bash
export GOVERNS_API_KEY="your-api-key"
export GOVERNS_BASE_URL="http://localhost:3002"
export GOVERNS_BASE_URL="https://api.governsai.com"
export GOVERNS_ORG_ID="org-456"
export GOVERNS_TIMEOUT="30000"
export GOVERNS_RETRIES="3"
Expand All @@ -85,7 +85,7 @@ from governs_ai import GovernsAIClient, GovernsAIConfig
# Explicit configuration
config = GovernsAIConfig(
api_key="your-api-key",
base_url="http://localhost:3002",
base_url="https://api.governsai.com",
org_id="org-456",
timeout=30000,
retries=3,
Expand Down Expand Up @@ -423,7 +423,7 @@ client = GovernsAIClient(
```python
GovernsAIClient(
api_key: str,
base_url: str = "http://localhost:3002",
base_url: str = "https://api.governsai.com",
org_id: str,
timeout: int = 30000,
retries: int = 3,
Expand Down Expand Up @@ -770,7 +770,7 @@ import os
client = GovernsAIClient(
api_key=os.getenv("GOVERNS_API_KEY"),
org_id=os.getenv("GOVERNS_ORG_ID"),
base_url=os.getenv("GOVERNS_BASE_URL", "http://localhost:3002")
base_url=os.getenv("GOVERNS_BASE_URL", "https://api.governsai.com")
)
```

Expand Down
42 changes: 42 additions & 0 deletions governs_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from .clients.budget import BudgetClient
from .clients.tool import ToolClient
from .clients.analytics import AnalyticsClient
from .clients.context import ContextClient
from .clients.documents import DocumentClient
from .models import (
PrecheckRequest,
PrecheckResponse,
Expand All @@ -21,6 +23,25 @@
ConfirmationResponse,
HealthStatus,
Decision,
SaveContextInput,
SaveContextResponse,
ContextLLMResponse,
ConversationSummary,
ConversationItem,
MemoryRecord,
MemorySearchMetadata,
MemorySearchResponse,
ResolvedUserDetails,
ResolvedUser,
DocumentUploadResponse,
DocumentChunk,
DocumentRecord,
DocumentDetails,
DocumentListPagination,
DocumentListResponse,
DocumentSearchSource,
DocumentSearchResult,
DocumentSearchResponse,
)
from .exceptions import (
GovernsAIError,
Expand All @@ -45,6 +66,8 @@
"BudgetClient",
"ToolClient",
"AnalyticsClient",
"ContextClient",
"DocumentClient",
# Data models
"PrecheckRequest",
"PrecheckResponse",
Expand All @@ -54,6 +77,25 @@
"ConfirmationResponse",
"HealthStatus",
"Decision",
"SaveContextInput",
"SaveContextResponse",
"ContextLLMResponse",
"ConversationSummary",
"ConversationItem",
"MemoryRecord",
"MemorySearchMetadata",
"MemorySearchResponse",
"ResolvedUserDetails",
"ResolvedUser",
"DocumentUploadResponse",
"DocumentChunk",
"DocumentRecord",
"DocumentDetails",
"DocumentListPagination",
"DocumentListResponse",
"DocumentSearchSource",
"DocumentSearchResult",
"DocumentSearchResponse",
# Exceptions
"GovernsAIError",
"PrecheckError",
Expand Down
8 changes: 6 additions & 2 deletions governs_ai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from .clients.budget import BudgetClient
from .clients.tool import ToolClient
from .clients.analytics import AnalyticsClient
from .clients.context import ContextClient
from .clients.documents import DocumentClient
from .exceptions import GovernsAIError


Expand All @@ -32,7 +34,7 @@ class GovernsAIConfig:
"""Configuration for GovernsAI client."""

api_key: str
base_url: str = "http://localhost:3002"
base_url: str = "https://api.governsai.com"
org_id: str = ""
timeout: int = 30000
retries: int = 3
Expand Down Expand Up @@ -83,7 +85,7 @@ def __init__(
else:
self.config = GovernsAIConfig(
api_key=api_key or os.getenv("GOVERNS_API_KEY", ""),
base_url=base_url or os.getenv("GOVERNS_BASE_URL", "http://localhost:3002"),
base_url=base_url or os.getenv("GOVERNS_BASE_URL", "https://api.governsai.com"),
org_id=org_id or os.getenv("GOVERNS_ORG_ID", ""),
timeout=timeout or int(os.getenv("GOVERNS_TIMEOUT", "30000")),
retries=retries or int(os.getenv("GOVERNS_RETRIES", "3")),
Expand Down Expand Up @@ -116,6 +118,8 @@ def __init__(
self.budget = BudgetClient(self.http_client, self.logger)
self.tools = ToolClient(self.http_client, self.logger)
self.analytics = AnalyticsClient(self.http_client, self.logger)
self.context = ContextClient(self.http_client, self.logger)
self.documents = DocumentClient(self.http_client, self.logger)

@classmethod
def from_env(cls) -> "GovernsAIClient":
Expand Down
4 changes: 4 additions & 0 deletions governs_ai/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
from .budget import BudgetClient
from .tool import ToolClient
from .analytics import AnalyticsClient
from .context import ContextClient
from .documents import DocumentClient

__all__ = [
"PrecheckClient",
"ConfirmationClient",
"BudgetClient",
"ToolClient",
"AnalyticsClient",
"ContextClient",
"DocumentClient",
]
Loading
Loading