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,27 @@
|
|
|
1
|
+
# Conversation Management
|
|
2
|
+
|
|
3
|
+
The conversation module manages conversation state and history for CR-CA agents.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Conversation management tracks dialogue context, maintains history, and manages multi-turn interactions.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from utils.conversation import ConversationManager
|
|
13
|
+
|
|
14
|
+
manager = ConversationManager()
|
|
15
|
+
manager.add_message("user", "Analyze X -> Y")
|
|
16
|
+
manager.add_message("assistant", result)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Conversation history tracking
|
|
22
|
+
- Context management
|
|
23
|
+
- Multi-turn dialogue support
|
|
24
|
+
|
|
25
|
+
## Next Steps
|
|
26
|
+
|
|
27
|
+
- [Graph Reasoner](graph-reasoner.md) - Graph reasoning utilities
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Graph Reasoner
|
|
2
|
+
|
|
3
|
+
The graph reasoner module provides utilities for reasoning about causal graphs.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Graph reasoner utilities help analyze causal graphs, find paths, identify confounders, and compute causal effects.
|
|
8
|
+
|
|
9
|
+
## Mathematical Foundation
|
|
10
|
+
|
|
11
|
+
Graph reasoning uses graph algorithms to:
|
|
12
|
+
|
|
13
|
+
1. **Path Finding**: Find all paths between variables
|
|
14
|
+
2. **Confounder Identification**: Identify variables that confound relationships
|
|
15
|
+
3. **Adjustment Sets**: Find valid adjustment sets for causal identification
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from utils.graph_reasoner import GraphReasoner
|
|
21
|
+
|
|
22
|
+
reasoner = GraphReasoner(graph)
|
|
23
|
+
paths = reasoner.find_paths("X", "Y")
|
|
24
|
+
confounders = reasoner.identify_confounders("X", "Y")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Next Steps
|
|
28
|
+
|
|
29
|
+
- [Batch Processor](batch-processor.md) - Batch processing
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Utils Overview
|
|
2
|
+
|
|
3
|
+
The `utils/` module provides utility functions and extensions for CR-CA.
|
|
4
|
+
|
|
5
|
+
## Modules
|
|
6
|
+
|
|
7
|
+
- **[Formatter](formatter.md)**: Text formatting and output utilities
|
|
8
|
+
- **[Router](router.md)**: Request routing and agent selection
|
|
9
|
+
- **[Conversation](conversation.md)**: Conversation management
|
|
10
|
+
- **[Graph Reasoner](graph-reasoner.md)**: Graph reasoning utilities
|
|
11
|
+
- **[Batch Processor](batch-processor.md)**: Batch processing utilities
|
|
12
|
+
- **[Rate Limiter](rate-limiter.md)**: Rate limiting for API calls
|
|
13
|
+
- **[Agent Discovery](agent-discovery.md)**: Agent discovery and registration
|
|
14
|
+
- **[Tool Discovery](tool-discovery.md)**: Tool discovery and registration
|
|
15
|
+
|
|
16
|
+
## Common Use Cases
|
|
17
|
+
|
|
18
|
+
- Formatting agent outputs
|
|
19
|
+
- Managing conversations
|
|
20
|
+
- Routing requests to appropriate agents
|
|
21
|
+
- Processing batches of tasks
|
|
22
|
+
- Rate limiting API calls
|
|
23
|
+
|
|
24
|
+
## Next Steps
|
|
25
|
+
|
|
26
|
+
- [Formatter](formatter.md) - Format outputs
|
|
27
|
+
- [Router](router.md) - Route requests
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Router
|
|
2
|
+
|
|
3
|
+
The router module provides request routing and agent selection functionality.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Router helps select appropriate agents for specific tasks based on capabilities and availability.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from utils.router import Router
|
|
13
|
+
|
|
14
|
+
router = Router()
|
|
15
|
+
agent = router.select_agent(task="Analyze causal relationships")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Agent capability matching
|
|
21
|
+
- Load balancing
|
|
22
|
+
- Fallback mechanisms
|
|
23
|
+
|
|
24
|
+
## Next Steps
|
|
25
|
+
|
|
26
|
+
- [Conversation](conversation.md) - Conversation management
|
|
27
|
+
- [Graph Reasoner](graph-reasoner.md) - Graph reasoning
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Utility Functions
|
|
2
|
+
|
|
3
|
+
Grouped documentation for smaller utility modules.
|
|
4
|
+
|
|
5
|
+
## Formatter
|
|
6
|
+
|
|
7
|
+
Text formatting and output utilities for CR-CA agents.
|
|
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 processing 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 to prevent exceeding rate limits.
|
|
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 utilities.
|
|
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 utilities.
|
|
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 calculates minimum edit operations:
|
|
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) - Request routing
|
|
97
|
+
- [Conversation](conversation.md) - Conversation management
|
docs/css/custom.css
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* EuroSwarms-inspired custom styling for CR-CA documentation */
|
|
2
|
+
|
|
3
|
+
/* Typography - Serif headings, sans-serif body */
|
|
4
|
+
:root {
|
|
5
|
+
--md-text-font: "Inter", "Helvetica Neue", Arial, sans-serif;
|
|
6
|
+
--md-code-font: "Roboto Mono", monospace;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Override heading fonts to use serif */
|
|
10
|
+
.md-typeset h1,
|
|
11
|
+
.md-typeset h2,
|
|
12
|
+
.md-typeset h3,
|
|
13
|
+
.md-typeset h4,
|
|
14
|
+
.md-typeset h5,
|
|
15
|
+
.md-typeset h6 {
|
|
16
|
+
font-family: "Crimson Text", Georgia, "Times New Roman", serif;
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Background color matching EuroSwarms */
|
|
21
|
+
body {
|
|
22
|
+
background-color: #F5F7FA;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.md-typeset {
|
|
26
|
+
color: #1A1A1A;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Custom list bullets using ▸ character */
|
|
30
|
+
.md-typeset ul li::marker {
|
|
31
|
+
content: "▸ ";
|
|
32
|
+
color: #1A1A1A;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Card-based sections with subtle shadows */
|
|
36
|
+
.md-typeset .admonition,
|
|
37
|
+
.md-typeset details {
|
|
38
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Code blocks with subtle borders */
|
|
43
|
+
.md-typeset pre {
|
|
44
|
+
border: 1px solid #E0E0E0;
|
|
45
|
+
border-radius: 4px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Links with subtle underline on hover */
|
|
49
|
+
.md-typeset a {
|
|
50
|
+
color: #1A1A1A;
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
border-bottom: 1px solid transparent;
|
|
53
|
+
transition: border-color 0.2s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.md-typeset a:hover {
|
|
57
|
+
border-bottom-color: #1A1A1A;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Spacing adjustments */
|
|
61
|
+
.md-typeset {
|
|
62
|
+
line-height: 1.7;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.md-typeset p {
|
|
66
|
+
margin-bottom: 1em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Navigation styling */
|
|
70
|
+
.md-nav__title {
|
|
71
|
+
font-family: "Crimson Text", Georgia, "Times New Roman", serif;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Math rendering improvements */
|
|
75
|
+
.MathJax {
|
|
76
|
+
font-size: 1.1em;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Responsive adjustments */
|
|
80
|
+
@media screen and (max-width: 76.25em) {
|
|
81
|
+
.md-nav--primary .md-nav__title {
|
|
82
|
+
font-family: "Crimson Text", Georgia, "Times New Roman", serif;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Basic Usage Examples
|
|
2
|
+
|
|
3
|
+
Basic examples for getting started with CR-CA.
|
|
4
|
+
|
|
5
|
+
## Simple Causal Analysis
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from CRCA import CRCAAgent
|
|
9
|
+
|
|
10
|
+
agent = CRCAAgent(
|
|
11
|
+
model_name="gpt-4o-mini",
|
|
12
|
+
agent_name="basic-agent"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
result = agent.run("What is the causal relationship between education and income?")
|
|
16
|
+
print(result)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Causal Graph Construction
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
# Add variables
|
|
23
|
+
agent.add_variable("education")
|
|
24
|
+
agent.add_variable("income")
|
|
25
|
+
agent.add_variable("experience")
|
|
26
|
+
|
|
27
|
+
# Add relationships
|
|
28
|
+
agent.add_causal_relationship("education", "income", strength=0.6)
|
|
29
|
+
agent.add_causal_relationship("experience", "income", strength=0.4)
|
|
30
|
+
|
|
31
|
+
# View graph
|
|
32
|
+
graph = agent.causal_graph
|
|
33
|
+
print(graph.get_variables())
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Counterfactual Analysis
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
counterfactuals = agent.generate_counterfactuals(
|
|
40
|
+
intervention={"education": "college"},
|
|
41
|
+
outcome="income"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
for cf in counterfactuals:
|
|
45
|
+
print(f"Expected income: ${cf.expected_outcome:,.2f}")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Mathematical Foundation
|
|
49
|
+
|
|
50
|
+
The causal effect is computed as:
|
|
51
|
+
|
|
52
|
+
$$E[Income | do(Education = college)] = \sum_{z} E[Income | Education = college, Z = z] P(Z = z)$$
|
|
53
|
+
|
|
54
|
+
## Next Steps
|
|
55
|
+
|
|
56
|
+
- [General Agent](general-agent/quickstart.md) - General agent examples
|
|
57
|
+
- [Hybrid Agent](hybrid-agent/auto-extraction.md) - Hybrid agent examples
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# General Agent Examples
|
|
2
|
+
|
|
3
|
+
Comprehensive examples for GeneralAgent usage.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
Basic usage of GeneralAgent:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from branches.general_agent.general_agent import GeneralAgent
|
|
11
|
+
|
|
12
|
+
agent = GeneralAgent(
|
|
13
|
+
model_name="gpt-4o-mini",
|
|
14
|
+
enable_multimodal=True
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
response = agent.run("Hello, how can you help me?")
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Simple Example
|
|
21
|
+
|
|
22
|
+
Simple example using GeneralAgent:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
agent = GeneralAgent(model_name="gpt-4o-mini")
|
|
26
|
+
response = agent.run("Analyze this data")
|
|
27
|
+
print(response)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Advanced Usage
|
|
31
|
+
|
|
32
|
+
Advanced usage with personality and multimodal support:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from branches.general_agent.general_agent import GeneralAgent
|
|
36
|
+
from branches.general_agent.personality import Personality
|
|
37
|
+
|
|
38
|
+
personality = Personality(traits=["analytical", "detailed"])
|
|
39
|
+
agent = GeneralAgent(
|
|
40
|
+
model_name="gpt-4o-mini",
|
|
41
|
+
enable_multimodal=True,
|
|
42
|
+
personality=personality
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
response = agent.run("Analyze this image and provide detailed analysis")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Next Steps
|
|
49
|
+
|
|
50
|
+
- [Hybrid Agent Examples](../hybrid-agent/hybrid-agent-examples.md) - Hybrid agent examples
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Hybrid Agent Examples
|
|
2
|
+
|
|
3
|
+
Comprehensive examples for hybrid agent usage.
|
|
4
|
+
|
|
5
|
+
## Auto Extraction
|
|
6
|
+
|
|
7
|
+
Automatic variable extraction with hybrid agent:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from architecture.hybrid.hybrid_agent import HybridAgent
|
|
11
|
+
|
|
12
|
+
agent = HybridAgent(model_name="gpt-4o-mini")
|
|
13
|
+
|
|
14
|
+
task = """
|
|
15
|
+
Analyze how increasing minimum wage affects employment.
|
|
16
|
+
Consider inflation, business costs, and consumer spending.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
result = agent.run(task)
|
|
20
|
+
# Variables and relationships are automatically extracted
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Dictionary Demo
|
|
24
|
+
|
|
25
|
+
Dictionary extraction demo:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
task = "Extract all key-value pairs from the following text..."
|
|
29
|
+
result = agent.run(task)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Enhanced Features
|
|
33
|
+
|
|
34
|
+
Enhanced hybrid agent features:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
agent = HybridAgent(
|
|
38
|
+
model_name="gpt-4o-mini",
|
|
39
|
+
enable_consistency_checking=True,
|
|
40
|
+
enable_self_verification=True
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
result = agent.run("Complex multi-step reasoning task")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## General Knowledge
|
|
47
|
+
|
|
48
|
+
General knowledge tasks:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
result = agent.run("Explain quantum computing in simple terms")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Next Steps
|
|
55
|
+
|
|
56
|
+
- [Image Annotation Examples](../image-annotation/image-annotation-examples.md) - Image annotation examples
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Image Annotation Examples
|
|
2
|
+
|
|
3
|
+
Comprehensive examples for image annotation usage.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
Basic annotation:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from image_annotation import ImageAnnotationEngine
|
|
11
|
+
|
|
12
|
+
engine = ImageAnnotationEngine()
|
|
13
|
+
result = engine.annotate("image.png", output="all")
|
|
14
|
+
|
|
15
|
+
print(f"Found {len(result.annotation_graph.entities)} entities")
|
|
16
|
+
print(result.formal_report)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## With CRCAAgent
|
|
20
|
+
|
|
21
|
+
Integration with CRCAAgent:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from CRCA import CRCAAgent
|
|
25
|
+
|
|
26
|
+
agent = CRCAAgent(
|
|
27
|
+
model_name="gpt-4o-mini",
|
|
28
|
+
use_image_annotation=True
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
response = agent.run("Analyze the image at path/to/image.png")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Operational Examples
|
|
35
|
+
|
|
36
|
+
Batch processing and production scenarios:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
engine = ImageAnnotationEngine(
|
|
40
|
+
cache_enabled=True,
|
|
41
|
+
parallel_workers=4
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Batch process images
|
|
45
|
+
results = engine.annotate(["img1.png", "img2.png", "img3.png"])
|
|
46
|
+
|
|
47
|
+
# Analyze results
|
|
48
|
+
for result in results:
|
|
49
|
+
print(f"Entities: {len(result.annotation_graph.entities)}")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Next Steps
|
|
53
|
+
|
|
54
|
+
- [Trading Examples](../trading/trading-examples.md) - Trading examples
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Integration Examples
|
|
2
|
+
|
|
3
|
+
Examples of integrating CR-CA with other systems.
|
|
4
|
+
|
|
5
|
+
## CRCA-SD Integration
|
|
6
|
+
|
|
7
|
+
Integration with CRCA-SD for socioeconomic dynamics:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from branches.crca_sd.crca_sd_core import StateVector, DynamicsModel
|
|
11
|
+
from CRCA import CRCAAgent
|
|
12
|
+
|
|
13
|
+
crca = CRCAAgent(model_name="gpt-4o-mini")
|
|
14
|
+
state = StateVector(P=1000000)
|
|
15
|
+
dynamics = DynamicsModel()
|
|
16
|
+
|
|
17
|
+
result = crca.run("Analyze policy impact on GDP")
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## CRCA-CG Integration
|
|
21
|
+
|
|
22
|
+
Integration with CRCA-CG for corporate governance:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from branches.crca_cg.corposwarm import CorporateSwarm
|
|
26
|
+
from CRCA import CRCAAgent
|
|
27
|
+
|
|
28
|
+
crca = CRCAAgent(model_name="gpt-4o-mini")
|
|
29
|
+
swarm = CorporateSwarm()
|
|
30
|
+
|
|
31
|
+
result = crca.run("Analyze governance decision impact")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Palantir Integration
|
|
35
|
+
|
|
36
|
+
Integration with Palantir systems:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from CRCA import CRCAAgent
|
|
40
|
+
|
|
41
|
+
agent = CRCAAgent(model_name="gpt-4o-mini")
|
|
42
|
+
result = agent.run("Analyze data from Palantir system")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Data Broker Integration
|
|
46
|
+
|
|
47
|
+
Integration with data broker systems:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from CRCA import CRCAAgent
|
|
51
|
+
|
|
52
|
+
agent = CRCAAgent(model_name="gpt-4o-mini")
|
|
53
|
+
result = agent.run("Fetch and analyze data from broker")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Next Steps
|
|
57
|
+
|
|
58
|
+
- [Architecture](../architecture/overview.md) - System architecture
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Examples Overview
|
|
2
|
+
|
|
3
|
+
This section provides code examples and tutorials for using CR-CA.
|
|
4
|
+
|
|
5
|
+
## Example Categories
|
|
6
|
+
|
|
7
|
+
- **[Basic Usage](basic-usage.md)**: Basic agent examples
|
|
8
|
+
- **[General Agent](general-agent/quickstart.md)**: General agent examples
|
|
9
|
+
- **[Hybrid Agent](hybrid-agent/auto-extraction.md)**: Hybrid agent examples
|
|
10
|
+
- **[Image Annotation](image-annotation/quickstart.md)**: Image annotation examples
|
|
11
|
+
- **[Trading](trading/crca-q-basic.md)**: Trading examples
|
|
12
|
+
- **[Integration](integration/crca-sd.md)**: Integration examples
|
|
13
|
+
|
|
14
|
+
## Quick Examples
|
|
15
|
+
|
|
16
|
+
### Basic Agent
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from CRCA import CRCAAgent
|
|
20
|
+
|
|
21
|
+
agent = CRCAAgent(model_name="gpt-4o-mini")
|
|
22
|
+
result = agent.run("Analyze X -> Y")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Image Annotation
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from image_annotation import ImageAnnotationEngine
|
|
29
|
+
|
|
30
|
+
engine = ImageAnnotationEngine()
|
|
31
|
+
result = engine.annotate("image.png")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Next Steps
|
|
35
|
+
|
|
36
|
+
- [Basic Usage](basic-usage.md) - Start with basics
|
|
37
|
+
- [General Agent](general-agent/quickstart.md) - General agent examples
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Trading Examples
|
|
2
|
+
|
|
3
|
+
Comprehensive examples for CRCA-Q quantitative trading.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
Basic trading with CRCA-Q:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from branches.CRCA-Q import QuantTradingAgent
|
|
11
|
+
|
|
12
|
+
agent = QuantTradingAgent(
|
|
13
|
+
account_size=10000,
|
|
14
|
+
dry_run=True
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
result = agent.run("BTC")
|
|
18
|
+
print(result)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Mathematical Foundation
|
|
22
|
+
|
|
23
|
+
CRCA-Q uses causal signals validated through:
|
|
24
|
+
|
|
25
|
+
$$P(Returns | do(Signal = s)) \neq P(Returns)$$
|
|
26
|
+
|
|
27
|
+
Where signals are validated for causal validity.
|
|
28
|
+
|
|
29
|
+
## Advanced Trading
|
|
30
|
+
|
|
31
|
+
Multi-asset and advanced features:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
agent = QuantTradingAgent(
|
|
35
|
+
account_size=100000,
|
|
36
|
+
multi_asset_mode=True,
|
|
37
|
+
asset_rotation_enabled=True
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Multi-asset analysis
|
|
41
|
+
result = agent.run(["BTC", "ETH", "SOL"])
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Next Steps
|
|
45
|
+
|
|
46
|
+
- [Integration Examples](../integration/integration-examples.md) - Integration examples
|