cost-katana 1.0.2__py3-none-any.whl → 2.0.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.
- cost_katana/__init__.py +1 -1
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/METADATA +328 -6
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/RECORD +7 -7
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/WHEEL +0 -0
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/entry_points.txt +0 -0
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {cost_katana-1.0.2.dist-info → cost_katana-2.0.0.dist-info}/top_level.txt +0 -0
cost_katana/__init__.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cost-katana
|
3
|
-
Version:
|
4
|
-
Summary:
|
3
|
+
Version: 2.0.0
|
4
|
+
Summary: Revolutionary AI SDK with Cortex Meta-Language for 70-95% token reduction
|
5
5
|
Home-page: https://github.com/Hypothesize-Tech/cost-katana-python
|
6
6
|
Author: Cost Katana Team
|
7
7
|
Author-email: abdul@hypothesize.tech
|
8
8
|
Project-URL: Bug Reports, https://github.com/Hypothesize-Tech/cost-katana-python/issues
|
9
9
|
Project-URL: Source, https://github.com/Hypothesize-Tech/cost-katana-python
|
10
10
|
Project-URL: Documentation, https://docs.costkatana.com
|
11
|
-
Keywords: ai,machine learning,cost optimization,openai,anthropic,aws bedrock,gemini
|
11
|
+
Keywords: ai,machine learning,cost optimization,cortex,lisp,token reduction,openai,anthropic,aws bedrock,gemini,claude opus
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
13
13
|
Classifier: Intended Audience :: Developers
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -45,7 +45,7 @@ Dynamic: summary
|
|
45
45
|
|
46
46
|
# Cost Katana Python SDK
|
47
47
|
|
48
|
-
A
|
48
|
+
A revolutionary AI SDK with **Cortex Meta-Language** for 70-95% token reduction. Features built-in cost optimization, failover, and analytics. Use any AI provider through one consistent API with breakthrough LISP-based optimization!
|
49
49
|
|
50
50
|
## 🚀 Quick Start
|
51
51
|
|
@@ -100,13 +100,105 @@ total_cost = sum(msg.get('metadata', {}).get('cost', 0) for msg in chat.history)
|
|
100
100
|
print(f"Total conversation cost: ${total_cost:.4f}")
|
101
101
|
```
|
102
102
|
|
103
|
+
## 🧠 Cortex Meta-Language: Revolutionary AI Optimization
|
104
|
+
|
105
|
+
Cost Katana's **Cortex** system achieves **70-95% token reduction** through a breakthrough 3-stage pipeline that generates complete answers in optimized LISP format.
|
106
|
+
|
107
|
+
### 🚀 Enable Cortex Optimization
|
108
|
+
|
109
|
+
```python
|
110
|
+
import cost_katana as ck
|
111
|
+
|
112
|
+
ck.configure(api_key='dak_your_key_here')
|
113
|
+
|
114
|
+
# Enable Cortex for massive token savings
|
115
|
+
model = ck.GenerativeModel('claude-3-sonnet')
|
116
|
+
response = model.generate_content(
|
117
|
+
"Write a complete Python web scraper with error handling",
|
118
|
+
cortex={
|
119
|
+
'enabled': True,
|
120
|
+
'mode': 'answer_generation', # Generate complete answers in LISP
|
121
|
+
'encoding_model': 'claude-3-5-sonnet',
|
122
|
+
'core_model': 'claude-opus-4-1',
|
123
|
+
'decoding_model': 'claude-3-5-sonnet',
|
124
|
+
'dynamic_instructions': True, # AI-powered LISP instruction generation
|
125
|
+
'analytics': True
|
126
|
+
}
|
127
|
+
)
|
128
|
+
|
129
|
+
print("Generated Answer:", response.text)
|
130
|
+
print(f"Token Reduction: {response.cortex_metadata.token_reduction}%")
|
131
|
+
print(f"Cost Savings: ${response.cortex_metadata.cost_savings:.4f}")
|
132
|
+
print(f"Confidence Score: {response.cortex_metadata.confidence}%")
|
133
|
+
print(f"Semantic Integrity: {response.cortex_metadata.semantic_integrity}%")
|
134
|
+
```
|
135
|
+
|
136
|
+
### 🔬 Advanced Cortex Features
|
137
|
+
|
138
|
+
```python
|
139
|
+
# Bulk optimization with Cortex
|
140
|
+
queries = [
|
141
|
+
"Explain machine learning algorithms",
|
142
|
+
"Write a React authentication component",
|
143
|
+
"Create a database migration script"
|
144
|
+
]
|
145
|
+
|
146
|
+
results = model.bulk_generate_content(
|
147
|
+
queries,
|
148
|
+
cortex={
|
149
|
+
'enabled': True,
|
150
|
+
'mode': 'answer_generation',
|
151
|
+
'batch_processing': True,
|
152
|
+
'dynamic_instructions': True
|
153
|
+
}
|
154
|
+
)
|
155
|
+
|
156
|
+
for i, result in enumerate(results):
|
157
|
+
print(f"Query {i+1}: {result.cortex_metadata.token_reduction}% reduction")
|
158
|
+
|
159
|
+
# Context-aware processing
|
160
|
+
technical_response = model.generate_content(
|
161
|
+
"Implement a distributed caching system",
|
162
|
+
cortex={
|
163
|
+
'enabled': True,
|
164
|
+
'context': 'technical',
|
165
|
+
'complexity': 'high',
|
166
|
+
'include_examples': True,
|
167
|
+
'code_generation': True
|
168
|
+
}
|
169
|
+
)
|
170
|
+
```
|
171
|
+
|
172
|
+
### 📊 Traditional vs Cortex Comparison
|
173
|
+
|
174
|
+
```python
|
175
|
+
# Compare traditional vs Cortex processing
|
176
|
+
comparison = model.compare_cortex(
|
177
|
+
query="Write a REST API with authentication in Flask",
|
178
|
+
max_tokens=2000
|
179
|
+
)
|
180
|
+
|
181
|
+
print("=== COMPARISON RESULTS ===")
|
182
|
+
print(f"Traditional: {comparison['traditional']['tokens_used']} tokens, ${comparison['traditional']['cost']:.4f}")
|
183
|
+
print(f"Cortex: {comparison['cortex']['tokens_used']} tokens, ${comparison['cortex']['cost']:.4f}")
|
184
|
+
print(f"Savings: {comparison['savings']['token_reduction']}% tokens, ${comparison['savings']['cost_savings']:.4f}")
|
185
|
+
print(f"Semantic Integrity: {comparison['quality']['semantic_integrity']}%")
|
186
|
+
```
|
187
|
+
|
103
188
|
## 🎯 Why Cost Katana?
|
104
189
|
|
190
|
+
### 🧠 Cortex-Powered Intelligence
|
191
|
+
- **70-95% Token Reduction**: Revolutionary LISP-based answer generation
|
192
|
+
- **3-Stage Optimization Pipeline**: Encoder → Core Processor → Decoder
|
193
|
+
- **Dynamic LISP Instructions**: AI-powered instruction generation for any context
|
194
|
+
- **Real-time Analytics**: Confidence, cost impact, and semantic integrity metrics
|
195
|
+
- **Universal Context Handling**: Technical, business, and industry-specific processing
|
196
|
+
|
105
197
|
### Simple Interface, Powerful Backend
|
106
198
|
- **One API for all providers**: Use Google Gemini, Anthropic Claude, OpenAI GPT, AWS Bedrock models through one interface
|
107
199
|
- **No API key juggling**: Store your provider keys securely in Cost Katana, use one key in your code
|
108
200
|
- **Automatic failover**: If one provider is down, automatically switch to alternatives
|
109
|
-
- **
|
201
|
+
- **Intelligent routing**: Cortex-powered optimization to minimize costs while maintaining quality
|
110
202
|
|
111
203
|
### Enterprise Features
|
112
204
|
- **Cost tracking**: Real-time cost monitoring and budgets
|
@@ -264,7 +356,7 @@ balanced_response = model.generate_content(
|
|
264
356
|
|
265
357
|
## 🖥️ Command Line Interface
|
266
358
|
|
267
|
-
Cost Katana includes a CLI for easy interaction:
|
359
|
+
Cost Katana includes a comprehensive CLI for easy interaction:
|
268
360
|
|
269
361
|
```bash
|
270
362
|
# Initialize configuration
|
@@ -283,6 +375,198 @@ cost-katana chat --model gemini-2.0-flash
|
|
283
375
|
cost-katana chat --config my-config.json
|
284
376
|
```
|
285
377
|
|
378
|
+
## 🧬 SAST (Semantic Abstract Syntax Tree) Features
|
379
|
+
|
380
|
+
Cost Katana includes advanced SAST capabilities for semantic optimization and analysis:
|
381
|
+
|
382
|
+
### SAST Optimization
|
383
|
+
|
384
|
+
```bash
|
385
|
+
# Optimize a prompt using SAST
|
386
|
+
cost-katana sast optimize "Write a detailed analysis of market trends"
|
387
|
+
|
388
|
+
# Optimize from file
|
389
|
+
cost-katana sast optimize --file prompt.txt --output optimized.txt
|
390
|
+
|
391
|
+
# Cross-lingual optimization
|
392
|
+
cost-katana sast optimize "Analyze data" --cross-lingual --language en
|
393
|
+
|
394
|
+
# Preserve ambiguity for analysis
|
395
|
+
cost-katana sast optimize "Complex query" --preserve-ambiguity
|
396
|
+
```
|
397
|
+
|
398
|
+
### SAST Comparison
|
399
|
+
|
400
|
+
```bash
|
401
|
+
# Compare traditional vs SAST optimization
|
402
|
+
cost-katana sast compare "Your prompt here"
|
403
|
+
|
404
|
+
# Compare with specific language
|
405
|
+
cost-katana sast compare --file prompt.txt --language en
|
406
|
+
```
|
407
|
+
|
408
|
+
### SAST Vocabulary & Analytics
|
409
|
+
|
410
|
+
```bash
|
411
|
+
# Explore SAST vocabulary
|
412
|
+
cost-katana sast vocabulary
|
413
|
+
|
414
|
+
# Search semantic primitives
|
415
|
+
cost-katana sast vocabulary --search "analysis" --category "action"
|
416
|
+
|
417
|
+
# Get SAST performance statistics
|
418
|
+
cost-katana sast stats
|
419
|
+
|
420
|
+
# View SAST showcase with examples
|
421
|
+
cost-katana sast showcase
|
422
|
+
|
423
|
+
# Telescope ambiguity demonstration
|
424
|
+
cost-katana sast telescope
|
425
|
+
|
426
|
+
# Test universal semantics across languages
|
427
|
+
cost-katana sast universal "concept" --languages "en,es,fr"
|
428
|
+
```
|
429
|
+
|
430
|
+
### SAST Python API
|
431
|
+
|
432
|
+
```python
|
433
|
+
import cost_katana as ck
|
434
|
+
|
435
|
+
ck.configure(api_key='dak_your_key_here')
|
436
|
+
client = ck.CostKatanaClient()
|
437
|
+
|
438
|
+
# Optimize with SAST
|
439
|
+
result = client.optimize_with_sast(
|
440
|
+
prompt="Your prompt here",
|
441
|
+
language="en",
|
442
|
+
cross_lingual=True,
|
443
|
+
preserve_ambiguity=False
|
444
|
+
)
|
445
|
+
|
446
|
+
# Compare SAST vs traditional
|
447
|
+
comparison = client.compare_sast_vs_traditional(
|
448
|
+
prompt="Your prompt here",
|
449
|
+
language="en"
|
450
|
+
)
|
451
|
+
|
452
|
+
# Get SAST vocabulary stats
|
453
|
+
stats = client.get_sast_vocabulary_stats()
|
454
|
+
|
455
|
+
# Search semantic primitives
|
456
|
+
primitives = client.search_semantic_primitives(
|
457
|
+
term="analysis",
|
458
|
+
category="action",
|
459
|
+
limit=10
|
460
|
+
)
|
461
|
+
|
462
|
+
# Test universal semantics
|
463
|
+
universal_test = client.test_universal_semantics(
|
464
|
+
concept="love",
|
465
|
+
languages=["en", "es", "fr"]
|
466
|
+
)
|
467
|
+
```
|
468
|
+
|
469
|
+
## 🧠 Cortex Engine Features
|
470
|
+
|
471
|
+
Cost Katana's Cortex engine provides intelligent processing capabilities:
|
472
|
+
|
473
|
+
### Cortex Operations
|
474
|
+
|
475
|
+
```python
|
476
|
+
import cost_katana as ck
|
477
|
+
|
478
|
+
ck.configure(api_key='dak_your_key_here')
|
479
|
+
client = ck.CostKatanaClient()
|
480
|
+
|
481
|
+
# Enable Cortex with SAST processing
|
482
|
+
result = client.optimize_with_sast(
|
483
|
+
prompt="Your prompt",
|
484
|
+
service="openai",
|
485
|
+
model="gpt-4o-mini",
|
486
|
+
# Cortex features
|
487
|
+
enableCortex=True,
|
488
|
+
cortexOperation="sast",
|
489
|
+
cortexStyle="conversational",
|
490
|
+
cortexFormat="plain",
|
491
|
+
cortexSemanticCache=True,
|
492
|
+
cortexPreserveSemantics=True,
|
493
|
+
cortexIntelligentRouting=True,
|
494
|
+
cortexSastProcessing=True,
|
495
|
+
cortexAmbiguityResolution=True,
|
496
|
+
cortexCrossLingualMode=False
|
497
|
+
)
|
498
|
+
```
|
499
|
+
|
500
|
+
### Cortex Capabilities
|
501
|
+
|
502
|
+
- **Semantic Caching**: Intelligent caching of semantic representations
|
503
|
+
- **Intelligent Routing**: Smart routing based on content analysis
|
504
|
+
- **Ambiguity Resolution**: Automatic resolution of ambiguous language
|
505
|
+
- **Cross-lingual Processing**: Multi-language semantic understanding
|
506
|
+
- **Semantic Preservation**: Maintains semantic meaning during optimization
|
507
|
+
|
508
|
+
## 🌐 Gateway Features
|
509
|
+
|
510
|
+
Cost Katana acts as a unified gateway to multiple AI providers:
|
511
|
+
|
512
|
+
### Provider Abstraction
|
513
|
+
|
514
|
+
```python
|
515
|
+
import cost_katana as ck
|
516
|
+
|
517
|
+
ck.configure(api_key='dak_your_key_here')
|
518
|
+
|
519
|
+
# Same interface, different providers
|
520
|
+
models = [
|
521
|
+
'nova-lite', # Amazon Nova
|
522
|
+
'claude-3-sonnet', # Anthropic Claude
|
523
|
+
'gemini-2.0-flash', # Google Gemini
|
524
|
+
'gpt-4', # OpenAI GPT
|
525
|
+
'llama-3.1-70b' # Meta Llama
|
526
|
+
]
|
527
|
+
|
528
|
+
for model in models:
|
529
|
+
response = ck.GenerativeModel(model).generate_content("Hello!")
|
530
|
+
print(f"{model}: {response.text[:50]}...")
|
531
|
+
```
|
532
|
+
|
533
|
+
### Intelligent Routing
|
534
|
+
|
535
|
+
```python
|
536
|
+
# Cost Katana automatically routes to the best provider
|
537
|
+
model = ck.GenerativeModel('balanced') # Uses intelligent routing
|
538
|
+
|
539
|
+
# Different optimization modes
|
540
|
+
fast_response = model.generate_content(
|
541
|
+
"Quick summary",
|
542
|
+
chat_mode='fastest' # Routes to fastest provider
|
543
|
+
)
|
544
|
+
|
545
|
+
cheap_response = model.generate_content(
|
546
|
+
"Detailed analysis",
|
547
|
+
chat_mode='cheapest' # Routes to most cost-effective provider
|
548
|
+
)
|
549
|
+
|
550
|
+
balanced_response = model.generate_content(
|
551
|
+
"Complex reasoning",
|
552
|
+
chat_mode='balanced' # Balances speed and cost
|
553
|
+
)
|
554
|
+
```
|
555
|
+
|
556
|
+
### Failover & Redundancy
|
557
|
+
|
558
|
+
```python
|
559
|
+
# Automatic failover if primary provider is down
|
560
|
+
model = ck.GenerativeModel('claude-3-sonnet')
|
561
|
+
|
562
|
+
try:
|
563
|
+
response = model.generate_content("Your prompt")
|
564
|
+
except ck.ModelNotAvailableError:
|
565
|
+
# Cost Katana automatically tries alternative providers
|
566
|
+
print("Primary model unavailable, using fallback...")
|
567
|
+
response = model.generate_content("Your prompt")
|
568
|
+
```
|
569
|
+
|
286
570
|
## 📊 Usage Analytics
|
287
571
|
|
288
572
|
Track your AI usage and costs:
|
@@ -400,6 +684,30 @@ class ChatSession:
|
|
400
684
|
def delete_conversation(self) -> None
|
401
685
|
```
|
402
686
|
|
687
|
+
### CostKatanaClient
|
688
|
+
|
689
|
+
```python
|
690
|
+
class CostKatanaClient:
|
691
|
+
def __init__(self, api_key: str = None, base_url: str = None, config_file: str = None)
|
692
|
+
|
693
|
+
# Core Methods
|
694
|
+
def send_message(self, message: str, model_id: str, **kwargs) -> Dict[str, Any]
|
695
|
+
def get_available_models(self) -> List[Dict[str, Any]]
|
696
|
+
def create_conversation(self, title: str = None, model_id: str = None) -> Dict[str, Any]
|
697
|
+
def get_conversation_history(self, conversation_id: str) -> Dict[str, Any]
|
698
|
+
def delete_conversation(self, conversation_id: str) -> Dict[str, Any]
|
699
|
+
|
700
|
+
# SAST Methods
|
701
|
+
def optimize_with_sast(self, prompt: str, **kwargs) -> Dict[str, Any]
|
702
|
+
def compare_sast_vs_traditional(self, prompt: str, **kwargs) -> Dict[str, Any]
|
703
|
+
def get_sast_vocabulary_stats(self) -> Dict[str, Any]
|
704
|
+
def search_semantic_primitives(self, term: str = None, **kwargs) -> Dict[str, Any]
|
705
|
+
def get_telescope_demo(self) -> Dict[str, Any]
|
706
|
+
def test_universal_semantics(self, concept: str, languages: List[str] = None) -> Dict[str, Any]
|
707
|
+
def get_sast_stats(self) -> Dict[str, Any]
|
708
|
+
def get_sast_showcase(self) -> Dict[str, Any]
|
709
|
+
```
|
710
|
+
|
403
711
|
### GenerateContentResponse
|
404
712
|
|
405
713
|
```python
|
@@ -409,6 +717,20 @@ class GenerateContentResponse:
|
|
409
717
|
thinking: Dict # AI reasoning (if available)
|
410
718
|
```
|
411
719
|
|
720
|
+
### UsageMetadata
|
721
|
+
|
722
|
+
```python
|
723
|
+
class UsageMetadata:
|
724
|
+
model: str # Model used
|
725
|
+
cost: float # Cost in USD
|
726
|
+
latency: float # Response time in seconds
|
727
|
+
total_tokens: int # Total tokens used
|
728
|
+
cache_hit: bool # Whether response was cached
|
729
|
+
risk_level: str # Risk assessment level
|
730
|
+
agent_path: List[str] # Multi-agent processing path
|
731
|
+
optimizations_applied: List[str] # Applied optimizations
|
732
|
+
```
|
733
|
+
|
412
734
|
## 🤝 Support
|
413
735
|
|
414
736
|
- **Documentation**: [docs.costkatana.com](https://docs.costkatana.com)
|
@@ -1,12 +1,12 @@
|
|
1
|
-
cost_katana/__init__.py,sha256=
|
1
|
+
cost_katana/__init__.py,sha256=meO0YYq0v7NaK4tK3RgK6JktNFrSCPXJB8QApz7uWy8,1754
|
2
2
|
cost_katana/cli.py,sha256=Xe88QKiNdB1aBnV60sSHLSvJ6YSk-BB9Ke45PSGp72Y,29404
|
3
3
|
cost_katana/client.py,sha256=gZX_-VC2gMuOjXO5XP2-YHElAy2K09XdhZW1jebeSLM,15782
|
4
4
|
cost_katana/config.py,sha256=5uxS_8Qqcb1FlINNMdVl1vxJ_n3FK2BHlJGpeJsoXL0,6792
|
5
5
|
cost_katana/exceptions.py,sha256=VNwc9lpShHQkHsgpAB-w-QJLNH6XRhuUzuXmbj9I9I8,963
|
6
6
|
cost_katana/models.py,sha256=zmPSVF8sLhSu1-o47_cq1Up3FkN6mE_Co9kaBJiCcIE,11602
|
7
|
-
cost_katana-
|
8
|
-
cost_katana-
|
9
|
-
cost_katana-
|
10
|
-
cost_katana-
|
11
|
-
cost_katana-
|
12
|
-
cost_katana-
|
7
|
+
cost_katana-2.0.0.dist-info/licenses/LICENSE,sha256=P7-BNX2xxJZ11R7KpNzczN_H1KJ6R8TisirpIQZWSzw,1067
|
8
|
+
cost_katana-2.0.0.dist-info/METADATA,sha256=a9_CnzZIkwntTf5V0I4kAGpvrtHDr_x17WKwJQV9j9M,22061
|
9
|
+
cost_katana-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
10
|
+
cost_katana-2.0.0.dist-info/entry_points.txt,sha256=vJX-F_Xy4kOoGDZr29uOxB9Iu8ZJDgi4u5NC4_XwFEA,53
|
11
|
+
cost_katana-2.0.0.dist-info/top_level.txt,sha256=VdbCDM3Xp_40Yu73-xCGWUJRn0pPs6kc0iMU3yd59lo,12
|
12
|
+
cost_katana-2.0.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|