memra 0.1.2__py3-none-any.whl → 0.2.1__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.
memra/__init__.py CHANGED
@@ -1,28 +1,27 @@
1
1
  """
2
- Memra SDK - A declarative orchestration framework for AI-powered business workflows
2
+ Memra SDK - Declarative AI Workflows
3
+
4
+ A framework for building AI-powered business workflows using a declarative approach.
5
+ Think of it as "Kubernetes for business logic" where agents are the pods and
6
+ departments are the deployments.
3
7
  """
4
8
 
5
- from .models import (
6
- Agent,
7
- Department,
8
- LLM,
9
- Tool,
10
- ExecutionPolicy,
11
- ExecutionTrace,
12
- DepartmentResult,
13
- DepartmentAudit
14
- )
15
- from .discovery_client import discover_tools, check_api_health, get_api_status
9
+ __version__ = "0.2.1"
10
+
11
+ # Core imports
12
+ from .models import Agent, Department, Tool
13
+ from .execution import ExecutionEngine
16
14
 
17
- __version__ = "0.1.2"
15
+ # Make key classes available at package level
18
16
  __all__ = [
19
- "Agent",
17
+ "Agent",
20
18
  "Department",
21
- "LLM",
22
- "Tool",
23
- "ExecutionPolicy",
24
- "ExecutionTrace",
25
- "DepartmentResult",
26
- "DepartmentAudit",
27
- "discover_tools"
28
- ]
19
+ "Tool",
20
+ "ExecutionEngine",
21
+ "__version__"
22
+ ]
23
+
24
+ # Optional: Add version check for compatibility
25
+ import sys
26
+ if sys.version_info < (3, 8):
27
+ raise RuntimeError("Memra requires Python 3.8 or higher")
memra/discovery.py ADDED
@@ -0,0 +1,15 @@
1
+ from typing import List, Dict, Any, Optional
2
+ from .tool_registry import ToolRegistry
3
+
4
+ def discover_tools(hosted_by: Optional[str] = None) -> List[Dict[str, Any]]:
5
+ """
6
+ Discover available tools in the Memra platform.
7
+
8
+ Args:
9
+ hosted_by: Filter tools by host ("memra" or "mcp"). If None, returns all tools.
10
+
11
+ Returns:
12
+ List of available tools with their metadata
13
+ """
14
+ registry = ToolRegistry()
15
+ return registry.discover_tools(hosted_by)
memra/execution.py CHANGED
@@ -2,7 +2,7 @@ import time
2
2
  import logging
3
3
  from typing import Dict, Any, List, Optional
4
4
  from .models import Department, Agent, DepartmentResult, ExecutionTrace, DepartmentAudit
5
- from .tool_registry_client import ToolRegistryClient
5
+ from .tool_registry import ToolRegistry
6
6
 
7
7
  logger = logging.getLogger(__name__)
8
8
 
@@ -10,7 +10,7 @@ class ExecutionEngine:
10
10
  """Engine that executes department workflows by coordinating agents and tools"""
11
11
 
12
12
  def __init__(self):
13
- self.tool_registry = ToolRegistryClient()
13
+ self.tool_registry = ToolRegistry()
14
14
  self.last_execution_audit: Optional[DepartmentAudit] = None
15
15
 
16
16
  def execute_department(self, department: Department, input_data: Dict[str, Any]) -> DepartmentResult:
memra/tool_registry.py ADDED
@@ -0,0 +1,70 @@
1
+ import importlib
2
+ import logging
3
+ import sys
4
+ import os
5
+ from typing import Dict, Any, List, Optional, Callable
6
+ from pathlib import Path
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+ class ToolRegistry:
11
+ """Registry for managing and executing tools via API calls only"""
12
+
13
+ def __init__(self):
14
+ self.tools: Dict[str, Dict[str, Any]] = {}
15
+ self._register_known_tools()
16
+
17
+ def _register_known_tools(self):
18
+ """Register known tools with their metadata (no actual implementations)"""
19
+ # Server-hosted tools (executed via Memra API)
20
+ server_tools = [
21
+ ("DatabaseQueryTool", "Query database schemas and data"),
22
+ ("PDFProcessor", "Process PDF files and extract content"),
23
+ ("OCRTool", "Perform OCR on images and documents"),
24
+ ("InvoiceExtractionWorkflow", "Extract structured data from invoices"),
25
+ ("FileReader", "Read files from the filesystem"),
26
+ ]
27
+
28
+ for tool_name, description in server_tools:
29
+ self.register_tool(tool_name, None, "memra", description)
30
+
31
+ # MCP-hosted tools (executed via MCP bridge)
32
+ mcp_tools = [
33
+ ("DataValidator", "Validate data against schemas"),
34
+ ("PostgresInsert", "Insert data into PostgreSQL database"),
35
+ ]
36
+
37
+ for tool_name, description in mcp_tools:
38
+ self.register_tool(tool_name, None, "mcp", description)
39
+
40
+ logger.info(f"Registered {len(self.tools)} tool definitions")
41
+
42
+ def register_tool(self, name: str, tool_class: Optional[type], hosted_by: str, description: str):
43
+ """Register a tool in the registry (metadata only)"""
44
+ self.tools[name] = {
45
+ "class": tool_class, # Will be None for API-based tools
46
+ "hosted_by": hosted_by,
47
+ "description": description
48
+ }
49
+ logger.debug(f"Registered tool: {name} (hosted by {hosted_by})")
50
+
51
+ def discover_tools(self, hosted_by: Optional[str] = None) -> List[Dict[str, Any]]:
52
+ """Discover available tools, optionally filtered by host"""
53
+ tools = []
54
+ for name, info in self.tools.items():
55
+ if hosted_by is None or info["hosted_by"] == hosted_by:
56
+ tools.append({
57
+ "name": name,
58
+ "hosted_by": info["hosted_by"],
59
+ "description": info["description"]
60
+ })
61
+ return tools
62
+
63
+ def execute_tool(self, tool_name: str, hosted_by: str, input_data: Dict[str, Any],
64
+ config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
65
+ """Execute a tool - this should not be called directly in API-based mode"""
66
+ logger.warning(f"Direct tool execution attempted for {tool_name}. Use API client instead.")
67
+ return {
68
+ "success": False,
69
+ "error": "Direct tool execution not supported. Use API client for tool execution."
70
+ }
@@ -12,12 +12,13 @@ class ToolRegistryClient:
12
12
  def __init__(self):
13
13
  self.api_base = os.getenv("MEMRA_API_URL", "https://api.memra.co")
14
14
  self.api_key = os.getenv("MEMRA_API_KEY")
15
+ self.tools_cache = None
16
+
15
17
  if not self.api_key:
16
18
  raise ValueError(
17
19
  "MEMRA_API_KEY environment variable is required. "
18
- "Contact info@memra.co to request access."
20
+ "Please contact info@memra.co for an API key."
19
21
  )
20
- self.tools_cache = None
21
22
 
22
23
  def discover_tools(self, hosted_by: Optional[str] = None) -> List[Dict[str, Any]]:
23
24
  """Discover available tools from the API"""
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.1
2
+ Name: memra
3
+ Version: 0.2.1
4
+ Summary: Declarative framework for enterprise workflows with MCP integration - Client SDK
5
+ Home-page: https://github.com/memra/memra-sdk
6
+ Author: Memra
7
+ Author-email: Memra <support@memra.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://memra.co
10
+ Project-URL: Repository, https://github.com/memra-platform/memra-sdk
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: pydantic>=1.8.0
24
+ Requires-Dist: httpx>=0.24.0
25
+ Requires-Dist: typing-extensions>=4.0.0
26
+ Requires-Dist: aiohttp>=3.8.0
27
+ Requires-Dist: aiohttp-cors>=0.7.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=6.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio; extra == "dev"
31
+ Requires-Dist: black; extra == "dev"
32
+ Requires-Dist: flake8; extra == "dev"
33
+ Provides-Extra: mcp
34
+ Requires-Dist: psycopg2-binary>=2.9.0; extra == "mcp"
35
+
36
+ # Memra SDK
37
+
38
+ A declarative orchestration framework for AI-powered business workflows. Think of it as "Kubernetes for business logic" where agents are the pods and departments are the deployments.
39
+
40
+ ## 🚀 Team Setup
41
+
42
+ **New team member?** See the complete setup guide: **[TEAM_SETUP.md](TEAM_SETUP.md)**
43
+
44
+ This includes:
45
+ - Database setup (PostgreSQL + Docker)
46
+ - Local development environment
47
+ - Testing instructions
48
+ - Troubleshooting guide
49
+
50
+ ## Quick Start
51
+
52
+ ```python
53
+ from memra.sdk.models import Agent, Department, Tool
54
+
55
+ # Define your agents
56
+ data_extractor = Agent(
57
+ role="Data Extraction Specialist",
58
+ job="Extract and validate data",
59
+ tools=[Tool(name="DataExtractor", hosted_by="memra")],
60
+ input_keys=["input_data"],
61
+ output_key="extracted_data"
62
+ )
63
+
64
+ # Create a department
65
+ dept = Department(
66
+ name="Data Processing",
67
+ mission="Process and validate data",
68
+ agents=[data_extractor]
69
+ )
70
+
71
+ # Run the workflow
72
+ result = dept.run({"input_data": {...}})
73
+ ```
74
+
75
+ ## Installation
76
+
77
+ ```bash
78
+ pip install memra
79
+ ```
80
+
81
+ ## API Access
82
+
83
+ Memra requires an API key to execute workflows on the hosted infrastructure.
84
+
85
+ ### Get Your API Key
86
+ Contact [info@memra.co](mailto:info@memra.co) for API access.
87
+
88
+ ### Set Your API Key
89
+ ```bash
90
+ # Set environment variable
91
+ export MEMRA_API_KEY="your-api-key-here"
92
+
93
+ # Or add to your shell profile for persistence
94
+ echo 'export MEMRA_API_KEY="your-api-key-here"' >> ~/.zshrc
95
+ ```
96
+
97
+ ### Test Your Setup
98
+ ```bash
99
+ python examples/accounts_payable_client.py
100
+ ```
101
+
102
+ ## Documentation
103
+
104
+ Documentation is coming soon. For now, see the examples below and in the `examples/` directory.
105
+
106
+ ## Example: Propane Delivery Workflow
107
+
108
+ See the `examples/propane_delivery.py` file for a complete example of how to use Memra to orchestrate a propane delivery workflow.
109
+
110
+ ## Contributing
111
+
112
+ We welcome contributions! Please see our [contributing guide](CONTRIBUTING.md) for details.
113
+
114
+ ## License
115
+
116
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
117
+
118
+ ## Examples
119
+
120
+ ```
121
+ ├── examples/
122
+ │ ├── accounts_payable_client.py # API-based example
123
+ │ ├── accounts_payable.py # Local example
124
+ │ ├── invoice_processing.py # Simple workflow
125
+ │ └── propane_delivery.py # Domain example
126
+ ├── memra/ # Core SDK
127
+ ├── logic/ # Tool implementations
128
+ ├── local/dependencies/ # Database setup & schemas
129
+ └── docker-compose.yml # Database setup
130
+ ```
@@ -0,0 +1,13 @@
1
+ memra/__init__.py,sha256=K3jA34FSI9LuDHAPyMFpG3cbX0pFVsTP2N5xzbUffiI,662
2
+ memra/discovery.py,sha256=yJIQnrDQu1nyzKykCIuzG_5SW5dIXHCEBLLKRWacIoY,480
3
+ memra/discovery_client.py,sha256=AbnKn6qhyrf7vmOvknEeDzH4tiGHsqPHtDaein_qaW0,1271
4
+ memra/execution.py,sha256=3UIP69x2Ba89vv7OQ3yAzlnl1lphGagFPgKUrqcqElk,20172
5
+ memra/models.py,sha256=nTaYLAp0tRzQ0CQaBLNBURfhBQ5_gyty0ams4mghyIc,3289
6
+ memra/tool_registry.py,sha256=vnsuH5q20AMXADNl3-7HCD26x1zHc67waxxqv_Ta6Ak,2951
7
+ memra/tool_registry_client.py,sha256=uzMQ4COvRams9vuPLcqcdljUpDlAYU_tyFxrRhrA0Lc,4009
8
+ memra-0.2.1.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ memra-0.2.1.dist-info/METADATA,sha256=LI5-Dte9XuNjsnM1KVs8Xr998nViC6jmI2S1nY37lkQ,3794
10
+ memra-0.2.1.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
11
+ memra-0.2.1.dist-info/entry_points.txt,sha256=LBVjwWoxWJRzNLgeByPn6xUvWFIRnqnemvAZgIoSt08,41
12
+ memra-0.2.1.dist-info/top_level.txt,sha256=pXWcTRS1zctdiSUivW4iyKpJ4tcfIu-1BW_fpbal3OY,6
13
+ memra-0.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ memra = memra.cli:main
@@ -1,191 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: memra
3
- Version: 0.1.2
4
- Summary: A declarative orchestration framework for AI-powered business workflows
5
- Author-email: Memra Team <info@memra.co>
6
- License: MIT
7
- Project-URL: Homepage, https://memra.co
8
- Project-URL: Repository, https://github.com/memra-platform/memra-sdk
9
- Project-URL: Documentation, https://memra.co
10
- Project-URL: Bug Reports, https://github.com/memra-platform/memra-sdk/issues
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
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
- Requires-Python: >=3.8
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: pydantic>=2.0.0
24
- Requires-Dist: httpx>=0.24.0
25
- Requires-Dist: typing-extensions>=4.0.0
26
- Dynamic: license-file
27
-
28
- # Memra SDK
29
-
30
- A declarative orchestration framework for AI-powered business workflows. Think of it as "Kubernetes for business logic" where agents are the pods and departments are the deployments.
31
-
32
- ## 🚀 Quick Start
33
-
34
- ```python
35
- from memra import Agent, Department, LLM
36
- from memra.execution import ExecutionEngine
37
-
38
- # Define your agents declaratively
39
- data_engineer = Agent(
40
- role="Data Engineer",
41
- job="Extract invoice schema from database",
42
- llm=LLM(model="llama-3.2-11b-vision-preview", temperature=0.1),
43
- tools=[
44
- {"name": "DatabaseQueryTool", "hosted_by": "memra"}
45
- ],
46
- output_key="invoice_schema"
47
- )
48
-
49
- invoice_parser = Agent(
50
- role="Invoice Parser",
51
- job="Extract structured data from invoice PDF",
52
- llm=LLM(model="llama-3.2-11b-vision-preview", temperature=0.0),
53
- tools=[
54
- {"name": "PDFProcessor", "hosted_by": "memra"},
55
- {"name": "InvoiceExtractionWorkflow", "hosted_by": "memra"}
56
- ],
57
- input_keys=["file", "invoice_schema"],
58
- output_key="invoice_data"
59
- )
60
-
61
- # Create a department
62
- ap_department = Department(
63
- name="Accounts Payable",
64
- mission="Process invoices accurately into financial system",
65
- agents=[data_engineer, invoice_parser],
66
- workflow_order=["Data Engineer", "Invoice Parser"]
67
- )
68
-
69
- # Execute the workflow
70
- engine = ExecutionEngine()
71
- result = engine.execute_department(ap_department, {
72
- "file": "invoice.pdf",
73
- "connection": "postgresql://user@host/db"
74
- })
75
-
76
- if result.success:
77
- print("✅ Invoice processed successfully!")
78
- print(f"Data: {result.data}")
79
- ```
80
-
81
- ## 📦 Installation
82
-
83
- ```bash
84
- pip install memra-sdk
85
- ```
86
-
87
- ## 🔑 Configuration
88
-
89
- ### Step 1: Get Your API Key
90
- Contact **info@memra.co** to request an API key for early access.
91
-
92
- ### Step 2: Set Your API Key
93
- Once you receive your API key, configure it:
94
-
95
- ```bash
96
- export MEMRA_API_KEY="your-api-key-here"
97
- export MEMRA_API_URL="https://api.memra.co" # Optional, defaults to production
98
- ```
99
-
100
- Or in Python:
101
-
102
- ```python
103
- import os
104
- os.environ["MEMRA_API_KEY"] = "your-api-key-here"
105
- ```
106
-
107
- ## 🎯 Key Features
108
-
109
- - **Declarative**: Define workflows like Kubernetes YAML
110
- - **AI-Powered**: Built-in LLM integrations for document processing
111
- - **Conversational**: Agents explain what they're doing in real-time
112
- - **Production Ready**: Real database connectivity and file processing
113
- - **Scalable**: Tools execute on Memra's cloud infrastructure
114
-
115
- ## 🏗️ Core Concepts
116
-
117
- ### Agents
118
- Agents are the workers in your workflow. Each agent has:
119
- - **Role**: What they do (e.g., "Data Engineer")
120
- - **Job**: Their specific responsibility
121
- - **Tools**: What capabilities they use
122
- - **LLM**: Their AI model configuration
123
-
124
- ### Departments
125
- Departments coordinate multiple agents:
126
- - **Mission**: Overall goal
127
- - **Workflow Order**: Sequence of agent execution
128
- - **Manager**: Optional oversight and validation
129
-
130
- ### Tools
131
- Tools are hosted capabilities:
132
- - **memra**: Hosted by Memra (PDF processing, LLMs, databases)
133
- - **mcp**: Customer-hosted via Model Context Protocol
134
-
135
- ## 📊 Example Output
136
-
137
- ```
138
- 🏢 Starting Accounts Payable Department
139
- 📋 Mission: Process invoices accurately into financial system
140
- 👥 Team: Data Engineer, Invoice Parser
141
- 🔄 Workflow: Data Engineer → Invoice Parser
142
-
143
- 👤 Data Engineer: Hi! I'm starting my work now...
144
- 💭 Data Engineer: My job is to extract invoice schema from database
145
- ⚡ Data Engineer: Using tool 1/1: DatabaseQueryTool
146
- ✅ Data Engineer: Great! DatabaseQueryTool did real work and gave me useful results
147
- 🎉 Data Engineer: Perfect! I completed my work with real data processing
148
-
149
- 👤 Invoice Parser: Hi! I'm starting my work now...
150
- 💭 Invoice Parser: My job is to extract structured data from invoice pdf
151
- ⚡ Invoice Parser: Using tool 1/2: PDFProcessor
152
- ✅ Invoice Parser: Great! PDFProcessor did real work and gave me useful results
153
- ```
154
-
155
- ## 🔍 Tool Discovery
156
-
157
- Discover available tools:
158
-
159
- ```python
160
- from memra import discover_tools, get_api_status
161
-
162
- # Check API health
163
- status = get_api_status()
164
- print(f"API Health: {status['api_healthy']}")
165
- print(f"Tools Available: {status['tools_available']}")
166
-
167
- # Discover tools
168
- tools = discover_tools()
169
- for tool in tools:
170
- print(f"- {tool['name']}: {tool['description']}")
171
- ```
172
-
173
- ## 📚 Examples
174
-
175
- See the `examples/` directory for complete workflows:
176
-
177
- - `accounts_payable_client.py`: Invoice processing with database integration
178
- - More examples coming soon!
179
-
180
- ## 🆘 Support
181
-
182
- - **Support**: info@memra.co
183
-
184
- ## 📄 License
185
-
186
- MIT License - see LICENSE file for details.
187
-
188
- ---
189
-
190
- **Built with ❤️ by the Memra team**
191
- **Note**: The SDK will not work without a valid API key.
@@ -1,10 +0,0 @@
1
- memra/__init__.py,sha256=QRk72YETLgL15GVt26tN_rBraCQkhZO7UB9T6d4u_uU,543
2
- memra/discovery_client.py,sha256=AbnKn6qhyrf7vmOvknEeDzH4tiGHsqPHtDaein_qaW0,1271
3
- memra/execution.py,sha256=UJ_MJ4getuSk4HJW1sCi7lc26avX-G6-GxnvE-DiSwk,20191
4
- memra/models.py,sha256=nTaYLAp0tRzQ0CQaBLNBURfhBQ5_gyty0ams4mghyIc,3289
5
- memra/tool_registry_client.py,sha256=KyNNxj84248E-8MoWNj6pJmlllUG8s0lmeXXmbu0U7o,3996
6
- memra-0.1.2.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- memra-0.1.2.dist-info/METADATA,sha256=gHIEJFsMqK7Bc-sIUgZ1LQS5tP3djey0_B3sZVWYINc,5640
8
- memra-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- memra-0.1.2.dist-info/top_level.txt,sha256=pXWcTRS1zctdiSUivW4iyKpJ4tcfIu-1BW_fpbal3OY,6
10
- memra-0.1.2.dist-info/RECORD,,