crca 1.4.0__py3-none-any.whl → 1.5.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.
- CRCA.py +172 -7
- MODEL_CARD.md +53 -0
- PKG-INFO +8 -2
- RELEASE_NOTES.md +17 -0
- STABILITY.md +19 -0
- architecture/hybrid/consistency_engine.py +362 -0
- architecture/hybrid/conversation_manager.py +421 -0
- architecture/hybrid/explanation_generator.py +452 -0
- architecture/hybrid/few_shot_learner.py +533 -0
- architecture/hybrid/graph_compressor.py +286 -0
- architecture/hybrid/hybrid_agent.py +4398 -0
- architecture/hybrid/language_compiler.py +623 -0
- architecture/hybrid/main,py +0 -0
- architecture/hybrid/reasoning_tracker.py +322 -0
- architecture/hybrid/self_verifier.py +524 -0
- architecture/hybrid/task_decomposer.py +567 -0
- architecture/hybrid/text_corrector.py +341 -0
- benchmark_results/crca_core_benchmarks.json +178 -0
- branches/crca_sd/crca_sd_realtime.py +6 -2
- branches/general_agent/__init__.py +102 -0
- branches/general_agent/general_agent.py +1400 -0
- branches/general_agent/personality.py +169 -0
- branches/general_agent/utils/__init__.py +19 -0
- branches/general_agent/utils/prompt_builder.py +170 -0
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/METADATA +8 -2
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/RECORD +303 -20
- crca_core/__init__.py +35 -0
- crca_core/benchmarks/__init__.py +14 -0
- crca_core/benchmarks/synthetic_scm.py +103 -0
- crca_core/core/__init__.py +23 -0
- crca_core/core/api.py +120 -0
- crca_core/core/estimate.py +208 -0
- crca_core/core/godclass.py +72 -0
- crca_core/core/intervention_design.py +174 -0
- crca_core/core/lifecycle.py +48 -0
- crca_core/discovery/__init__.py +9 -0
- crca_core/discovery/tabular.py +193 -0
- crca_core/identify/__init__.py +171 -0
- crca_core/identify/backdoor.py +39 -0
- crca_core/identify/frontdoor.py +48 -0
- crca_core/identify/graph.py +106 -0
- crca_core/identify/id_algorithm.py +43 -0
- crca_core/identify/iv.py +48 -0
- crca_core/models/__init__.py +67 -0
- crca_core/models/provenance.py +56 -0
- crca_core/models/refusal.py +39 -0
- crca_core/models/result.py +83 -0
- crca_core/models/spec.py +151 -0
- crca_core/models/validation.py +68 -0
- crca_core/scm/__init__.py +9 -0
- crca_core/scm/linear_gaussian.py +198 -0
- crca_core/timeseries/__init__.py +6 -0
- crca_core/timeseries/pcmci.py +181 -0
- crca_llm/__init__.py +12 -0
- crca_llm/client.py +85 -0
- crca_llm/coauthor.py +118 -0
- crca_llm/orchestrator.py +289 -0
- crca_llm/types.py +21 -0
- crca_reasoning/__init__.py +16 -0
- crca_reasoning/critique.py +54 -0
- crca_reasoning/godclass.py +206 -0
- crca_reasoning/memory.py +24 -0
- crca_reasoning/rationale.py +10 -0
- crca_reasoning/react_controller.py +81 -0
- crca_reasoning/tool_router.py +97 -0
- crca_reasoning/types.py +40 -0
- crca_sd/__init__.py +15 -0
- crca_sd/crca_sd_core.py +2 -0
- crca_sd/crca_sd_governance.py +2 -0
- crca_sd/crca_sd_mpc.py +2 -0
- crca_sd/crca_sd_realtime.py +2 -0
- crca_sd/crca_sd_tui.py +2 -0
- cuda-keyring_1.1-1_all.deb +0 -0
- cuda-keyring_1.1-1_all.deb.1 +0 -0
- docs/IMAGE_ANNOTATION_USAGE.md +539 -0
- docs/INSTALL_DEEPSPEED.md +125 -0
- docs/api/branches/crca-cg.md +19 -0
- docs/api/branches/crca-q.md +27 -0
- docs/api/branches/crca-sd.md +37 -0
- docs/api/branches/general-agent.md +24 -0
- docs/api/branches/overview.md +19 -0
- docs/api/crca/agent-methods.md +62 -0
- docs/api/crca/operations.md +79 -0
- docs/api/crca/overview.md +32 -0
- docs/api/image-annotation/engine.md +52 -0
- docs/api/image-annotation/overview.md +17 -0
- docs/api/schemas/annotation.md +34 -0
- docs/api/schemas/core-schemas.md +82 -0
- docs/api/schemas/overview.md +32 -0
- docs/api/schemas/policy.md +30 -0
- docs/api/utils/conversation.md +22 -0
- docs/api/utils/graph-reasoner.md +32 -0
- docs/api/utils/overview.md +21 -0
- docs/api/utils/router.md +19 -0
- docs/api/utils/utilities.md +97 -0
- docs/architecture/causal-graphs.md +41 -0
- docs/architecture/data-flow.md +29 -0
- docs/architecture/design-principles.md +33 -0
- docs/architecture/hybrid-agent/components.md +38 -0
- docs/architecture/hybrid-agent/consistency.md +26 -0
- docs/architecture/hybrid-agent/overview.md +44 -0
- docs/architecture/hybrid-agent/reasoning.md +22 -0
- docs/architecture/llm-integration.md +26 -0
- docs/architecture/modular-structure.md +37 -0
- docs/architecture/overview.md +69 -0
- docs/architecture/policy-engine-arch.md +29 -0
- docs/branches/crca-cg/corposwarm.md +39 -0
- docs/branches/crca-cg/esg-scoring.md +30 -0
- docs/branches/crca-cg/multi-agent.md +35 -0
- docs/branches/crca-cg/overview.md +40 -0
- docs/branches/crca-q/alternative-data.md +55 -0
- docs/branches/crca-q/architecture.md +71 -0
- docs/branches/crca-q/backtesting.md +45 -0
- docs/branches/crca-q/causal-engine.md +33 -0
- docs/branches/crca-q/execution.md +39 -0
- docs/branches/crca-q/market-data.md +60 -0
- docs/branches/crca-q/overview.md +58 -0
- docs/branches/crca-q/philosophy.md +60 -0
- docs/branches/crca-q/portfolio-optimization.md +66 -0
- docs/branches/crca-q/risk-management.md +102 -0
- docs/branches/crca-q/setup.md +65 -0
- docs/branches/crca-q/signal-generation.md +61 -0
- docs/branches/crca-q/signal-validation.md +43 -0
- docs/branches/crca-sd/core.md +84 -0
- docs/branches/crca-sd/governance.md +53 -0
- docs/branches/crca-sd/mpc-solver.md +65 -0
- docs/branches/crca-sd/overview.md +59 -0
- docs/branches/crca-sd/realtime.md +28 -0
- docs/branches/crca-sd/tui.md +20 -0
- docs/branches/general-agent/overview.md +37 -0
- docs/branches/general-agent/personality.md +36 -0
- docs/branches/general-agent/prompt-builder.md +30 -0
- docs/changelog/index.md +79 -0
- docs/contributing/code-style.md +69 -0
- docs/contributing/documentation.md +43 -0
- docs/contributing/overview.md +29 -0
- docs/contributing/testing.md +29 -0
- docs/core/crcagent/async-operations.md +65 -0
- docs/core/crcagent/automatic-extraction.md +107 -0
- docs/core/crcagent/batch-prediction.md +80 -0
- docs/core/crcagent/bayesian-inference.md +60 -0
- docs/core/crcagent/causal-graph.md +92 -0
- docs/core/crcagent/counterfactuals.md +96 -0
- docs/core/crcagent/deterministic-simulation.md +78 -0
- docs/core/crcagent/dual-mode-operation.md +82 -0
- docs/core/crcagent/initialization.md +88 -0
- docs/core/crcagent/optimization.md +65 -0
- docs/core/crcagent/overview.md +63 -0
- docs/core/crcagent/time-series.md +57 -0
- docs/core/schemas/annotation.md +30 -0
- docs/core/schemas/core-schemas.md +82 -0
- docs/core/schemas/overview.md +30 -0
- docs/core/schemas/policy.md +41 -0
- docs/core/templates/base-agent.md +31 -0
- docs/core/templates/feature-mixins.md +31 -0
- docs/core/templates/overview.md +29 -0
- docs/core/templates/templates-guide.md +75 -0
- docs/core/tools/mcp-client.md +34 -0
- docs/core/tools/overview.md +24 -0
- docs/core/utils/conversation.md +27 -0
- docs/core/utils/graph-reasoner.md +29 -0
- docs/core/utils/overview.md +27 -0
- docs/core/utils/router.md +27 -0
- docs/core/utils/utilities.md +97 -0
- docs/css/custom.css +84 -0
- docs/examples/basic-usage.md +57 -0
- docs/examples/general-agent/general-agent-examples.md +50 -0
- docs/examples/hybrid-agent/hybrid-agent-examples.md +56 -0
- docs/examples/image-annotation/image-annotation-examples.md +54 -0
- docs/examples/integration/integration-examples.md +58 -0
- docs/examples/overview.md +37 -0
- docs/examples/trading/trading-examples.md +46 -0
- docs/features/causal-reasoning/advanced-topics.md +101 -0
- docs/features/causal-reasoning/counterfactuals.md +43 -0
- docs/features/causal-reasoning/do-calculus.md +50 -0
- docs/features/causal-reasoning/overview.md +47 -0
- docs/features/causal-reasoning/structural-models.md +52 -0
- docs/features/hybrid-agent/advanced-components.md +55 -0
- docs/features/hybrid-agent/core-components.md +64 -0
- docs/features/hybrid-agent/overview.md +34 -0
- docs/features/image-annotation/engine.md +82 -0
- docs/features/image-annotation/features.md +113 -0
- docs/features/image-annotation/integration.md +75 -0
- docs/features/image-annotation/overview.md +53 -0
- docs/features/image-annotation/quickstart.md +73 -0
- docs/features/policy-engine/doctrine-ledger.md +105 -0
- docs/features/policy-engine/monitoring.md +44 -0
- docs/features/policy-engine/mpc-control.md +89 -0
- docs/features/policy-engine/overview.md +46 -0
- docs/getting-started/configuration.md +225 -0
- docs/getting-started/first-agent.md +164 -0
- docs/getting-started/installation.md +144 -0
- docs/getting-started/quickstart.md +137 -0
- docs/index.md +118 -0
- docs/js/mathjax.js +13 -0
- docs/lrm/discovery_proof_notes.md +25 -0
- docs/lrm/finetune_full.md +83 -0
- docs/lrm/math_appendix.md +120 -0
- docs/lrm/overview.md +32 -0
- docs/mkdocs.yml +238 -0
- docs/stylesheets/extra.css +21 -0
- docs_generated/crca_core/CounterfactualResult.md +12 -0
- docs_generated/crca_core/DiscoveryHypothesisResult.md +13 -0
- docs_generated/crca_core/DraftSpec.md +13 -0
- docs_generated/crca_core/EstimateResult.md +13 -0
- docs_generated/crca_core/IdentificationResult.md +17 -0
- docs_generated/crca_core/InterventionDesignResult.md +12 -0
- docs_generated/crca_core/LockedSpec.md +15 -0
- docs_generated/crca_core/RefusalResult.md +12 -0
- docs_generated/crca_core/ValidationReport.md +9 -0
- docs_generated/crca_core/index.md +13 -0
- examples/general_agent_example.py +277 -0
- examples/general_agent_quickstart.py +202 -0
- examples/general_agent_simple.py +92 -0
- examples/hybrid_agent_auto_extraction.py +84 -0
- examples/hybrid_agent_dictionary_demo.py +104 -0
- examples/hybrid_agent_enhanced.py +179 -0
- examples/hybrid_agent_general_knowledge.py +107 -0
- examples/image_annotation_quickstart.py +328 -0
- examples/test_hybrid_fixes.py +77 -0
- image_annotation/__init__.py +27 -0
- image_annotation/annotation_engine.py +2593 -0
- install_cuda_wsl2.sh +59 -0
- install_deepspeed.sh +56 -0
- install_deepspeed_simple.sh +87 -0
- mkdocs.yml +252 -0
- ollama/Modelfile +8 -0
- prompts/__init__.py +2 -1
- prompts/default_crca.py +9 -1
- prompts/general_agent.py +227 -0
- prompts/image_annotation.py +56 -0
- pyproject.toml +17 -2
- requirements-docs.txt +10 -0
- requirements.txt +21 -2
- schemas/__init__.py +26 -1
- schemas/annotation.py +222 -0
- schemas/conversation.py +193 -0
- schemas/hybrid.py +211 -0
- schemas/reasoning.py +276 -0
- schemas_export/crca_core/CounterfactualResult.schema.json +108 -0
- schemas_export/crca_core/DiscoveryHypothesisResult.schema.json +113 -0
- schemas_export/crca_core/DraftSpec.schema.json +635 -0
- schemas_export/crca_core/EstimateResult.schema.json +113 -0
- schemas_export/crca_core/IdentificationResult.schema.json +145 -0
- schemas_export/crca_core/InterventionDesignResult.schema.json +111 -0
- schemas_export/crca_core/LockedSpec.schema.json +646 -0
- schemas_export/crca_core/RefusalResult.schema.json +90 -0
- schemas_export/crca_core/ValidationReport.schema.json +62 -0
- scripts/build_lrm_dataset.py +80 -0
- scripts/export_crca_core_schemas.py +54 -0
- scripts/export_hf_lrm.py +37 -0
- scripts/export_ollama_gguf.py +45 -0
- scripts/generate_changelog.py +157 -0
- scripts/generate_crca_core_docs_from_schemas.py +86 -0
- scripts/run_crca_core_benchmarks.py +163 -0
- scripts/run_full_finetune.py +198 -0
- scripts/run_lrm_eval.py +31 -0
- templates/graph_management.py +29 -0
- tests/conftest.py +9 -0
- tests/test_core.py +2 -3
- tests/test_crca_core_discovery_tabular.py +15 -0
- tests/test_crca_core_estimate_dowhy.py +36 -0
- tests/test_crca_core_identify.py +18 -0
- tests/test_crca_core_intervention_design.py +36 -0
- tests/test_crca_core_linear_gaussian_scm.py +69 -0
- tests/test_crca_core_spec.py +25 -0
- tests/test_crca_core_timeseries_pcmci.py +15 -0
- tests/test_crca_llm_coauthor.py +12 -0
- tests/test_crca_llm_orchestrator.py +80 -0
- tests/test_hybrid_agent_llm_enhanced.py +556 -0
- tests/test_image_annotation_demo.py +376 -0
- tests/test_image_annotation_operational.py +408 -0
- tests/test_image_annotation_unit.py +551 -0
- tests/test_training_moe.py +13 -0
- training/__init__.py +42 -0
- training/datasets.py +140 -0
- training/deepspeed_zero2_0_5b.json +22 -0
- training/deepspeed_zero2_1_5b.json +22 -0
- training/deepspeed_zero3_0_5b.json +28 -0
- training/deepspeed_zero3_14b.json +28 -0
- training/deepspeed_zero3_h100_3gpu.json +20 -0
- training/deepspeed_zero3_offload.json +28 -0
- training/eval.py +92 -0
- training/finetune.py +516 -0
- training/public_datasets.py +89 -0
- training_data/react_train.jsonl +7473 -0
- utils/agent_discovery.py +311 -0
- utils/batch_processor.py +317 -0
- utils/conversation.py +78 -0
- utils/edit_distance.py +118 -0
- utils/formatter.py +33 -0
- utils/graph_reasoner.py +530 -0
- utils/rate_limiter.py +283 -0
- utils/router.py +2 -2
- utils/tool_discovery.py +307 -0
- webui/__init__.py +10 -0
- webui/app.py +229 -0
- webui/config.py +104 -0
- webui/static/css/style.css +332 -0
- webui/static/js/main.js +284 -0
- webui/templates/index.html +42 -0
- tests/test_crca_excel.py +0 -166
- tests/test_data_broker.py +0 -424
- tests/test_palantir.py +0 -349
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/WHEEL +0 -0
- {crca-1.4.0.dist-info → crca-1.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# CRCA-SD API
|
|
2
|
+
|
|
3
|
+
API reference for CRCA-SD socioeconomic dynamics.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### StateVector
|
|
8
|
+
|
|
9
|
+
Socioeconomic state vector.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class StateVector:
|
|
13
|
+
P: float # Population
|
|
14
|
+
L: float # Labor
|
|
15
|
+
U: float # Unemployment
|
|
16
|
+
# ... 15 variables total
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### DynamicsModel
|
|
20
|
+
|
|
21
|
+
System dynamics model.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
class DynamicsModel:
|
|
25
|
+
def step(self, x_t: StateVector, u_t: ControlVector) -> StateVector:
|
|
26
|
+
"""Step forward one time period."""
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Mathematical Foundation
|
|
30
|
+
|
|
31
|
+
Dynamics follow:
|
|
32
|
+
|
|
33
|
+
$$\mathbf{x}_{t+1} = f(\mathbf{x}_t, \mathbf{u}_t, \mathbf{w}_t)$$
|
|
34
|
+
|
|
35
|
+
## Next Steps
|
|
36
|
+
|
|
37
|
+
- [CRCA-CG](crca-cg.md) - Corporate governance API
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# General Agent API
|
|
2
|
+
|
|
3
|
+
API reference for General Agent.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### GeneralAgent
|
|
8
|
+
|
|
9
|
+
General-purpose agent.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class GeneralAgent(BaseSpecializedAgent):
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
model_name: str,
|
|
16
|
+
enable_multimodal: bool = False,
|
|
17
|
+
personality: Optional[Personality] = None
|
|
18
|
+
):
|
|
19
|
+
"""Initialize general agent."""
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Next Steps
|
|
23
|
+
|
|
24
|
+
- [Image Annotation API](../image-annotation/overview.md) - Image annotation API
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Branches API Reference
|
|
2
|
+
|
|
3
|
+
API reference for specialized branches.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Branches API provides documentation for CRCA-Q, CRCA-SD, CRCA-CG, and General Agent.
|
|
8
|
+
|
|
9
|
+
## Branches
|
|
10
|
+
|
|
11
|
+
- **[CRCA-Q](crca-q.md)**: Quantitative trading API
|
|
12
|
+
- **[CRCA-SD](crca-sd.md)**: Socioeconomic dynamics API
|
|
13
|
+
- **[CRCA-CG](crca-cg.md)**: Corporate governance API
|
|
14
|
+
- **[General Agent](general-agent.md)**: General agent API
|
|
15
|
+
|
|
16
|
+
## Next Steps
|
|
17
|
+
|
|
18
|
+
- [CRCA-Q](crca-q.md) - Trading API
|
|
19
|
+
- [CRCA-SD](crca-sd.md) - Socioeconomic dynamics API
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# CRCAAgent Class & Core Methods
|
|
2
|
+
|
|
3
|
+
Main causal reasoning agent class and core methods.
|
|
4
|
+
|
|
5
|
+
## Class Definition
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
class CRCAAgent(Agent):
|
|
9
|
+
"""Causal Reasoning with Counterfactual Analysis Agent."""
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Initialization
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
CRCAAgent(
|
|
16
|
+
model_name: str = "gpt-4o-mini",
|
|
17
|
+
agent_name: str = "cr-ca-lite-agent",
|
|
18
|
+
max_loops: Optional[Union[int, str]] = 3,
|
|
19
|
+
variables: Optional[List[str]] = None,
|
|
20
|
+
causal_edges: Optional[List[Tuple[str, str]] = None,
|
|
21
|
+
**kwargs
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Core Methods
|
|
26
|
+
|
|
27
|
+
### run()
|
|
28
|
+
|
|
29
|
+
Execute a causal reasoning task.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
def run(self, task: str) -> str:
|
|
33
|
+
"""Execute causal reasoning task."""
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### add_causal_relationship()
|
|
37
|
+
|
|
38
|
+
Add a causal relationship to the graph.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
def add_causal_relationship(
|
|
42
|
+
self,
|
|
43
|
+
parent: str,
|
|
44
|
+
child: str,
|
|
45
|
+
strength: float = 0.0
|
|
46
|
+
) -> None:
|
|
47
|
+
"""Add causal relationship."""
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Mathematical Foundation
|
|
51
|
+
|
|
52
|
+
The agent implements operations on SCMs:
|
|
53
|
+
|
|
54
|
+
$$V_i = f_i(Pa(V_i), U_i)$$
|
|
55
|
+
|
|
56
|
+
Methods implement:
|
|
57
|
+
- **run**: $Result = f(Task, SCM)$
|
|
58
|
+
- **add_causal_relationship**: $E \leftarrow E \cup \{(X, Y)\}$
|
|
59
|
+
|
|
60
|
+
## Next Steps
|
|
61
|
+
|
|
62
|
+
- [Operations](operations.md) - Advanced operations
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# CRCAAgent Operations
|
|
2
|
+
|
|
3
|
+
Advanced operations including extraction, simulation, and counterfactuals.
|
|
4
|
+
|
|
5
|
+
## Variable Extraction
|
|
6
|
+
|
|
7
|
+
Methods for automatic variable extraction from natural language.
|
|
8
|
+
|
|
9
|
+
### Mathematical Foundation
|
|
10
|
+
|
|
11
|
+
Extraction identifies:
|
|
12
|
+
|
|
13
|
+
$$V = \{V_1, \ldots, V_n\} = Extract(T)$$
|
|
14
|
+
|
|
15
|
+
Where $T$ is the natural language task.
|
|
16
|
+
|
|
17
|
+
### Methods
|
|
18
|
+
|
|
19
|
+
- `extract_variables()`: Extract variables from text
|
|
20
|
+
- `extract_relationships()`: Extract causal relationships
|
|
21
|
+
|
|
22
|
+
## Deterministic Simulation
|
|
23
|
+
|
|
24
|
+
Methods for deterministic causal simulation.
|
|
25
|
+
|
|
26
|
+
### Mathematical Foundation
|
|
27
|
+
|
|
28
|
+
Simulation uses:
|
|
29
|
+
|
|
30
|
+
$$V_i(t+\Delta t) = V_i(t) + f_i(Pa(V_i(t)), U_i) \cdot \Delta t$$
|
|
31
|
+
|
|
32
|
+
For differential equation systems.
|
|
33
|
+
|
|
34
|
+
### Methods
|
|
35
|
+
|
|
36
|
+
- `simulate()`: Single-step simulation
|
|
37
|
+
- `simulate_time_series()`: Multi-step simulation
|
|
38
|
+
|
|
39
|
+
### Usage
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
result = agent.simulate(
|
|
43
|
+
variables={"education": 16, "experience": 5},
|
|
44
|
+
target="income"
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Counterfactual Generation
|
|
49
|
+
|
|
50
|
+
Methods for generating counterfactual scenarios.
|
|
51
|
+
|
|
52
|
+
### Mathematical Foundation
|
|
53
|
+
|
|
54
|
+
Counterfactuals compute:
|
|
55
|
+
|
|
56
|
+
$$P(Y_{x'} | X=x, Y=y)$$
|
|
57
|
+
|
|
58
|
+
Using:
|
|
59
|
+
1. **Abduction**: $U_Y = f^{-1}(X=x, Z=z, Y=y)$
|
|
60
|
+
2. **Action**: Set $X = x'$
|
|
61
|
+
3. **Prediction**: $Y_{x'} = f(X=x', Z=z, U_Y)$
|
|
62
|
+
|
|
63
|
+
### Methods
|
|
64
|
+
|
|
65
|
+
- `generate_counterfactuals()`: Generate counterfactual scenarios
|
|
66
|
+
- `evaluate_counterfactual()`: Evaluate specific counterfactual
|
|
67
|
+
|
|
68
|
+
### Usage
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
counterfactuals = agent.generate_counterfactuals(
|
|
72
|
+
intervention={"education": "college"},
|
|
73
|
+
outcome="income"
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Next Steps
|
|
78
|
+
|
|
79
|
+
- [Utils API](../utils/overview.md) - Utils API
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# CRCAAgent API Reference
|
|
2
|
+
|
|
3
|
+
API reference for CRCAAgent and related classes.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This section provides API documentation for CRCAAgent. Documentation is hybrid: auto-generated where docstrings exist, manually created where they are missing.
|
|
8
|
+
|
|
9
|
+
## Core Classes
|
|
10
|
+
|
|
11
|
+
- **[CRCAAgent](agent.md)**: Main agent class
|
|
12
|
+
- **[Methods](methods.md)**: Core methods
|
|
13
|
+
- **[Extraction](extraction.md)**: Variable extraction methods
|
|
14
|
+
- **[Simulation](simulation.md)**: Simulation methods
|
|
15
|
+
- **[Counterfactuals](counterfactuals.md)**: Counterfactual methods
|
|
16
|
+
|
|
17
|
+
## Mathematical Foundation
|
|
18
|
+
|
|
19
|
+
All methods implement operations on Structural Causal Models:
|
|
20
|
+
|
|
21
|
+
$$(U, V, F)$$
|
|
22
|
+
|
|
23
|
+
Where operations include:
|
|
24
|
+
- Variable extraction: $V = Extract(T)$
|
|
25
|
+
- Graph construction: $G = Build(V, E)$
|
|
26
|
+
- Causal inference: $E[Y | do(X=x)]$
|
|
27
|
+
- Counterfactuals: $P(Y_{x'} | X=x, Y=y)$
|
|
28
|
+
|
|
29
|
+
## Next Steps
|
|
30
|
+
|
|
31
|
+
- [CRCAAgent](agent.md) - Agent class
|
|
32
|
+
- [Methods](methods.md) - Core methods
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# AnnotationEngine API
|
|
2
|
+
|
|
3
|
+
API reference for AnnotationEngine class.
|
|
4
|
+
|
|
5
|
+
## Class Definition
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
class ImageAnnotationEngine:
|
|
9
|
+
"""Image annotation engine."""
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Methods
|
|
13
|
+
|
|
14
|
+
### annotate()
|
|
15
|
+
|
|
16
|
+
Annotate image(s).
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
def annotate(
|
|
20
|
+
self,
|
|
21
|
+
input: Union[str, np.ndarray, Image.Image, List, Path],
|
|
22
|
+
frame_id: Optional[int] = None,
|
|
23
|
+
output: Optional[str] = None
|
|
24
|
+
) -> Union[AnnotationResult, np.ndarray, Dict[str, Any], str, List]:
|
|
25
|
+
"""Annotate image(s)."""
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### query()
|
|
29
|
+
|
|
30
|
+
Query image with natural language.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
def query(
|
|
34
|
+
self,
|
|
35
|
+
input: Union[str, np.ndarray, Image.Image, Path],
|
|
36
|
+
query: str,
|
|
37
|
+
frame_id: Optional[int] = None
|
|
38
|
+
) -> Dict[str, Any]:
|
|
39
|
+
"""Query image."""
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Mathematical Foundation
|
|
43
|
+
|
|
44
|
+
Annotation uses:
|
|
45
|
+
|
|
46
|
+
$$P(L_i | E_i, I) = LLM(E_i, I)$$
|
|
47
|
+
|
|
48
|
+
Where $L_i$ is label, $E_i$ is entity, and $I$ is image.
|
|
49
|
+
|
|
50
|
+
## Next Steps
|
|
51
|
+
|
|
52
|
+
- [Schemas](schemas.md) - Annotation schemas
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Image Annotation API Reference
|
|
2
|
+
|
|
3
|
+
API reference for image annotation system.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Image annotation API provides documentation for AnnotationEngine and related classes.
|
|
8
|
+
|
|
9
|
+
## Classes
|
|
10
|
+
|
|
11
|
+
- **[Engine](engine.md)**: AnnotationEngine class
|
|
12
|
+
- **[Schemas](schemas.md)**: Annotation data schemas
|
|
13
|
+
|
|
14
|
+
## Next Steps
|
|
15
|
+
|
|
16
|
+
- [Engine](engine.md) - AnnotationEngine API
|
|
17
|
+
- [Schemas](schemas.md) - Annotation schemas
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Annotation Schemas
|
|
2
|
+
|
|
3
|
+
Schemas for image annotation system.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### AnnotationResult
|
|
8
|
+
|
|
9
|
+
Complete annotation result.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class AnnotationResult(BaseModel):
|
|
13
|
+
annotation_graph: AnnotationGraph
|
|
14
|
+
overlay_image: Optional[bytes]
|
|
15
|
+
formal_report: str
|
|
16
|
+
json_output: Dict[str, Any]
|
|
17
|
+
processing_time: float
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### PrimitiveEntity
|
|
21
|
+
|
|
22
|
+
Geometric primitive entity.
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
class PrimitiveEntity(BaseModel):
|
|
26
|
+
entity_id: str
|
|
27
|
+
primitive_type: str
|
|
28
|
+
pixel_coords: List[Tuple[int, int]]
|
|
29
|
+
metadata: Dict[str, Any]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Next Steps
|
|
33
|
+
|
|
34
|
+
- [Conversation](conversation.md) - Conversation schemas
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Core Schemas API
|
|
2
|
+
|
|
3
|
+
API for core data schemas grouped together.
|
|
4
|
+
|
|
5
|
+
## Conversation Schemas
|
|
6
|
+
|
|
7
|
+
Schemas for conversation management.
|
|
8
|
+
|
|
9
|
+
### Classes
|
|
10
|
+
|
|
11
|
+
- `ConversationState`: Current conversation state
|
|
12
|
+
- `Message`: Individual message in conversation
|
|
13
|
+
- `Context`: Conversation context
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from schemas.conversation import ConversationState, Message
|
|
19
|
+
|
|
20
|
+
state = ConversationState(
|
|
21
|
+
messages=[Message(role="user", content="Hello")]
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Hybrid Agent Schemas
|
|
26
|
+
|
|
27
|
+
Schemas for hybrid agent architecture.
|
|
28
|
+
|
|
29
|
+
### Classes
|
|
30
|
+
|
|
31
|
+
- `HybridAgentState`: Hybrid agent state
|
|
32
|
+
- `ReasoningStep`: Individual reasoning step
|
|
33
|
+
- `ConsistencyCheck`: Consistency check result
|
|
34
|
+
|
|
35
|
+
### Usage
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from schemas.hybrid import HybridAgentState
|
|
39
|
+
|
|
40
|
+
state = HybridAgentState(
|
|
41
|
+
reasoning_steps=[],
|
|
42
|
+
consistency_checks=[]
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Reasoning Schemas
|
|
47
|
+
|
|
48
|
+
Schemas for causal reasoning operations and results.
|
|
49
|
+
|
|
50
|
+
### Classes
|
|
51
|
+
|
|
52
|
+
- `CausalInferenceResult`: Causal inference result
|
|
53
|
+
- `CounterfactualScenario`: Counterfactual scenario
|
|
54
|
+
- `CausalEffect`: Causal effect estimate
|
|
55
|
+
|
|
56
|
+
### Mathematical Foundation
|
|
57
|
+
|
|
58
|
+
Causal effect:
|
|
59
|
+
|
|
60
|
+
$$\tau = E[Y | do(X=1)] - E[Y | do(X=0)]$$
|
|
61
|
+
|
|
62
|
+
With confidence interval:
|
|
63
|
+
|
|
64
|
+
$$CI_{1-\alpha} = [\tau - z_{\alpha/2} \cdot SE, \tau + z_{\alpha/2} \cdot SE]$$
|
|
65
|
+
|
|
66
|
+
### Usage
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from schemas.reasoning import CausalInferenceResult
|
|
70
|
+
|
|
71
|
+
result = CausalInferenceResult(
|
|
72
|
+
treatment="X",
|
|
73
|
+
outcome="Y",
|
|
74
|
+
effect=0.5,
|
|
75
|
+
confidence=0.9
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Next Steps
|
|
80
|
+
|
|
81
|
+
- [Annotation](annotation.md) - Image annotation schemas
|
|
82
|
+
- [Policy](policy.md) - Policy engine schemas
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Schemas API Reference
|
|
2
|
+
|
|
3
|
+
API reference for data schemas.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Schemas define Pydantic models for type safety and validation.
|
|
8
|
+
|
|
9
|
+
## Modules
|
|
10
|
+
|
|
11
|
+
- **[Annotation](annotation.md)**: Image annotation schemas
|
|
12
|
+
- **[Conversation](conversation.md)**: Conversation schemas
|
|
13
|
+
- **[Hybrid](hybrid.md)**: Hybrid agent schemas
|
|
14
|
+
- **[Reasoning](reasoning.md)**: Reasoning schemas
|
|
15
|
+
- **[Policy](policy.md)**: Policy engine schemas
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from schemas.annotation import AnnotationResult
|
|
21
|
+
|
|
22
|
+
result = AnnotationResult(
|
|
23
|
+
entities=[],
|
|
24
|
+
labels=[],
|
|
25
|
+
relations=[]
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Next Steps
|
|
30
|
+
|
|
31
|
+
- [Annotation](annotation.md) - Annotation schemas
|
|
32
|
+
- [Policy](policy.md) - Policy schemas
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Policy Engine Schemas
|
|
2
|
+
|
|
3
|
+
Schemas for policy engine system.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### DoctrineV1
|
|
8
|
+
|
|
9
|
+
Policy doctrine definition.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class DoctrineV1(BaseModel):
|
|
13
|
+
version: str
|
|
14
|
+
objectives: List[str]
|
|
15
|
+
constraints: List[str]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Mathematical Foundation
|
|
19
|
+
|
|
20
|
+
Doctrine defines optimization problem:
|
|
21
|
+
|
|
22
|
+
$$\min_{\mathbf{u}} \sum_{i} w_i J_i(\mathbf{u})$$
|
|
23
|
+
|
|
24
|
+
Subject to:
|
|
25
|
+
|
|
26
|
+
$$g_j(\mathbf{u}) \leq 0, \quad j = 1, \ldots, m$$
|
|
27
|
+
|
|
28
|
+
## Next Steps
|
|
29
|
+
|
|
30
|
+
- [Branches API](../branches/overview.md) - Branches API
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Conversation API
|
|
2
|
+
|
|
3
|
+
API for conversation management.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### ConversationManager
|
|
8
|
+
|
|
9
|
+
Manages conversation state and history.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class ConversationManager:
|
|
13
|
+
def add_message(self, role: str, content: str) -> None:
|
|
14
|
+
"""Add message to conversation."""
|
|
15
|
+
|
|
16
|
+
def get_history(self) -> List[Message]:
|
|
17
|
+
"""Get conversation history."""
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Next Steps
|
|
21
|
+
|
|
22
|
+
- [Graph Reasoner](graph-reasoner.md) - Graph reasoner API
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Graph Reasoner API
|
|
2
|
+
|
|
3
|
+
API for graph reasoning utilities.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### GraphReasoner
|
|
8
|
+
|
|
9
|
+
Provides utilities for reasoning about causal graphs.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class GraphReasoner:
|
|
13
|
+
def find_paths(self, source: str, target: str) -> List[List[str]]:
|
|
14
|
+
"""Find all paths from source to target."""
|
|
15
|
+
|
|
16
|
+
def identify_confounders(self, X: str, Y: str) -> List[str]:
|
|
17
|
+
"""Identify confounders for X -> Y."""
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Mathematical Foundation
|
|
21
|
+
|
|
22
|
+
Path finding uses graph algorithms:
|
|
23
|
+
|
|
24
|
+
$$Paths(X, Y) = \{p : X \to^* Y\}$$
|
|
25
|
+
|
|
26
|
+
Confounder identification:
|
|
27
|
+
|
|
28
|
+
$$Z \in Confounders(X, Y) \iff Z \to X \text{ and } Z \to Y$$
|
|
29
|
+
|
|
30
|
+
## Next Steps
|
|
31
|
+
|
|
32
|
+
- [Batch Processor](batch-processor.md) - Batch processor API
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Utils API Reference
|
|
2
|
+
|
|
3
|
+
API reference for utility modules.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Utils API provides documentation for utility functions and classes. Most documentation is manual due to minimal docstrings in source code.
|
|
8
|
+
|
|
9
|
+
## Modules
|
|
10
|
+
|
|
11
|
+
- **[Formatter](formatter.md)**: Formatter utilities
|
|
12
|
+
- **[Router](router.md)**: Router functionality
|
|
13
|
+
- **[Conversation](conversation.md)**: Conversation management
|
|
14
|
+
- **[Graph Reasoner](graph-reasoner.md)**: Graph reasoning
|
|
15
|
+
- **[Batch Processor](batch-processor.md)**: Batch processing
|
|
16
|
+
- **[Rate Limiter](rate-limiter.md)**: Rate limiting
|
|
17
|
+
|
|
18
|
+
## Next Steps
|
|
19
|
+
|
|
20
|
+
- [Formatter](formatter.md) - Formatter API
|
|
21
|
+
- [Router](router.md) - Router API
|
docs/api/utils/router.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Router API
|
|
2
|
+
|
|
3
|
+
API for router functionality.
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
### Router
|
|
8
|
+
|
|
9
|
+
Routes requests to appropriate agents.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class Router:
|
|
13
|
+
def select_agent(self, task: str) -> Agent:
|
|
14
|
+
"""Select appropriate agent for task."""
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Next Steps
|
|
18
|
+
|
|
19
|
+
- [Conversation](conversation.md) - Conversation API
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Utility Functions API
|
|
2
|
+
|
|
3
|
+
API for smaller utility modules grouped together.
|
|
4
|
+
|
|
5
|
+
## Formatter
|
|
6
|
+
|
|
7
|
+
Text formatting and output utilities.
|
|
8
|
+
|
|
9
|
+
### Functions
|
|
10
|
+
|
|
11
|
+
- `format_causal_result()`: Format causal analysis results
|
|
12
|
+
- `format_graph()`: Format causal graph for display
|
|
13
|
+
- `format_counterfactuals()`: Format counterfactual scenarios
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from utils.formatter import format_causal_result
|
|
19
|
+
|
|
20
|
+
result = agent.run("Analyze X -> Y")
|
|
21
|
+
formatted = format_causal_result(result)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Batch Processor
|
|
25
|
+
|
|
26
|
+
Batch processing utilities for multiple tasks.
|
|
27
|
+
|
|
28
|
+
### Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from utils.batch_processor import BatchProcessor
|
|
32
|
+
|
|
33
|
+
processor = BatchProcessor(agent)
|
|
34
|
+
results = processor.process_batch(tasks)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Rate Limiter
|
|
38
|
+
|
|
39
|
+
Rate limiting for API calls.
|
|
40
|
+
|
|
41
|
+
### Usage
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from utils.rate_limiter import RateLimiter
|
|
45
|
+
|
|
46
|
+
limiter = RateLimiter(max_calls=100, period=60)
|
|
47
|
+
limiter.wait_if_needed()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Agent Discovery
|
|
51
|
+
|
|
52
|
+
Agent discovery and registration.
|
|
53
|
+
|
|
54
|
+
### Usage
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from utils.agent_discovery import AgentDiscovery
|
|
58
|
+
|
|
59
|
+
discovery = AgentDiscovery()
|
|
60
|
+
agents = discovery.discover_agents()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Tool Discovery
|
|
64
|
+
|
|
65
|
+
Tool discovery and registration.
|
|
66
|
+
|
|
67
|
+
### Usage
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from utils.tool_discovery import ToolDiscovery
|
|
71
|
+
|
|
72
|
+
discovery = ToolDiscovery()
|
|
73
|
+
tools = discovery.discover_tools()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Edit Distance
|
|
77
|
+
|
|
78
|
+
Edit distance algorithms for text correction.
|
|
79
|
+
|
|
80
|
+
### Mathematical Foundation
|
|
81
|
+
|
|
82
|
+
Levenshtein distance:
|
|
83
|
+
|
|
84
|
+
$$D_{lev}(s_1, s_2) = \min\{Insertions, Deletions, Substitutions\}$$
|
|
85
|
+
|
|
86
|
+
### Usage
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from utils.edit_distance import levenshtein_distance
|
|
90
|
+
|
|
91
|
+
distance = levenshtein_distance("hello", "hallo")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Next Steps
|
|
95
|
+
|
|
96
|
+
- [Router](router.md) - Router API
|
|
97
|
+
- [Conversation](conversation.md) - Conversation API
|