agentium 2.0.0__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.
- agentium/__init__.py +122 -0
- agentium/_meta.py +11 -0
- agentium/_v1/__init__.py +301 -0
- agentium/_v1/core/__init__.py +1 -0
- agentium/_v1/core/communicator.py +575 -0
- agentium/_v1/core/condenser.py +330 -0
- agentium/_v1/core/extractor.py +737 -0
- agentium/_v1/core/insight_generator.py +522 -0
- agentium/_v1/core/memory_helper.py +647 -0
- agentium/_v1/core/optimizer.py +502 -0
- agentium/_v1/core/rearranger.py +599 -0
- agentium/_v1/core/summarize_custom.py +689 -0
- agentium/_v1/core/template_manager.py +516 -0
- agentium/_v1/core/translator.py +524 -0
- agentium/_v1/core/workflow_helper.py +530 -0
- agentium/_v1/integrations/__init__.py +467 -0
- agentium/_v1/integrations/gemini.py +358 -0
- agentium/_v1/integrations/langchain.py +468 -0
- agentium/_v1/integrations/langgraph.py +601 -0
- agentium/_v1/utils/__init__.py +1 -0
- agentium/_v1/utils/logger_utils.py +392 -0
- agentium/adapters/__init__.py +55 -0
- agentium/adapters/cachetools_adapter.py +107 -0
- agentium/adapters/crewai_adapter.py +71 -0
- agentium/adapters/deepdiff_adapter.py +32 -0
- agentium/adapters/httpx_adapter.py +43 -0
- agentium/adapters/jmespath_adapter.py +37 -0
- agentium/adapters/jsonrepair_adapter.py +46 -0
- agentium/adapters/jsonschema_adapter.py +41 -0
- agentium/adapters/langgraph_adapter.py +87 -0
- agentium/adapters/litellm_adapter.py +37 -0
- agentium/adapters/mcp_adapter.py +64 -0
- agentium/adapters/openai_agents_adapter.py +84 -0
- agentium/adapters/plain.py +177 -0
- agentium/adapters/pybreaker_adapter.py +83 -0
- agentium/adapters/pydantic_adapter.py +58 -0
- agentium/adapters/rapidfuzz_adapter.py +37 -0
- agentium/adapters/tenacity_adapter.py +94 -0
- agentium/adapters/tiktoken_adapter.py +51 -0
- agentium/cli/doctor_cmd.py +265 -0
- agentium/cli/init_cmd.py +182 -0
- agentium/cli/main.py +399 -0
- agentium/core/__init__.py +58 -0
- agentium/core/communicator.py +10 -0
- agentium/core/condenser.py +11 -0
- agentium/core/config.py +209 -0
- agentium/core/events.py +213 -0
- agentium/core/extractor.py +10 -0
- agentium/core/hashing.py +75 -0
- agentium/core/insight_generator.py +10 -0
- agentium/core/memory_helper.py +10 -0
- agentium/core/optimizer.py +10 -0
- agentium/core/otel.py +30 -0
- agentium/core/rearranger.py +25 -0
- agentium/core/redact.py +98 -0
- agentium/core/run.py +112 -0
- agentium/core/summarize_custom.py +10 -0
- agentium/core/template_manager.py +10 -0
- agentium/core/tokens.py +27 -0
- agentium/core/translator.py +10 -0
- agentium/core/workflow_helper.py +10 -0
- agentium/fingerprint/__init__.py +13 -0
- agentium/fingerprint/diff.py +155 -0
- agentium/fingerprint/fp.py +184 -0
- agentium/fingerprint/lock.py +102 -0
- agentium/hub/__init__.py +16 -0
- agentium/hub/facade.py +50 -0
- agentium/hub/plugins.py +52 -0
- agentium/hub/wrapper.py +196 -0
- agentium/integrations/__init__.py +10 -0
- agentium/integrations/crewai.py +14 -0
- agentium/integrations/gemini.py +16 -0
- agentium/integrations/langchain.py +35 -0
- agentium/integrations/langgraph.py +43 -0
- agentium/lineage/__init__.py +29 -0
- agentium/lineage/claims.py +250 -0
- agentium/lineage/gate.py +141 -0
- agentium/lineage/graph.py +315 -0
- agentium/lineage/handoff.py +211 -0
- agentium/lineage/verify.py +74 -0
- agentium/pin/__init__.py +25 -0
- agentium/pin/guard.py +122 -0
- agentium/pin/soak.py +154 -0
- agentium/pin/store.py +137 -0
- agentium/py.typed +1 -0
- agentium/recipes/__init__.py +80 -0
- agentium/recipes/api_call_safe.py +142 -0
- agentium/recipes/budget_llm.py +157 -0
- agentium/recipes/cached_tool.py +149 -0
- agentium/recipes/drift_report.py +117 -0
- agentium/recipes/fuzzy_dedupe_cache.py +176 -0
- agentium/recipes/fuzzy_verify.py +133 -0
- agentium/recipes/graph_retry.py +147 -0
- agentium/recipes/graph_tracing.py +112 -0
- agentium/recipes/http_cache_tool.py +117 -0
- agentium/recipes/llm_failover.py +163 -0
- agentium/recipes/mcp_bridge.py +137 -0
- agentium/recipes/mcp_safe_tools.py +173 -0
- agentium/recipes/protected_handoff.py +141 -0
- agentium/recipes/safe_call.py +160 -0
- agentium/recipes/smart_compact.py +107 -0
- agentium/recipes/structured_llm.py +120 -0
- agentium/recipes/traced_retry.py +208 -0
- agentium/recipes/typed_agent_tools.py +157 -0
- agentium/recipes/validated_tool_args.py +185 -0
- agentium/recipes/verified_extract.py +88 -0
- agentium/speed/__init__.py +7 -0
- agentium/speed/prefetch.py +209 -0
- agentium/utils/__init__.py +1 -0
- agentium/utils/logger_utils.py +10 -0
- agentium-2.0.0.dist-info/METADATA +580 -0
- agentium-2.0.0.dist-info/RECORD +115 -0
- agentium-2.0.0.dist-info/WHEEL +5 -0
- agentium-2.0.0.dist-info/entry_points.txt +2 -0
- agentium-2.0.0.dist-info/top_level.txt +1 -0
agentium/__init__.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agentium v2 — Context & trust integrity toolkit for multi-agent and long-running AI agents.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import warnings
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from ._meta import VERSION as __version__, AUTHOR as __author__, LICENSE as __license__
|
|
11
|
+
|
|
12
|
+
# Core v2 Foundation Exports
|
|
13
|
+
from .core.run import run, get_current_run, RunContext
|
|
14
|
+
from .adapters.plain import tool, get_tool_registry, ToolRegistry
|
|
15
|
+
from .core.events import Event, EventType, EventWriter, EventReader
|
|
16
|
+
from .core.config import load_config, AgentiumConfig
|
|
17
|
+
from .core.redact import Redactor, redact_payload
|
|
18
|
+
from .core.hashing import canonical_json, sha256_hex
|
|
19
|
+
from .core.tokens import estimate_tokens, set_tokenizer
|
|
20
|
+
|
|
21
|
+
# v2 Pin & Context Integrity Exports
|
|
22
|
+
from .pin.store import Pin, PinStore
|
|
23
|
+
from .pin.guard import reinject, guard_compaction
|
|
24
|
+
from .pin.soak import soak, TruncateCompactor, LastNCompactor, StubSummarizer
|
|
25
|
+
|
|
26
|
+
# v2 Lineage, Claims, Handoff & Action Gate Exports
|
|
27
|
+
from .lineage.claims import Claim, EvidenceRef, ClaimStore
|
|
28
|
+
from .lineage.verify import verifier, register_verifier, get_verifier, JsonFieldExtractor
|
|
29
|
+
from .lineage.graph import LineageGraph, BlameReport, LineageDiff, diff_lineage
|
|
30
|
+
from .lineage.handoff import HandoffPacket, HandoffOverflowError, lint_handoff, enforce_handoff_size
|
|
31
|
+
from .lineage.gate import ActionGate, ActionBlockedError, guarded
|
|
32
|
+
|
|
33
|
+
# v2 Fingerprint & Drift Exports
|
|
34
|
+
from .fingerprint.fp import Fingerprint, fingerprint
|
|
35
|
+
from .fingerprint.lock import LockFile, read_lock_file, write_lock_file
|
|
36
|
+
from .fingerprint.diff import DriftReport, diff_fingerprints
|
|
37
|
+
|
|
38
|
+
# v2 Experimental Acceleration Exports
|
|
39
|
+
from .speed.prefetch import PrefetchManager, ToolPredictor
|
|
40
|
+
|
|
41
|
+
# v2 Hub, Wrapper, Facade & Recipe Exports
|
|
42
|
+
from .hub.wrapper import wrap, wrap_async
|
|
43
|
+
from .hub.facade import use
|
|
44
|
+
from .hub.plugins import discover_plugins, get_plugin
|
|
45
|
+
from . import recipes
|
|
46
|
+
|
|
47
|
+
# v1 Public Names preserved for backward compatibility
|
|
48
|
+
_V1_NAMES = {
|
|
49
|
+
"Agentium",
|
|
50
|
+
"Condenser",
|
|
51
|
+
"CondenserConfig",
|
|
52
|
+
"Optimizer",
|
|
53
|
+
"OptimizerConfig",
|
|
54
|
+
"Rearranger",
|
|
55
|
+
"RearrangerConfig",
|
|
56
|
+
"Communicator",
|
|
57
|
+
"CommunicatorConfig",
|
|
58
|
+
"Extractor",
|
|
59
|
+
"ExtractorConfig",
|
|
60
|
+
"Translator",
|
|
61
|
+
"TranslatorConfig",
|
|
62
|
+
"InsightGenerator",
|
|
63
|
+
"InsightConfig",
|
|
64
|
+
"WorkflowHelper",
|
|
65
|
+
"WorkflowConfig",
|
|
66
|
+
"TemplateManager",
|
|
67
|
+
"TemplateConfig",
|
|
68
|
+
"MemoryHelper",
|
|
69
|
+
"MemoryConfig",
|
|
70
|
+
"CustomSummarizer",
|
|
71
|
+
"SummaryConfig",
|
|
72
|
+
"LoggerUtils",
|
|
73
|
+
"LoggerConfig",
|
|
74
|
+
"LANGCHAIN_INTEGRATION_AVAILABLE",
|
|
75
|
+
"LANGGRAPH_INTEGRATION_AVAILABLE",
|
|
76
|
+
"CREWAI_INTEGRATION_AVAILABLE",
|
|
77
|
+
"GEMINI_INTEGRATION_AVAILABLE",
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def __getattr__(name: str) -> Any:
|
|
82
|
+
if name in _V1_NAMES:
|
|
83
|
+
warnings.warn(
|
|
84
|
+
f"'{name}' is part of the Agentium v1 text-processing toolkit and is deprecated in Agentium v2.",
|
|
85
|
+
DeprecationWarning,
|
|
86
|
+
stacklevel=2,
|
|
87
|
+
)
|
|
88
|
+
from . import _v1
|
|
89
|
+
|
|
90
|
+
return getattr(_v1, name)
|
|
91
|
+
raise AttributeError(f"module 'agentium' has no attribute '{name}'")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
__all__ = [
|
|
95
|
+
"__version__",
|
|
96
|
+
"__author__",
|
|
97
|
+
"__license__",
|
|
98
|
+
"run",
|
|
99
|
+
"get_current_run",
|
|
100
|
+
"RunContext",
|
|
101
|
+
"tool",
|
|
102
|
+
"get_tool_registry",
|
|
103
|
+
"ToolRegistry",
|
|
104
|
+
"Event",
|
|
105
|
+
"EventType",
|
|
106
|
+
"EventWriter",
|
|
107
|
+
"EventReader",
|
|
108
|
+
"load_config",
|
|
109
|
+
"AgentiumConfig",
|
|
110
|
+
"Redactor",
|
|
111
|
+
"redact_payload",
|
|
112
|
+
"canonical_json",
|
|
113
|
+
"sha256_hex",
|
|
114
|
+
"estimate_tokens",
|
|
115
|
+
"set_tokenizer",
|
|
116
|
+
"wrap",
|
|
117
|
+
"wrap_async",
|
|
118
|
+
"use",
|
|
119
|
+
"discover_plugins",
|
|
120
|
+
"get_plugin",
|
|
121
|
+
"recipes",
|
|
122
|
+
] + list(_V1_NAMES)
|
agentium/_meta.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Package metadata and centralized configuration values."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
# Central package name variable to allow frictionless renaming
|
|
7
|
+
PACKAGE_NAME = os.environ.get("AGENTIUM_PACKAGE_NAME", "agentium")
|
|
8
|
+
VERSION = "2.0.0"
|
|
9
|
+
AUTHOR = "Sanjay N"
|
|
10
|
+
LICENSE = "MIT"
|
|
11
|
+
PLUGIN_ENTRYPOINT_GROUP = "agentium.plugins"
|
agentium/_v1/__init__.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agentium - Comprehensive Python Library for AI Agent Development
|
|
3
|
+
|
|
4
|
+
A production-ready library providing essential tools and utilities for
|
|
5
|
+
building intelligent AI agents, compatible with LangChain, LangGraph, and CrewAI.
|
|
6
|
+
|
|
7
|
+
Core Features:
|
|
8
|
+
- Content condensation and optimization
|
|
9
|
+
- Data extraction and processing
|
|
10
|
+
- Multi-channel communication
|
|
11
|
+
- Translation and localization
|
|
12
|
+
- Insight generation and analysis
|
|
13
|
+
- Workflow orchestration
|
|
14
|
+
- Template management
|
|
15
|
+
- Memory and context storage
|
|
16
|
+
- Custom summarization
|
|
17
|
+
- Advanced logging and monitoring
|
|
18
|
+
|
|
19
|
+
Framework Integrations:
|
|
20
|
+
- LangChain: Tools, memory, parsers, callbacks
|
|
21
|
+
- LangGraph: Workflow nodes, state management
|
|
22
|
+
- CrewAI: Enhanced agents, tasks, crews
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__version__ = "1.0.0"
|
|
26
|
+
__author__ = "Agentium Development Team"
|
|
27
|
+
__license__ = "MIT"
|
|
28
|
+
|
|
29
|
+
# Core components
|
|
30
|
+
from .core.condenser import Condenser, CondenserConfig
|
|
31
|
+
from .core.optimizer import Optimizer, OptimizerConfig
|
|
32
|
+
from .core.rearranger import Rearranger, RearrangerConfig
|
|
33
|
+
from .core.extractor import Extractor, ExtractorConfig
|
|
34
|
+
from .core.communicator import Communicator, CommunicatorConfig
|
|
35
|
+
from .core.translator import Translator, TranslatorConfig
|
|
36
|
+
from .core.insight_generator import InsightGenerator, InsightConfig
|
|
37
|
+
from .core.workflow_helper import WorkflowHelper, WorkflowConfig
|
|
38
|
+
from .core.template_manager import TemplateManager, TemplateConfig
|
|
39
|
+
from .core.memory_helper import MemoryHelper, MemoryConfig
|
|
40
|
+
from .core.summarize_custom import CustomSummarizer, SummaryConfig
|
|
41
|
+
|
|
42
|
+
# Utilities
|
|
43
|
+
from .utils.logger_utils import LoggerUtils, LoggerConfig
|
|
44
|
+
|
|
45
|
+
# Integrations (with optional imports)
|
|
46
|
+
try:
|
|
47
|
+
from .integrations.langchain import (
|
|
48
|
+
get_agentium_langchain_integration,
|
|
49
|
+
AgentiumLangChainIntegration,
|
|
50
|
+
AgentiumMemory,
|
|
51
|
+
AgentiumOutputParser,
|
|
52
|
+
AgentiumCallbackHandler
|
|
53
|
+
)
|
|
54
|
+
LANGCHAIN_INTEGRATION_AVAILABLE = True
|
|
55
|
+
except Exception:
|
|
56
|
+
LANGCHAIN_INTEGRATION_AVAILABLE = False
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
from .integrations.langgraph import (
|
|
60
|
+
get_agentium_langgraph_integration,
|
|
61
|
+
AgentiumLangGraphIntegration,
|
|
62
|
+
AgentiumLangGraphBuilder,
|
|
63
|
+
AgentiumLangGraphWorkflow
|
|
64
|
+
)
|
|
65
|
+
LANGGRAPH_INTEGRATION_AVAILABLE = True
|
|
66
|
+
except Exception:
|
|
67
|
+
LANGGRAPH_INTEGRATION_AVAILABLE = False
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
from .integrations.gemini import (
|
|
71
|
+
GeminiIntegration,
|
|
72
|
+
GeminiConfig,
|
|
73
|
+
GeminiModel,
|
|
74
|
+
get_gemini_integration
|
|
75
|
+
)
|
|
76
|
+
GEMINI_INTEGRATION_AVAILABLE = True
|
|
77
|
+
except Exception:
|
|
78
|
+
GEMINI_INTEGRATION_AVAILABLE = False
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
import crewai # type: ignore
|
|
82
|
+
CREWAI_INTEGRATION_AVAILABLE = True
|
|
83
|
+
except Exception:
|
|
84
|
+
CREWAI_INTEGRATION_AVAILABLE = False
|
|
85
|
+
|
|
86
|
+
# Main exports
|
|
87
|
+
__all__ = [
|
|
88
|
+
# Version and metadata
|
|
89
|
+
'__version__',
|
|
90
|
+
'__author__',
|
|
91
|
+
'__license__',
|
|
92
|
+
|
|
93
|
+
# Core components
|
|
94
|
+
'Condenser',
|
|
95
|
+
'CondenserConfig',
|
|
96
|
+
'Optimizer',
|
|
97
|
+
'OptimizerConfig',
|
|
98
|
+
'Rearranger',
|
|
99
|
+
'RearrangerConfig',
|
|
100
|
+
'Extractor',
|
|
101
|
+
'ExtractorConfig',
|
|
102
|
+
'Communicator',
|
|
103
|
+
'CommunicatorConfig',
|
|
104
|
+
'Translator',
|
|
105
|
+
'TranslatorConfig',
|
|
106
|
+
'InsightGenerator',
|
|
107
|
+
'InsightConfig',
|
|
108
|
+
'WorkflowHelper',
|
|
109
|
+
'WorkflowConfig',
|
|
110
|
+
'TemplateManager',
|
|
111
|
+
'TemplateConfig',
|
|
112
|
+
'MemoryHelper',
|
|
113
|
+
'MemoryConfig',
|
|
114
|
+
'CustomSummarizer',
|
|
115
|
+
'SummaryConfig',
|
|
116
|
+
|
|
117
|
+
# Utilities
|
|
118
|
+
'LoggerUtils',
|
|
119
|
+
'LoggerConfig',
|
|
120
|
+
|
|
121
|
+
# Integration flags
|
|
122
|
+
'LANGCHAIN_INTEGRATION_AVAILABLE',
|
|
123
|
+
'LANGGRAPH_INTEGRATION_AVAILABLE',
|
|
124
|
+
'GEMINI_INTEGRATION_AVAILABLE',
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
# Add integration exports if available
|
|
128
|
+
if LANGCHAIN_INTEGRATION_AVAILABLE:
|
|
129
|
+
__all__.extend([
|
|
130
|
+
'get_agentium_langchain_integration',
|
|
131
|
+
'AgentiumLangChainIntegration',
|
|
132
|
+
'AgentiumMemory',
|
|
133
|
+
'AgentiumOutputParser',
|
|
134
|
+
'AgentiumCallbackHandler'
|
|
135
|
+
])
|
|
136
|
+
|
|
137
|
+
if LANGGRAPH_INTEGRATION_AVAILABLE:
|
|
138
|
+
__all__.extend([
|
|
139
|
+
'get_agentium_langgraph_integration',
|
|
140
|
+
'AgentiumLangGraphIntegration',
|
|
141
|
+
'AgentiumLangGraphBuilder',
|
|
142
|
+
'AgentiumLangGraphWorkflow'
|
|
143
|
+
])
|
|
144
|
+
|
|
145
|
+
if GEMINI_INTEGRATION_AVAILABLE:
|
|
146
|
+
__all__.extend([
|
|
147
|
+
'GeminiIntegration',
|
|
148
|
+
'GeminiConfig',
|
|
149
|
+
'GeminiModel',
|
|
150
|
+
'get_gemini_integration'
|
|
151
|
+
])
|
|
152
|
+
|
|
153
|
+
from typing import Optional, Dict, Any
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class Agentium:
|
|
157
|
+
"""
|
|
158
|
+
Main Agentium class providing unified access to all components.
|
|
159
|
+
|
|
160
|
+
This class serves as a convenient entry point for accessing all
|
|
161
|
+
Agentium functionality in a single interface.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
def __init__(self, logger_config: Optional[LoggerConfig] = None):
|
|
165
|
+
"""Initialize Agentium with optional logging configuration"""
|
|
166
|
+
self.logger = LoggerUtils.get_logger(__name__)
|
|
167
|
+
|
|
168
|
+
if logger_config:
|
|
169
|
+
LoggerUtils.configure(logger_config)
|
|
170
|
+
|
|
171
|
+
# Initialize core components
|
|
172
|
+
self.condenser = Condenser()
|
|
173
|
+
self.optimizer = Optimizer()
|
|
174
|
+
self.rearranger = Rearranger()
|
|
175
|
+
self.extractor = Extractor()
|
|
176
|
+
self.communicator = Communicator()
|
|
177
|
+
self.translator = Translator()
|
|
178
|
+
self.insight_generator = InsightGenerator()
|
|
179
|
+
self.workflow_helper = WorkflowHelper()
|
|
180
|
+
self.template_manager = TemplateManager()
|
|
181
|
+
self.memory_helper = MemoryHelper()
|
|
182
|
+
self.summarizer = CustomSummarizer()
|
|
183
|
+
|
|
184
|
+
# Initialize integrations
|
|
185
|
+
self._init_integrations()
|
|
186
|
+
|
|
187
|
+
self.logger.info("Agentium initialized with all core components")
|
|
188
|
+
|
|
189
|
+
def _init_integrations(self):
|
|
190
|
+
"""Initialize framework integrations"""
|
|
191
|
+
self.langchain_integration = None
|
|
192
|
+
self.langgraph_integration = None
|
|
193
|
+
self.gemini_integration = None
|
|
194
|
+
|
|
195
|
+
if LANGCHAIN_INTEGRATION_AVAILABLE:
|
|
196
|
+
try:
|
|
197
|
+
self.langchain_integration = get_agentium_langchain_integration()
|
|
198
|
+
self.logger.info("LangChain integration initialized")
|
|
199
|
+
except Exception as e:
|
|
200
|
+
self.logger.warning(f"Failed to initialize LangChain integration: {e}")
|
|
201
|
+
|
|
202
|
+
if LANGGRAPH_INTEGRATION_AVAILABLE:
|
|
203
|
+
try:
|
|
204
|
+
self.langgraph_integration = get_agentium_langgraph_integration()
|
|
205
|
+
self.logger.info("LangGraph integration initialized")
|
|
206
|
+
except Exception as e:
|
|
207
|
+
self.logger.warning(f"Failed to initialize LangGraph integration: {e}")
|
|
208
|
+
|
|
209
|
+
if GEMINI_INTEGRATION_AVAILABLE:
|
|
210
|
+
try:
|
|
211
|
+
self.gemini_integration = get_gemini_integration()
|
|
212
|
+
self.logger.info("Gemini integration initialized")
|
|
213
|
+
except Exception as e:
|
|
214
|
+
self.logger.warning(f"Failed to initialize Gemini integration: {e}")
|
|
215
|
+
|
|
216
|
+
def get_integration_status(self) -> Dict[str, bool]:
|
|
217
|
+
"""Get the status of all integrations"""
|
|
218
|
+
return {
|
|
219
|
+
'langchain': LANGCHAIN_INTEGRATION_AVAILABLE and self.langchain_integration is not None,
|
|
220
|
+
'langgraph': LANGGRAPH_INTEGRATION_AVAILABLE and self.langgraph_integration is not None,
|
|
221
|
+
'gemini': GEMINI_INTEGRATION_AVAILABLE and self.gemini_integration is not None,
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
def process_content(self, content: str, workflow: str = "basic") -> Dict[str, Any]:
|
|
225
|
+
"""
|
|
226
|
+
Process content through a predefined workflow
|
|
227
|
+
|
|
228
|
+
Available workflows:
|
|
229
|
+
- basic: condense -> optimize -> summarize
|
|
230
|
+
- analysis: extract -> insights -> summarize
|
|
231
|
+
- translation: translate -> optimize -> summarize
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
results = {'workflow': workflow, 'steps': []}
|
|
235
|
+
|
|
236
|
+
try:
|
|
237
|
+
if workflow == "basic":
|
|
238
|
+
# Condense -> Optimize -> Summarize
|
|
239
|
+
condensed_result = self.condenser.condense(content)
|
|
240
|
+
condensed_text = condensed_result.get('text') if isinstance(condensed_result, dict) else condensed_result
|
|
241
|
+
results['steps'].append({'step': 'condense', 'result': condensed_result})
|
|
242
|
+
|
|
243
|
+
optimized_result = self.optimizer.optimize(condensed_text)
|
|
244
|
+
optimized_text = optimized_result.get('text') if isinstance(optimized_result, dict) else optimized_result
|
|
245
|
+
results['steps'].append({'step': 'optimize', 'result': optimized_result})
|
|
246
|
+
|
|
247
|
+
summarized_result = self.summarizer.summarize(optimized_text)
|
|
248
|
+
summarized = summarized_result if isinstance(summarized_result, dict) else {'summary': summarized_result}
|
|
249
|
+
results['steps'].append({'step': 'summarize', 'result': summarized})
|
|
250
|
+
|
|
251
|
+
results['final_output'] = summarized.get('summary', str(summarized))
|
|
252
|
+
|
|
253
|
+
elif workflow == "analysis":
|
|
254
|
+
# Extract -> Insights -> Summarize
|
|
255
|
+
extracted_result = self.extractor.extract(content)
|
|
256
|
+
extracted = extracted_result if isinstance(extracted_result, dict) else {'extracted_data': extracted_result}
|
|
257
|
+
results['steps'].append({'step': 'extract', 'result': extracted})
|
|
258
|
+
|
|
259
|
+
insights_result = self.insight_generator.generate_insights(str(extracted['extracted_data']))
|
|
260
|
+
insights = insights_result if isinstance(insights_result, dict) else {'insights': insights_result}
|
|
261
|
+
results['steps'].append({'step': 'insights', 'result': insights})
|
|
262
|
+
|
|
263
|
+
data_str = str(extracted['extracted_data'])
|
|
264
|
+
insights_str = str(insights.get('insights', insights))
|
|
265
|
+
summarized_result = self.summarizer.summarize(f"Data: {data_str} Insights: {insights_str}")
|
|
266
|
+
summarized = summarized_result if isinstance(summarized_result, dict) else {'summary': summarized_result}
|
|
267
|
+
results['steps'].append({'step': 'summarize', 'result': summarized})
|
|
268
|
+
|
|
269
|
+
results['final_output'] = summarized.get('summary', str(summarized))
|
|
270
|
+
|
|
271
|
+
elif workflow == "translation":
|
|
272
|
+
# Translate -> Optimize -> Summarize
|
|
273
|
+
translated_result = self.translator.translate(content)
|
|
274
|
+
translated = translated_result if isinstance(translated_result, dict) else {'translated_text': translated_result}
|
|
275
|
+
results['steps'].append({'step': 'translate', 'result': translated})
|
|
276
|
+
|
|
277
|
+
optimized_result = self.optimizer.optimize(translated['translated_text'])
|
|
278
|
+
optimized = optimized_result if isinstance(optimized_result, dict) else {'optimized_content': optimized_result}
|
|
279
|
+
results['steps'].append({'step': 'optimize', 'result': optimized})
|
|
280
|
+
|
|
281
|
+
summarized_result = self.summarizer.summarize(optimized['optimized_content'])
|
|
282
|
+
summarized = summarized_result if isinstance(summarized_result, dict) else {'summary': summarized_result}
|
|
283
|
+
results['steps'].append({'step': 'summarize', 'result': summarized})
|
|
284
|
+
|
|
285
|
+
results['final_output'] = summarized.get('summary', str(summarized))
|
|
286
|
+
|
|
287
|
+
else:
|
|
288
|
+
raise ValueError(f"Unknown workflow: {workflow}")
|
|
289
|
+
|
|
290
|
+
results['success'] = True
|
|
291
|
+
|
|
292
|
+
except Exception as e:
|
|
293
|
+
results['success'] = False
|
|
294
|
+
results['error'] = str(e)
|
|
295
|
+
self.logger.error(f"Workflow {workflow} failed: {e}")
|
|
296
|
+
|
|
297
|
+
return results
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
# Add to main exports
|
|
301
|
+
__all__.extend(['Agentium'])
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Core package initialization
|