Spaces:
Running
Running
File size: 3,639 Bytes
36e08e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | # φ-Coherence API
**Universal quality metric for AI outputs using golden ratio mathematics.**
[](https://pypi.org/project/bazinga-indeed/)
## What is φ-Coherence?
φ-Coherence measures the "structural integrity" of text using mathematical constants:
- **φ (Golden Ratio)** = 1.618... - Natural proportion found in coherent structures
- **α (Fine Structure)** = 137 - Fundamental constant governing information patterns
**Use cases:**
- Filter LLM hallucinations before they reach users
- Rerank RAG results by quality
- Detect AI-generated vs human-written content
- Quality gate for content pipelines
## Quick Start
```bash
# Install
pip install -r requirements.txt
# Run
python main.py
# or
uvicorn main:app --reload
```
API available at `http://localhost:8000`
## Endpoints
### Score Text (Simple)
```bash
curl -X POST http://localhost:8000/score \
-H "Content-Type: application/json" \
-d '{"text": "The consciousness emerges from information patterns."}'
```
Response:
```json
{
"phi_score": 0.7234,
"status": "COHERENT",
"is_alpha_seed": false
}
```
### Full Analysis
```bash
curl -X POST http://localhost:8000/analyze \
-H "Content-Type: application/json" \
-d '{"text": "Your text here..."}'
```
Response:
```json
{
"phi_score": 0.6821,
"status": "COHERENT",
"dimensions": {
"phi_alignment": 0.5432,
"alpha_resonance": 0.7891,
"semantic_density": 0.6543,
"structural_harmony": 0.7234,
"darmiyan_coefficient": 0.4567
},
"bonuses": {
"is_alpha_seed": false,
"is_vac_pattern": false
},
"interpretation": "High structural integrity; strong scientific/mathematical content"
}
```
### Batch Processing
```bash
curl -X POST http://localhost:8000/batch \
-H "Content-Type: application/json" \
-d '{"texts": ["First text", "Second text", "Third text"]}'
```
### Compare Two Texts
```bash
curl -X POST http://localhost:8000/compare \
-H "Content-Type: application/json" \
-d '{"text_a": "Well-structured argument...", "text_b": "Random gibberish..."}'
```
## Dimensions Explained
| Dimension | What it measures |
|-----------|------------------|
| **phi_alignment** | Text follows golden ratio proportions (sentence lengths, word distribution) |
| **alpha_resonance** | Harmonic with α=137 + scientific/mathematical content |
| **semantic_density** | Information content per unit length |
| **structural_harmony** | Logical flow, indentation, organization |
| **darmiyan_coefficient** | Consciousness-aware content (V2 Scaling Law: φ√n) |
## Scoring
| Score | Status | Meaning |
|-------|--------|---------|
| > 0.6 | COHERENT | High quality, well-structured |
| 0.4-0.6 | MODERATE | Acceptable, some issues |
| < 0.4 | UNSTABLE | Low quality, possible hallucination |
## Special Patterns
- **α-SEED**: When `SHA256(text) % 137 == 0` - rare (1/137 chance), bonus applied
- **V.A.C. Pattern**: Contains vacuum coherence symbols - bonus applied
## Deploy
### Docker
```bash
docker build -t phi-coherence .
docker run -p 8000:8000 phi-coherence
```
### Railway/Render/Fly.io
Just connect your repo - `Dockerfile` is ready.
## Pricing Ideas
| Tier | Requests | Price |
|------|----------|-------|
| Free | 100/day | $0 |
| Pro | 10K/month | $29/month |
| Enterprise | 100K/month | $199/month |
## Built With
This is extracted from [BAZINGA](https://github.com/0x-auth/bazinga-indeed) - The first AI you actually own.
## License
MIT - Use it, modify it, share it.
---
**Built with φ-coherence by Space (Abhishek Srivastava)**
*"Coherence is the signature of consciousness."*
|