openliate 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
openliate/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """
2
+ OpenLiate Python SDK — Built for Sovereign AI Agents From India to the World
3
+ Class is an Agent: 1 Class = 5 Properties (L · I · A · T · E)
4
+ """
5
+ from .om import liate
6
+ from .client import LapiClient, AgentRunResult
7
+
8
+ __version__ = "0.1.0"
9
+ __all__ = ["liate", "LapiClient", "AgentRunResult"]
10
+
openliate/client.py ADDED
@@ -0,0 +1,127 @@
1
+ """
2
+ OpenLiate Python LAPI Client
3
+ Connects to OpenLiate Orchestration Module (OM) via standard LAPI /run protocol.
4
+ """
5
+ from dataclasses import dataclass, field
6
+ from typing import Any, Dict, List, Optional
7
+ import json
8
+ import urllib.request
9
+ import urllib.error
10
+ import time
11
+
12
+ @dataclass
13
+ class AgentRunResult:
14
+ """
15
+ Standard OpenLiate execution response object.
16
+ """
17
+ response: str
18
+ steps: List[Dict[str, Any]] = field(default_factory=list)
19
+ execution_time_ms: float = 0.0
20
+ session_id: Optional[str] = None
21
+ agent: Optional[str] = None
22
+ raw: Dict[str, Any] = field(default_factory=dict)
23
+
24
+ def __str__(self) -> str:
25
+ return self.response
26
+
27
+ class LapiClient:
28
+ """
29
+ HTTP client for communicating with OpenLiate LAPI endpoint.
30
+ Supports both standard library urllib (zero dependencies) and httpx (async).
31
+ """
32
+ def __init__(self, endpoint: str = "http://localhost:7071"):
33
+ self.endpoint = endpoint.rstrip("/")
34
+
35
+ def run(self, manifest: Dict[str, Any], prompt: str, session_id: Optional[str] = None) -> AgentRunResult:
36
+ """
37
+ Synchronous run via standard urllib.
38
+ """
39
+ url = f"{self.endpoint}/run"
40
+ payload = {
41
+ "manifest": manifest,
42
+ "prompt": prompt
43
+ }
44
+ if session_id:
45
+ payload["sessionId"] = session_id
46
+
47
+ data = json.dumps(payload).encode("utf-8")
48
+ req = urllib.request.Request(
49
+ url,
50
+ data=data,
51
+ headers={"Content-Type": "application/json"}
52
+ )
53
+
54
+ start_time = time.time()
55
+ try:
56
+ with urllib.request.urlopen(req, timeout=120) as resp:
57
+ status = resp.status
58
+ body = json.loads(resp.read().decode("utf-8"))
59
+ except urllib.error.HTTPError as e:
60
+ err_body = e.read().decode("utf-8")
61
+ try:
62
+ err_json = json.loads(err_body)
63
+ err_msg = err_json.get("error", err_body)
64
+ except Exception:
65
+ err_msg = err_body
66
+ raise RuntimeError(f"[OpenLiate LAPI Error HTTP {e.code}]: {err_msg}") from e
67
+ except urllib.error.URLError as e:
68
+ raise ConnectionError(
69
+ f"[OpenLiate Connection Error]: Unable to reach LAPI engine at {self.endpoint}. "
70
+ f"Ensure the OpenLiate engine is running (e.g. `openliate serve` or deployed URL)."
71
+ ) from e
72
+
73
+ duration_ms = (time.time() - start_time) * 1000.0
74
+
75
+ return AgentRunResult(
76
+ response=body.get("text", body.get("response", body.get("output", ""))),
77
+ steps=body.get("steps", []),
78
+ execution_time_ms=body.get("latencyMs", body.get("executionTimeMs", duration_ms)),
79
+ session_id=body.get("sessionId", session_id),
80
+ agent=body.get("agent", manifest.get("A", {}).get("name", "agent")),
81
+ raw=body
82
+ )
83
+
84
+ async def arun(self, manifest: Dict[str, Any], prompt: str, session_id: Optional[str] = None) -> AgentRunResult:
85
+ """
86
+ Asynchronous run via httpx.
87
+ """
88
+ try:
89
+ import httpx
90
+ except ImportError:
91
+ raise ImportError(
92
+ "httpx is required for asynchronous arun(). Install with: pip install httpx"
93
+ )
94
+
95
+ url = f"{self.endpoint}/run"
96
+ payload = {
97
+ "manifest": manifest,
98
+ "prompt": prompt
99
+ }
100
+ if session_id:
101
+ payload["sessionId"] = session_id
102
+
103
+ start_time = time.time()
104
+ async with httpx.AsyncClient(timeout=120.0) as client:
105
+ try:
106
+ resp = await client.post(url, json=payload)
107
+ resp.raise_for_status()
108
+ body = resp.json()
109
+ except httpx.HTTPStatusError as e:
110
+ raise RuntimeError(f"[OpenLiate LAPI Error HTTP {e.response.status_code}]: {e.response.text}") from e
111
+ except httpx.RequestError as e:
112
+ raise ConnectionError(
113
+ f"[OpenLiate Connection Error]: Unable to reach LAPI engine at {self.endpoint}. "
114
+ f"Ensure OpenLiate is running (`openliate serve` or cloud endpoint)."
115
+ ) from e
116
+
117
+ duration_ms = (time.time() - start_time) * 1000.0
118
+
119
+ return AgentRunResult(
120
+ response=body.get("text", body.get("response", body.get("output", ""))),
121
+ steps=body.get("steps", []),
122
+ execution_time_ms=body.get("latencyMs", body.get("executionTimeMs", duration_ms)),
123
+ session_id=body.get("sessionId", session_id),
124
+ agent=body.get("agent", manifest.get("A", {}).get("name", "agent")),
125
+ raw=body
126
+ )
127
+
openliate/om.py ADDED
@@ -0,0 +1,102 @@
1
+ """
2
+ Core Engine: OM (Orchestration Module)
3
+ Matches AUM (Agent Unified Manifest) specification across 5 orthogonal layers:
4
+ L[LM] · I[ntegration] · A[gent] · T[ools] · E[nvironment]
5
+ """
6
+ from typing import Any, Dict, List, Optional, Union
7
+ import os
8
+ from .client import LapiClient, AgentRunResult
9
+
10
+ class liate:
11
+ """
12
+ OM (Orchestration Module) — Python OOP Base Class for AI Agents.
13
+ Supports pure LIATE authoring across 3 styles:
14
+ 1. Shorthand: L · I · A · T · E
15
+ 2. Full Name: LLM · Integration · Agent · Tools · Environment
16
+ 3. Lowercase: llm · integration · agent · tools · environment
17
+
18
+ Example:
19
+ ```python
20
+ from openliate import liate
21
+
22
+ class HelloAgent(liate):
23
+ LLM = "sarvam/sarvam-105b"
24
+ Integration = {"memory": "sessions/hello-agent"}
25
+ Agent = {"name": "hello_agent"}
26
+ Tools = ["fetch"]
27
+ Environment = {"SARVAM_API_KEY": "$SARVAM_API_KEY"}
28
+
29
+ agent = HelloAgent()
30
+ result = agent.run("Namaste world!")
31
+ print(result)
32
+ ```
33
+ """
34
+ # 1. Shorthand
35
+ L: Optional[Union[str, Dict[str, Any]]] = None
36
+ I: Optional[Dict[str, Any]] = None
37
+ A: Optional[Union[str, Dict[str, Any]]] = None
38
+ T: Optional[List[Any]] = None
39
+ E: Optional[Dict[str, str]] = None
40
+
41
+ # 2. Full Name
42
+ LLM: Optional[Union[str, Dict[str, Any]]] = None
43
+ Integration: Optional[Dict[str, Any]] = None
44
+ Agent: Optional[Union[str, Dict[str, Any]]] = None
45
+ Tools: Optional[List[Any]] = None
46
+ Environment: Optional[Dict[str, str]] = None
47
+
48
+ # 3. Lowercase
49
+ llm: Optional[Union[str, Dict[str, Any]]] = None
50
+ integration: Optional[Dict[str, Any]] = None
51
+ agent: Optional[Union[str, Dict[str, Any]]] = None
52
+ tools: Optional[List[Any]] = None
53
+ environment: Optional[Dict[str, str]] = None
54
+
55
+ def __init__(self, endpoint: Optional[str] = None):
56
+ self._endpoint = endpoint or os.environ.get("OPENLIATE_ENDPOINT", "http://localhost:7071")
57
+ self._client = LapiClient(endpoint=self._endpoint)
58
+
59
+ def to_manifest(self) -> Dict[str, Any]:
60
+ """
61
+ Exports the declarative AUM (Agent Unified Manifest) dictionary.
62
+ """
63
+ l_val = self.L if self.L is not None else (self.LLM if self.LLM is not None else self.llm)
64
+ i_val = self.I if self.I is not None else (self.Integration if self.Integration is not None else self.integration)
65
+ a_val = self.A if self.A is not None else (self.Agent if self.Agent is not None else self.agent)
66
+ t_val = self.T if self.T is not None else (self.Tools if self.Tools is not None else self.tools)
67
+ e_val = self.E if self.E is not None else (self.Environment if self.Environment is not None else self.environment)
68
+
69
+ if not l_val:
70
+ raise ValueError(
71
+ f"[OpenLiate Error]: Missing required Layer [L] (LLM) in class '{self.__class__.__name__}'. "
72
+ f"Declare 'L', 'LLM', or 'llm' on your class. "
73
+ f"OpenLiate never hardcodes or falls back to silent model defaults."
74
+ )
75
+
76
+ name = self.__class__.__name__
77
+ agent_a = a_val or {"name": name}
78
+ if isinstance(agent_a, str):
79
+ agent_a = {"name": agent_a}
80
+
81
+ return {
82
+ "L": l_val,
83
+ "I": i_val or {},
84
+ "A": agent_a,
85
+ "T": t_val or [],
86
+ "E": e_val or {}
87
+ }
88
+
89
+ def run(self, prompt: str, session_id: Optional[str] = None) -> AgentRunResult:
90
+ """
91
+ Executes the agent via OpenLiate LAPI.
92
+ """
93
+ manifest = self.to_manifest()
94
+ return self._client.run(manifest=manifest, prompt=prompt, session_id=session_id)
95
+
96
+ async def arun(self, prompt: str, session_id: Optional[str] = None) -> AgentRunResult:
97
+ """
98
+ Asynchronously executes the agent via OpenLiate LAPI.
99
+ """
100
+ manifest = self.to_manifest()
101
+ return await self._client.arun(manifest=manifest, prompt=prompt, session_id=session_id)
102
+
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.5
2
+ Name: openliate
3
+ Version: 0.1.0
4
+ Summary: Open Source Backend Layer for AI Agents — Built for Sovereign AI Agents From India to the World
5
+ Project-URL: Homepage, https://openliate.tech
6
+ Project-URL: Repository, https://github.com/openliate/openliate
7
+ Project-URL: Documentation, https://docs.openliate.tech
8
+ Project-URL: Issues, https://github.com/openliate/openliate/issues
9
+ Author-email: OpenLiate <vinod@openliate.tech>, Vinod Hatti <gitdevinod@gmail.com>
10
+ License: MIT
11
+ Keywords: agent,aum,autonomous-agents,liate,mcp,om,sarvamai,sovereign-ai
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Requires-Dist: httpx>=0.24.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # OpenLiate — Python SDK
26
+
27
+ ### Sovereign AI Agents in 5 Lines: Class is an Agent.
28
+ `L[LM] · I[ntegration] · A[gent] · T[ools] · E[nvironment]`
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install openliate
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Quickstart (`agent.py`)
41
+
42
+ ```python
43
+ from openliate import liate
44
+
45
+ class HelloAgent(liate):
46
+ L = "sarvam/sarvam-105b"
47
+ I = {"memory": "sessions/hello-agent"}
48
+ A = {"name": "hello_agent", "intent": "Autonomous Assistant"}
49
+ T = ["fetch"]
50
+ E = {"SARVAM_API_KEY": "$SARVAM_API_KEY"}
51
+
52
+ agent = HelloAgent()
53
+
54
+ # 1. Inspect declarative AUM manifest
55
+ print(agent.to_manifest())
56
+
57
+ # 2. Run agent via OpenLiate engine
58
+ result = agent.run("Namaste world!")
59
+ print(result.response)
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Architecture: AUM & OM
65
+
66
+ Every agent declares the 5 orthogonal layers according to the **Agent Unified Manifest (AUM)** standard:
67
+
68
+ - **`L` (Model):** Sovereign LLM provider and model (e.g., Sarvam 105B).
69
+ - **`I` (Integration):** Memory retention, Postgres, and knowledge repositories.
70
+ - **`A` (Agent / Harness):** Agent name, intent, and reasoning loop.
71
+ - **`T` (Tools):** Anthropic Model Context Protocol (MCP) and custom tools.
72
+ - **`E` (Environment):** Secrets and guardrails.
73
+
74
+ Execution is powered by the **Orchestration Module (OM)** connecting locally or to deployed cloud endpoints.
75
+
76
+ ---
77
+
78
+ ## License
79
+
80
+ MIT © [OpenLiate](https://openliate.tech)
81
+
@@ -0,0 +1,6 @@
1
+ openliate/__init__.py,sha256=PCX3pUhkf4NvXWy61ntmDA2sxiF4m4Sd-yIpyo-MLAY,298
2
+ openliate/client.py,sha256=XnhX9GTpcKFHwtG8DxxK-JyXzLCEbeZTljZI1g2vZjQ,4676
3
+ openliate/om.py,sha256=auhEJIJQuoMUI2Ehx8YdIlDAkmS7emmGvmwzbUm-7oU,3952
4
+ openliate-0.1.0.dist-info/METADATA,sha256=5GckY4UhIhVPcPLUve41D0D6Q49j-Uapy7EgNN5tSKc,2469
5
+ openliate-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ openliate-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any