jaf-py 2.2.3__py3-none-any.whl → 2.2.4__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.
- jaf/core/engine.py +5 -1
- jaf/core/types.py +1 -0
- jaf/providers/model.py +5 -2
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/METADATA +143 -5
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/RECORD +9 -9
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/WHEEL +0 -0
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/entry_points.txt +0 -0
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/licenses/LICENSE +0 -0
- {jaf_py-2.2.3.dist-info → jaf_py-2.2.4.dist-info}/top_level.txt +0 -0
jaf/core/engine.py
CHANGED
|
@@ -91,7 +91,11 @@ async def run(
|
|
|
91
91
|
set_current_run_config(config)
|
|
92
92
|
|
|
93
93
|
if config.on_event:
|
|
94
|
-
config.on_event(RunStartEvent(data=to_event_data(RunStartEventData(
|
|
94
|
+
config.on_event(RunStartEvent(data=to_event_data(RunStartEventData(
|
|
95
|
+
run_id=initial_state.run_id,
|
|
96
|
+
trace_id=initial_state.trace_id,
|
|
97
|
+
session_id=config.conversation_id
|
|
98
|
+
))))
|
|
95
99
|
|
|
96
100
|
state_with_memory = await _load_conversation_history(initial_state, config)
|
|
97
101
|
result = await _run_internal(state_with_memory, config)
|
jaf/core/types.py
CHANGED
jaf/providers/model.py
CHANGED
|
@@ -51,8 +51,11 @@ def make_litellm_provider(
|
|
|
51
51
|
if proxies:
|
|
52
52
|
# Create httpx client with proxy configuration
|
|
53
53
|
try:
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
# Use the https proxy if available, otherwise http proxy
|
|
55
|
+
proxy_url = proxies.get('https://') or proxies.get('http://')
|
|
56
|
+
if proxy_url:
|
|
57
|
+
http_client = httpx.Client(proxy=proxy_url)
|
|
58
|
+
client_kwargs["http_client"] = http_client
|
|
56
59
|
except Exception as e:
|
|
57
60
|
print(f"Warning: Could not configure proxy: {e}")
|
|
58
61
|
# Fall back to environment variables for proxy
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaf-py
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.4
|
|
4
4
|
Summary: A purely functional agent framework with immutable state and composable tools - Python implementation
|
|
5
5
|
Author: JAF Contributors
|
|
6
6
|
Maintainer: JAF Contributors
|
|
@@ -73,7 +73,7 @@ Dynamic: license-file
|
|
|
73
73
|
|
|
74
74
|
<!--  -->
|
|
75
75
|
|
|
76
|
-
[](https://github.com/xynehq/jaf-py)
|
|
77
77
|
[](https://www.python.org/)
|
|
78
78
|
[](https://xynehq.github.io/jaf-py/)
|
|
79
79
|
|
|
@@ -114,15 +114,23 @@ A purely functional agent framework with immutable state and composable tools, p
|
|
|
114
114
|
|
|
115
115
|
### 📊 **Observability & Monitoring**
|
|
116
116
|
- ✅ **Real-time Tracing**: Event-driven observability
|
|
117
|
+
- ✅ **OpenTelemetry Integration**: Distributed tracing with OTLP
|
|
118
|
+
- ✅ **Langfuse Tracing**: LLM observability and analytics
|
|
117
119
|
- ✅ **Structured Logging**: JSON-formatted logs
|
|
118
120
|
- ✅ **Error Handling**: Comprehensive error types and recovery
|
|
119
121
|
- ✅ **Performance Metrics**: Built-in timing and counters
|
|
120
122
|
|
|
123
|
+
### 🤖 **Agent-as-Tool Architecture**
|
|
124
|
+
- ✅ **Hierarchical Orchestration**: Use agents as tools in other agents
|
|
125
|
+
- ✅ **Conditional Tool Enabling**: Enable/disable agent tools based on context
|
|
126
|
+
- ✅ **Session Management**: Configurable session inheritance for sub-agents
|
|
127
|
+
- ✅ **Flexible Output Extraction**: Custom extractors for agent tool outputs
|
|
128
|
+
|
|
121
129
|
### 🔧 **Developer Experience**
|
|
122
130
|
- ✅ **CLI Tools**: Project initialization and management
|
|
123
131
|
- ✅ **Hot Reload**: Development server with auto-reload
|
|
124
132
|
- ✅ **Type Hints**: Full mypy compatibility
|
|
125
|
-
- ✅ **Rich Examples**: RAG, multi-agent, and server demos
|
|
133
|
+
- ✅ **Rich Examples**: RAG, multi-agent, agent-as-tool, and server demos
|
|
126
134
|
- ✅ **Visual Architecture**: Graphviz-powered agent and tool diagrams
|
|
127
135
|
|
|
128
136
|
## 🎯 Core Philosophy
|
|
@@ -148,6 +156,7 @@ pip install "jaf-py[all] @ git+https://github.com/xynehq/jaf-py.git"
|
|
|
148
156
|
pip install "jaf-py[server] @ git+https://github.com/xynehq/jaf-py.git" # FastAPI server support
|
|
149
157
|
pip install "jaf-py[memory] @ git+https://github.com/xynehq/jaf-py.git" # Redis/PostgreSQL memory providers
|
|
150
158
|
pip install "jaf-py[visualization] @ git+https://github.com/xynehq/jaf-py.git" # Graphviz visualization tools
|
|
159
|
+
pip install "jaf-py[tracing] @ git+https://github.com/xynehq/jaf-py.git" # OpenTelemetry and Langfuse tracing
|
|
151
160
|
pip install "jaf-py[dev] @ git+https://github.com/xynehq/jaf-py.git" # Development tools
|
|
152
161
|
```
|
|
153
162
|
|
|
@@ -212,6 +221,7 @@ For offline access, documentation is also available in the [`docs/`](docs/) dire
|
|
|
212
221
|
- **[🔧 Tools Guide](docs/tools.md)** - Creating and using tools
|
|
213
222
|
- **[💾 Memory System](docs/memory-system.md)** - Persistence and memory providers
|
|
214
223
|
- **[🤖 Model Providers](docs/model-providers.md)** - LiteLLM integration
|
|
224
|
+
- **[📊 Monitoring](docs/monitoring.md)** - Observability, metrics, and alerting
|
|
215
225
|
- **[🌐 Server API](docs/server-api.md)** - FastAPI endpoints reference
|
|
216
226
|
- **[📦 Deployment](docs/deployment.md)** - Production deployment guide
|
|
217
227
|
- **[🎮 Examples](docs/examples.md)** - Detailed example walkthroughs
|
|
@@ -439,6 +449,58 @@ config = RunConfig(
|
|
|
439
449
|
)
|
|
440
450
|
```
|
|
441
451
|
|
|
452
|
+
## 🤖 Agent-as-Tool Functionality
|
|
453
|
+
|
|
454
|
+
JAF 2.2+ introduces powerful agent-as-tool capabilities, allowing you to use agents as tools within other agents for hierarchical orchestration:
|
|
455
|
+
|
|
456
|
+
```python
|
|
457
|
+
from jaf.core.agent_tool import create_agent_tool
|
|
458
|
+
from jaf.core.types import create_json_output_extractor
|
|
459
|
+
|
|
460
|
+
# Create specialized agents
|
|
461
|
+
spanish_agent = Agent(
|
|
462
|
+
name="spanish_translator",
|
|
463
|
+
instructions=lambda state: "Translate text to Spanish",
|
|
464
|
+
output_codec=TranslationOutput
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
french_agent = Agent(
|
|
468
|
+
name="french_translator",
|
|
469
|
+
instructions=lambda state: "Translate text to French",
|
|
470
|
+
output_codec=TranslationOutput
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# Convert agents to tools with conditional enabling
|
|
474
|
+
spanish_tool = spanish_agent.as_tool(
|
|
475
|
+
tool_name="translate_to_spanish",
|
|
476
|
+
tool_description="Translate text to Spanish",
|
|
477
|
+
max_turns=3,
|
|
478
|
+
custom_output_extractor=create_json_output_extractor(),
|
|
479
|
+
is_enabled=True # Always enabled
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
french_tool = french_agent.as_tool(
|
|
483
|
+
tool_name="translate_to_french",
|
|
484
|
+
tool_description="Translate text to French",
|
|
485
|
+
max_turns=3,
|
|
486
|
+
custom_output_extractor=create_json_output_extractor(),
|
|
487
|
+
is_enabled=lambda context, agent: context.language_preference == "french_spanish"
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
# Create orchestrator agent using agent tools
|
|
491
|
+
orchestrator = Agent(
|
|
492
|
+
name="translation_orchestrator",
|
|
493
|
+
instructions=lambda state: "Use translation tools to respond in multiple languages",
|
|
494
|
+
tools=[spanish_tool, french_tool]
|
|
495
|
+
)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Key Features:
|
|
499
|
+
- **Conditional Enabling**: Enable/disable agent tools based on runtime context
|
|
500
|
+
- **Session Management**: Configure whether sub-agents inherit parent session state
|
|
501
|
+
- **Custom Output Extraction**: Define how to extract and format agent tool outputs
|
|
502
|
+
- **Error Handling**: Robust error handling for failed agent tool executions
|
|
503
|
+
|
|
442
504
|
## 🔗 Agent Handoffs
|
|
443
505
|
|
|
444
506
|
```python
|
|
@@ -488,6 +550,48 @@ config = RunConfig(
|
|
|
488
550
|
)
|
|
489
551
|
```
|
|
490
552
|
|
|
553
|
+
### OpenTelemetry Integration
|
|
554
|
+
|
|
555
|
+
JAF 2.2+ includes built-in OpenTelemetry support for distributed tracing:
|
|
556
|
+
|
|
557
|
+
```python
|
|
558
|
+
import os
|
|
559
|
+
from jaf.core.tracing import create_composite_trace_collector, ConsoleTraceCollector
|
|
560
|
+
|
|
561
|
+
# Configure OpenTelemetry endpoint
|
|
562
|
+
os.environ["TRACE_COLLECTOR_URL"] = "http://localhost:4318/v1/traces"
|
|
563
|
+
|
|
564
|
+
# Tracing will be automatically configured when creating a composite collector
|
|
565
|
+
trace_collector = create_composite_trace_collector(ConsoleTraceCollector())
|
|
566
|
+
|
|
567
|
+
config = RunConfig(
|
|
568
|
+
# ... other config
|
|
569
|
+
on_event=trace_collector.collect,
|
|
570
|
+
)
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Langfuse Integration
|
|
574
|
+
|
|
575
|
+
For LLM-specific observability and analytics:
|
|
576
|
+
|
|
577
|
+
```python
|
|
578
|
+
import os
|
|
579
|
+
from jaf.core.tracing import create_composite_trace_collector, ConsoleTraceCollector
|
|
580
|
+
|
|
581
|
+
# Configure Langfuse credentials
|
|
582
|
+
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-your-public-key"
|
|
583
|
+
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-your-secret-key"
|
|
584
|
+
os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # or your self-hosted instance
|
|
585
|
+
|
|
586
|
+
# Langfuse tracing will be automatically configured
|
|
587
|
+
trace_collector = create_composite_trace_collector(ConsoleTraceCollector())
|
|
588
|
+
|
|
589
|
+
config = RunConfig(
|
|
590
|
+
# ... other config
|
|
591
|
+
on_event=trace_collector.collect,
|
|
592
|
+
)
|
|
593
|
+
```
|
|
594
|
+
|
|
491
595
|
### Error Handling
|
|
492
596
|
|
|
493
597
|
```python
|
|
@@ -663,7 +767,41 @@ python server_example.py
|
|
|
663
767
|
- `POST /chat` - Chat with any agent
|
|
664
768
|
- `GET /docs` - Interactive API documentation
|
|
665
769
|
|
|
666
|
-
### 2.
|
|
770
|
+
### 2. Agent-as-Tool Demo
|
|
771
|
+
|
|
772
|
+
```bash
|
|
773
|
+
cd examples
|
|
774
|
+
python agent_as_tool_example.py
|
|
775
|
+
|
|
776
|
+
# Or start as server
|
|
777
|
+
python agent_as_tool_example.py --server
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
**Features demonstrated:**
|
|
781
|
+
- ✅ Hierarchical agent orchestration
|
|
782
|
+
- ✅ Conditional tool enabling based on context
|
|
783
|
+
- ✅ Custom output extraction from agent tools
|
|
784
|
+
- ✅ Session management for sub-agents
|
|
785
|
+
- ✅ Translation agents working together
|
|
786
|
+
|
|
787
|
+
### 3. Tracing Integration Demos
|
|
788
|
+
|
|
789
|
+
```bash
|
|
790
|
+
# OpenTelemetry tracing example
|
|
791
|
+
cd examples
|
|
792
|
+
python otel_tracing_demo.py
|
|
793
|
+
|
|
794
|
+
# Langfuse tracing example
|
|
795
|
+
python langfuse_tracing_demo.py
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
**Features demonstrated:**
|
|
799
|
+
- ✅ OpenTelemetry distributed tracing setup
|
|
800
|
+
- ✅ Langfuse LLM observability integration
|
|
801
|
+
- ✅ Composite trace collectors
|
|
802
|
+
- ✅ Real-time monitoring and analytics
|
|
803
|
+
|
|
804
|
+
### 4. MCP Integration Demo
|
|
667
805
|
|
|
668
806
|
```bash
|
|
669
807
|
cd examples/mcp_demo
|
|
@@ -721,4 +859,4 @@ MIT
|
|
|
721
859
|
|
|
722
860
|
---
|
|
723
861
|
|
|
724
|
-
**JAF (Juspay Agentic Framework) v2.
|
|
862
|
+
**JAF (Juspay Agentic Framework) v2.2** - Building the future of functional AI agent systems 🚀
|
|
@@ -42,7 +42,7 @@ jaf/core/__init__.py,sha256=rBvP_7TGbJICDJnA7a3qyX8yQErCDWaGAn5WzpyH4gU,1339
|
|
|
42
42
|
jaf/core/agent_tool.py,sha256=8TcBuSxGmDTW5F_GhBU_m5S43nYqkjO4qTrNERraAig,11656
|
|
43
43
|
jaf/core/analytics.py,sha256=NrUfOLLTDIhOzdfc65ZqS9AJ4ZAP9BtNtga69q0YdYw,23265
|
|
44
44
|
jaf/core/composition.py,sha256=IVxRO1Q9nK7JRH32qQ4p8WMIUu66BhqPNrlTNMGFVwE,26317
|
|
45
|
-
jaf/core/engine.py,sha256=
|
|
45
|
+
jaf/core/engine.py,sha256=ydlF2m9GWyHXWAP6dng8sOwxEWcaaH8etkImorfY0aY,26954
|
|
46
46
|
jaf/core/errors.py,sha256=5fwTNhkojKRQ4wZj3lZlgDnAsrYyjYOwXJkIr5EGNUc,5539
|
|
47
47
|
jaf/core/performance.py,sha256=jedQmTEkrKMD6_Aw1h8PdG-5TsdYSFFT7Or6k5dmN2g,9974
|
|
48
48
|
jaf/core/proxy.py,sha256=_WM3cpRlSQLYpgSBrnY30UPMe2iZtlqDQ65kppE-WY0,4609
|
|
@@ -51,7 +51,7 @@ jaf/core/streaming.py,sha256=c5o9iqpjoYV2LrUpG6qLWCYrWcP-DCcZsvMbyqKunp8,16089
|
|
|
51
51
|
jaf/core/tool_results.py,sha256=-bTOqOX02lMyslp5Z4Dmuhx0cLd5o7kgR88qK2HO_sw,11323
|
|
52
52
|
jaf/core/tools.py,sha256=SbJRRr4y_xxNYNTulZg6OiyNaHBlo_qXWYY510jxQEs,16489
|
|
53
53
|
jaf/core/tracing.py,sha256=r96LCi4dV7BSoqVuFMXI7j72G9jOwpbEjnhYqubuQzc,23455
|
|
54
|
-
jaf/core/types.py,sha256=
|
|
54
|
+
jaf/core/types.py,sha256=fF7_UMFTPUzGQQxZ9tGoWdjF5LSI02RHoJ9vvSe3W8I,16905
|
|
55
55
|
jaf/core/workflows.py,sha256=Ul-82gzjIXtkhnSMSPv-8igikjkMtW1EBo9yrfodtvI,26294
|
|
56
56
|
jaf/memory/__init__.py,sha256=-L98xlvihurGAzF0DnXtkueDVvO_wV2XxxEwAWdAj50,1400
|
|
57
57
|
jaf/memory/factory.py,sha256=Fh6JyvQtCKe38DZV5-NnC9vPRCvzBgSSPFIGaX7Nt5E,2958
|
|
@@ -68,7 +68,7 @@ jaf/policies/handoff.py,sha256=KJYYuL9T6v6DECRhnsS2Je6q4Aj9_zC5d_KBnvEnZNE,8318
|
|
|
68
68
|
jaf/policies/validation.py,sha256=wn-7ynH10E5nk-_r1_kHIYHrBGmLX0EFr-FUTHrsxvc,10903
|
|
69
69
|
jaf/providers/__init__.py,sha256=j_o-Rubr8d9tNYlFWb6fvzkxIBl3JKK_iabj9wTFia0,2114
|
|
70
70
|
jaf/providers/mcp.py,sha256=WxcC8gUFpDBBYyhorMcc1jHq3xMDMBtnwyRPthfL0S0,13074
|
|
71
|
-
jaf/providers/model.py,sha256=
|
|
71
|
+
jaf/providers/model.py,sha256=9w2mph6g1TaLOFp3t0VtN2kYEfTa-lyYAVjAqQg3wrU,7748
|
|
72
72
|
jaf/server/__init__.py,sha256=K0vSgTfzn3oM54UX9BeAROpaksYY43mFtfjSXoQrhXA,339
|
|
73
73
|
jaf/server/main.py,sha256=CTb0ywbPIq9ELfay5MKChVR7BpIQOoEbPjPfpzo2aBQ,2152
|
|
74
74
|
jaf/server/server.py,sha256=o-n6dPWmlu4_v5ozVW3BTOm1b5kHBQhqRYlHh5sXL-k,8048
|
|
@@ -79,9 +79,9 @@ jaf/visualization/functional_core.py,sha256=zedMDZbvjuOugWwnh6SJ2stvRNQX1Hlkb9Ab
|
|
|
79
79
|
jaf/visualization/graphviz.py,sha256=WTOM6UP72-lVKwI4_SAr5-GCC3ouckxHv88ypCDQWJ0,12056
|
|
80
80
|
jaf/visualization/imperative_shell.py,sha256=GpMrAlMnLo2IQgyB2nardCz09vMvAzaYI46MyrvJ0i4,2593
|
|
81
81
|
jaf/visualization/types.py,sha256=QQcbVeQJLuAOXk8ynd08DXIS-PVCnv3R-XVE9iAcglw,1389
|
|
82
|
-
jaf_py-2.2.
|
|
83
|
-
jaf_py-2.2.
|
|
84
|
-
jaf_py-2.2.
|
|
85
|
-
jaf_py-2.2.
|
|
86
|
-
jaf_py-2.2.
|
|
87
|
-
jaf_py-2.2.
|
|
82
|
+
jaf_py-2.2.4.dist-info/licenses/LICENSE,sha256=LXUQBJxdyr-7C4bk9cQBwvsF_xwA-UVstDTKabpcjlI,1063
|
|
83
|
+
jaf_py-2.2.4.dist-info/METADATA,sha256=LRWLY4HHpn57BSrHesTA1i5gXSP95zA7Wt1vjIx5P7w,27613
|
|
84
|
+
jaf_py-2.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
85
|
+
jaf_py-2.2.4.dist-info/entry_points.txt,sha256=OtIJeNJpb24kgGrqRx9szGgDx1vL9ayq8uHErmu7U5w,41
|
|
86
|
+
jaf_py-2.2.4.dist-info/top_level.txt,sha256=Xu1RZbGaM4_yQX7bpalo881hg7N_dybaOW282F15ruE,4
|
|
87
|
+
jaf_py-2.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|