cost-katana 1.0.1__tar.gz → 1.0.3__tar.gz
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-1.0.1/cost_katana.egg-info → cost_katana-1.0.3}/PKG-INFO +236 -5
- {cost_katana-1.0.1 → cost_katana-1.0.3}/README.md +235 -4
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana/__init__.py +16 -14
- cost_katana-1.0.3/cost_katana/cli.py +765 -0
- cost_katana-1.0.3/cost_katana/client.py +458 -0
- cost_katana-1.0.3/cost_katana/config.py +178 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana/exceptions.py +19 -1
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana/models.py +110 -111
- {cost_katana-1.0.1 → cost_katana-1.0.3/cost_katana.egg-info}/PKG-INFO +236 -5
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana.egg-info/SOURCES.txt +2 -0
- cost_katana-1.0.3/examples/advanced_features_demo.py +530 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/basic_usage.py +30 -22
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/chat_session.py +28 -24
- cost_katana-1.0.3/examples/comprehensive_demo.py +578 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/config_example.py +72 -56
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/full_integration_demo.py +113 -106
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/old_vs_new.py +30 -22
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/provider_comparison.py +128 -109
- {cost_katana-1.0.1 → cost_katana-1.0.3}/setup.py +1 -1
- cost_katana-1.0.1/cost_katana/cli.py +0 -303
- cost_katana-1.0.1/cost_katana/client.py +0 -235
- cost_katana-1.0.1/cost_katana/config.py +0 -181
- {cost_katana-1.0.1 → cost_katana-1.0.3}/LICENSE +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/MANIFEST.in +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana.egg-info/dependency_links.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana.egg-info/entry_points.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana.egg-info/requires.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/cost_katana.egg-info/top_level.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/examples/config.json +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/requirements-dev.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/requirements.txt +0 -0
- {cost_katana-1.0.1 → cost_katana-1.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cost-katana
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
4
4
|
Summary: Unified AI interface with cost optimization and failover
|
5
5
|
Home-page: https://github.com/Hypothesize-Tech/cost-katana-python
|
6
6
|
Author: Cost Katana Team
|
@@ -159,7 +159,7 @@ model = ck.GenerativeModel('gemini') # Uses mapping from config
|
|
159
159
|
### Environment Variables
|
160
160
|
|
161
161
|
```bash
|
162
|
-
export
|
162
|
+
export API_KEY=dak_your_key_here
|
163
163
|
export COST_KATANA_DEFAULT_MODEL=claude-3-sonnet
|
164
164
|
```
|
165
165
|
|
@@ -264,7 +264,7 @@ balanced_response = model.generate_content(
|
|
264
264
|
|
265
265
|
## 🖥️ Command Line Interface
|
266
266
|
|
267
|
-
Cost Katana includes a CLI for easy interaction:
|
267
|
+
Cost Katana includes a comprehensive CLI for easy interaction:
|
268
268
|
|
269
269
|
```bash
|
270
270
|
# Initialize configuration
|
@@ -283,6 +283,198 @@ cost-katana chat --model gemini-2.0-flash
|
|
283
283
|
cost-katana chat --config my-config.json
|
284
284
|
```
|
285
285
|
|
286
|
+
## 🧬 SAST (Semantic Abstract Syntax Tree) Features
|
287
|
+
|
288
|
+
Cost Katana includes advanced SAST capabilities for semantic optimization and analysis:
|
289
|
+
|
290
|
+
### SAST Optimization
|
291
|
+
|
292
|
+
```bash
|
293
|
+
# Optimize a prompt using SAST
|
294
|
+
cost-katana sast optimize "Write a detailed analysis of market trends"
|
295
|
+
|
296
|
+
# Optimize from file
|
297
|
+
cost-katana sast optimize --file prompt.txt --output optimized.txt
|
298
|
+
|
299
|
+
# Cross-lingual optimization
|
300
|
+
cost-katana sast optimize "Analyze data" --cross-lingual --language en
|
301
|
+
|
302
|
+
# Preserve ambiguity for analysis
|
303
|
+
cost-katana sast optimize "Complex query" --preserve-ambiguity
|
304
|
+
```
|
305
|
+
|
306
|
+
### SAST Comparison
|
307
|
+
|
308
|
+
```bash
|
309
|
+
# Compare traditional vs SAST optimization
|
310
|
+
cost-katana sast compare "Your prompt here"
|
311
|
+
|
312
|
+
# Compare with specific language
|
313
|
+
cost-katana sast compare --file prompt.txt --language en
|
314
|
+
```
|
315
|
+
|
316
|
+
### SAST Vocabulary & Analytics
|
317
|
+
|
318
|
+
```bash
|
319
|
+
# Explore SAST vocabulary
|
320
|
+
cost-katana sast vocabulary
|
321
|
+
|
322
|
+
# Search semantic primitives
|
323
|
+
cost-katana sast vocabulary --search "analysis" --category "action"
|
324
|
+
|
325
|
+
# Get SAST performance statistics
|
326
|
+
cost-katana sast stats
|
327
|
+
|
328
|
+
# View SAST showcase with examples
|
329
|
+
cost-katana sast showcase
|
330
|
+
|
331
|
+
# Telescope ambiguity demonstration
|
332
|
+
cost-katana sast telescope
|
333
|
+
|
334
|
+
# Test universal semantics across languages
|
335
|
+
cost-katana sast universal "concept" --languages "en,es,fr"
|
336
|
+
```
|
337
|
+
|
338
|
+
### SAST Python API
|
339
|
+
|
340
|
+
```python
|
341
|
+
import cost_katana as ck
|
342
|
+
|
343
|
+
ck.configure(api_key='dak_your_key_here')
|
344
|
+
client = ck.CostKatanaClient()
|
345
|
+
|
346
|
+
# Optimize with SAST
|
347
|
+
result = client.optimize_with_sast(
|
348
|
+
prompt="Your prompt here",
|
349
|
+
language="en",
|
350
|
+
cross_lingual=True,
|
351
|
+
preserve_ambiguity=False
|
352
|
+
)
|
353
|
+
|
354
|
+
# Compare SAST vs traditional
|
355
|
+
comparison = client.compare_sast_vs_traditional(
|
356
|
+
prompt="Your prompt here",
|
357
|
+
language="en"
|
358
|
+
)
|
359
|
+
|
360
|
+
# Get SAST vocabulary stats
|
361
|
+
stats = client.get_sast_vocabulary_stats()
|
362
|
+
|
363
|
+
# Search semantic primitives
|
364
|
+
primitives = client.search_semantic_primitives(
|
365
|
+
term="analysis",
|
366
|
+
category="action",
|
367
|
+
limit=10
|
368
|
+
)
|
369
|
+
|
370
|
+
# Test universal semantics
|
371
|
+
universal_test = client.test_universal_semantics(
|
372
|
+
concept="love",
|
373
|
+
languages=["en", "es", "fr"]
|
374
|
+
)
|
375
|
+
```
|
376
|
+
|
377
|
+
## 🧠 Cortex Engine Features
|
378
|
+
|
379
|
+
Cost Katana's Cortex engine provides intelligent processing capabilities:
|
380
|
+
|
381
|
+
### Cortex Operations
|
382
|
+
|
383
|
+
```python
|
384
|
+
import cost_katana as ck
|
385
|
+
|
386
|
+
ck.configure(api_key='dak_your_key_here')
|
387
|
+
client = ck.CostKatanaClient()
|
388
|
+
|
389
|
+
# Enable Cortex with SAST processing
|
390
|
+
result = client.optimize_with_sast(
|
391
|
+
prompt="Your prompt",
|
392
|
+
service="openai",
|
393
|
+
model="gpt-4o-mini",
|
394
|
+
# Cortex features
|
395
|
+
enableCortex=True,
|
396
|
+
cortexOperation="sast",
|
397
|
+
cortexStyle="conversational",
|
398
|
+
cortexFormat="plain",
|
399
|
+
cortexSemanticCache=True,
|
400
|
+
cortexPreserveSemantics=True,
|
401
|
+
cortexIntelligentRouting=True,
|
402
|
+
cortexSastProcessing=True,
|
403
|
+
cortexAmbiguityResolution=True,
|
404
|
+
cortexCrossLingualMode=False
|
405
|
+
)
|
406
|
+
```
|
407
|
+
|
408
|
+
### Cortex Capabilities
|
409
|
+
|
410
|
+
- **Semantic Caching**: Intelligent caching of semantic representations
|
411
|
+
- **Intelligent Routing**: Smart routing based on content analysis
|
412
|
+
- **Ambiguity Resolution**: Automatic resolution of ambiguous language
|
413
|
+
- **Cross-lingual Processing**: Multi-language semantic understanding
|
414
|
+
- **Semantic Preservation**: Maintains semantic meaning during optimization
|
415
|
+
|
416
|
+
## 🌐 Gateway Features
|
417
|
+
|
418
|
+
Cost Katana acts as a unified gateway to multiple AI providers:
|
419
|
+
|
420
|
+
### Provider Abstraction
|
421
|
+
|
422
|
+
```python
|
423
|
+
import cost_katana as ck
|
424
|
+
|
425
|
+
ck.configure(api_key='dak_your_key_here')
|
426
|
+
|
427
|
+
# Same interface, different providers
|
428
|
+
models = [
|
429
|
+
'nova-lite', # Amazon Nova
|
430
|
+
'claude-3-sonnet', # Anthropic Claude
|
431
|
+
'gemini-2.0-flash', # Google Gemini
|
432
|
+
'gpt-4', # OpenAI GPT
|
433
|
+
'llama-3.1-70b' # Meta Llama
|
434
|
+
]
|
435
|
+
|
436
|
+
for model in models:
|
437
|
+
response = ck.GenerativeModel(model).generate_content("Hello!")
|
438
|
+
print(f"{model}: {response.text[:50]}...")
|
439
|
+
```
|
440
|
+
|
441
|
+
### Intelligent Routing
|
442
|
+
|
443
|
+
```python
|
444
|
+
# Cost Katana automatically routes to the best provider
|
445
|
+
model = ck.GenerativeModel('balanced') # Uses intelligent routing
|
446
|
+
|
447
|
+
# Different optimization modes
|
448
|
+
fast_response = model.generate_content(
|
449
|
+
"Quick summary",
|
450
|
+
chat_mode='fastest' # Routes to fastest provider
|
451
|
+
)
|
452
|
+
|
453
|
+
cheap_response = model.generate_content(
|
454
|
+
"Detailed analysis",
|
455
|
+
chat_mode='cheapest' # Routes to most cost-effective provider
|
456
|
+
)
|
457
|
+
|
458
|
+
balanced_response = model.generate_content(
|
459
|
+
"Complex reasoning",
|
460
|
+
chat_mode='balanced' # Balances speed and cost
|
461
|
+
)
|
462
|
+
```
|
463
|
+
|
464
|
+
### Failover & Redundancy
|
465
|
+
|
466
|
+
```python
|
467
|
+
# Automatic failover if primary provider is down
|
468
|
+
model = ck.GenerativeModel('claude-3-sonnet')
|
469
|
+
|
470
|
+
try:
|
471
|
+
response = model.generate_content("Your prompt")
|
472
|
+
except ck.ModelNotAvailableError:
|
473
|
+
# Cost Katana automatically tries alternative providers
|
474
|
+
print("Primary model unavailable, using fallback...")
|
475
|
+
response = model.generate_content("Your prompt")
|
476
|
+
```
|
477
|
+
|
286
478
|
## 📊 Usage Analytics
|
287
479
|
|
288
480
|
Track your AI usage and costs:
|
@@ -400,6 +592,30 @@ class ChatSession:
|
|
400
592
|
def delete_conversation(self) -> None
|
401
593
|
```
|
402
594
|
|
595
|
+
### CostKatanaClient
|
596
|
+
|
597
|
+
```python
|
598
|
+
class CostKatanaClient:
|
599
|
+
def __init__(self, api_key: str = None, base_url: str = None, config_file: str = None)
|
600
|
+
|
601
|
+
# Core Methods
|
602
|
+
def send_message(self, message: str, model_id: str, **kwargs) -> Dict[str, Any]
|
603
|
+
def get_available_models(self) -> List[Dict[str, Any]]
|
604
|
+
def create_conversation(self, title: str = None, model_id: str = None) -> Dict[str, Any]
|
605
|
+
def get_conversation_history(self, conversation_id: str) -> Dict[str, Any]
|
606
|
+
def delete_conversation(self, conversation_id: str) -> Dict[str, Any]
|
607
|
+
|
608
|
+
# SAST Methods
|
609
|
+
def optimize_with_sast(self, prompt: str, **kwargs) -> Dict[str, Any]
|
610
|
+
def compare_sast_vs_traditional(self, prompt: str, **kwargs) -> Dict[str, Any]
|
611
|
+
def get_sast_vocabulary_stats(self) -> Dict[str, Any]
|
612
|
+
def search_semantic_primitives(self, term: str = None, **kwargs) -> Dict[str, Any]
|
613
|
+
def get_telescope_demo(self) -> Dict[str, Any]
|
614
|
+
def test_universal_semantics(self, concept: str, languages: List[str] = None) -> Dict[str, Any]
|
615
|
+
def get_sast_stats(self) -> Dict[str, Any]
|
616
|
+
def get_sast_showcase(self) -> Dict[str, Any]
|
617
|
+
```
|
618
|
+
|
403
619
|
### GenerateContentResponse
|
404
620
|
|
405
621
|
```python
|
@@ -409,12 +625,27 @@ class GenerateContentResponse:
|
|
409
625
|
thinking: Dict # AI reasoning (if available)
|
410
626
|
```
|
411
627
|
|
628
|
+
### UsageMetadata
|
629
|
+
|
630
|
+
```python
|
631
|
+
class UsageMetadata:
|
632
|
+
model: str # Model used
|
633
|
+
cost: float # Cost in USD
|
634
|
+
latency: float # Response time in seconds
|
635
|
+
total_tokens: int # Total tokens used
|
636
|
+
cache_hit: bool # Whether response was cached
|
637
|
+
risk_level: str # Risk assessment level
|
638
|
+
agent_path: List[str] # Multi-agent processing path
|
639
|
+
optimizations_applied: List[str] # Applied optimizations
|
640
|
+
```
|
641
|
+
|
412
642
|
## 🤝 Support
|
413
643
|
|
414
644
|
- **Documentation**: [docs.costkatana.com](https://docs.costkatana.com)
|
415
|
-
- **Discord Community**: [discord.gg/costkatana](https://discord.gg/
|
416
|
-
- **Email Support**:
|
645
|
+
- **Discord Community**: [discord.gg/costkatana](https://discord.gg/Wcwzw8wM)
|
646
|
+
- **Email Support**: abdul@hypothesize.tech
|
417
647
|
- **GitHub Issues**: [github.com/cost-katana/python-sdk](https://github.com/cost-katana/python-sdk)
|
648
|
+
- **GitHub Repository**: [github.com/Hypothesize-Tech/cost-katana-python](https://github.com/Hypothesize-Tech/cost-katana-python)
|
418
649
|
|
419
650
|
## 📄 License
|
420
651
|
|
@@ -114,7 +114,7 @@ model = ck.GenerativeModel('gemini') # Uses mapping from config
|
|
114
114
|
### Environment Variables
|
115
115
|
|
116
116
|
```bash
|
117
|
-
export
|
117
|
+
export API_KEY=dak_your_key_here
|
118
118
|
export COST_KATANA_DEFAULT_MODEL=claude-3-sonnet
|
119
119
|
```
|
120
120
|
|
@@ -219,7 +219,7 @@ balanced_response = model.generate_content(
|
|
219
219
|
|
220
220
|
## 🖥️ Command Line Interface
|
221
221
|
|
222
|
-
Cost Katana includes a CLI for easy interaction:
|
222
|
+
Cost Katana includes a comprehensive CLI for easy interaction:
|
223
223
|
|
224
224
|
```bash
|
225
225
|
# Initialize configuration
|
@@ -238,6 +238,198 @@ cost-katana chat --model gemini-2.0-flash
|
|
238
238
|
cost-katana chat --config my-config.json
|
239
239
|
```
|
240
240
|
|
241
|
+
## 🧬 SAST (Semantic Abstract Syntax Tree) Features
|
242
|
+
|
243
|
+
Cost Katana includes advanced SAST capabilities for semantic optimization and analysis:
|
244
|
+
|
245
|
+
### SAST Optimization
|
246
|
+
|
247
|
+
```bash
|
248
|
+
# Optimize a prompt using SAST
|
249
|
+
cost-katana sast optimize "Write a detailed analysis of market trends"
|
250
|
+
|
251
|
+
# Optimize from file
|
252
|
+
cost-katana sast optimize --file prompt.txt --output optimized.txt
|
253
|
+
|
254
|
+
# Cross-lingual optimization
|
255
|
+
cost-katana sast optimize "Analyze data" --cross-lingual --language en
|
256
|
+
|
257
|
+
# Preserve ambiguity for analysis
|
258
|
+
cost-katana sast optimize "Complex query" --preserve-ambiguity
|
259
|
+
```
|
260
|
+
|
261
|
+
### SAST Comparison
|
262
|
+
|
263
|
+
```bash
|
264
|
+
# Compare traditional vs SAST optimization
|
265
|
+
cost-katana sast compare "Your prompt here"
|
266
|
+
|
267
|
+
# Compare with specific language
|
268
|
+
cost-katana sast compare --file prompt.txt --language en
|
269
|
+
```
|
270
|
+
|
271
|
+
### SAST Vocabulary & Analytics
|
272
|
+
|
273
|
+
```bash
|
274
|
+
# Explore SAST vocabulary
|
275
|
+
cost-katana sast vocabulary
|
276
|
+
|
277
|
+
# Search semantic primitives
|
278
|
+
cost-katana sast vocabulary --search "analysis" --category "action"
|
279
|
+
|
280
|
+
# Get SAST performance statistics
|
281
|
+
cost-katana sast stats
|
282
|
+
|
283
|
+
# View SAST showcase with examples
|
284
|
+
cost-katana sast showcase
|
285
|
+
|
286
|
+
# Telescope ambiguity demonstration
|
287
|
+
cost-katana sast telescope
|
288
|
+
|
289
|
+
# Test universal semantics across languages
|
290
|
+
cost-katana sast universal "concept" --languages "en,es,fr"
|
291
|
+
```
|
292
|
+
|
293
|
+
### SAST Python API
|
294
|
+
|
295
|
+
```python
|
296
|
+
import cost_katana as ck
|
297
|
+
|
298
|
+
ck.configure(api_key='dak_your_key_here')
|
299
|
+
client = ck.CostKatanaClient()
|
300
|
+
|
301
|
+
# Optimize with SAST
|
302
|
+
result = client.optimize_with_sast(
|
303
|
+
prompt="Your prompt here",
|
304
|
+
language="en",
|
305
|
+
cross_lingual=True,
|
306
|
+
preserve_ambiguity=False
|
307
|
+
)
|
308
|
+
|
309
|
+
# Compare SAST vs traditional
|
310
|
+
comparison = client.compare_sast_vs_traditional(
|
311
|
+
prompt="Your prompt here",
|
312
|
+
language="en"
|
313
|
+
)
|
314
|
+
|
315
|
+
# Get SAST vocabulary stats
|
316
|
+
stats = client.get_sast_vocabulary_stats()
|
317
|
+
|
318
|
+
# Search semantic primitives
|
319
|
+
primitives = client.search_semantic_primitives(
|
320
|
+
term="analysis",
|
321
|
+
category="action",
|
322
|
+
limit=10
|
323
|
+
)
|
324
|
+
|
325
|
+
# Test universal semantics
|
326
|
+
universal_test = client.test_universal_semantics(
|
327
|
+
concept="love",
|
328
|
+
languages=["en", "es", "fr"]
|
329
|
+
)
|
330
|
+
```
|
331
|
+
|
332
|
+
## 🧠 Cortex Engine Features
|
333
|
+
|
334
|
+
Cost Katana's Cortex engine provides intelligent processing capabilities:
|
335
|
+
|
336
|
+
### Cortex Operations
|
337
|
+
|
338
|
+
```python
|
339
|
+
import cost_katana as ck
|
340
|
+
|
341
|
+
ck.configure(api_key='dak_your_key_here')
|
342
|
+
client = ck.CostKatanaClient()
|
343
|
+
|
344
|
+
# Enable Cortex with SAST processing
|
345
|
+
result = client.optimize_with_sast(
|
346
|
+
prompt="Your prompt",
|
347
|
+
service="openai",
|
348
|
+
model="gpt-4o-mini",
|
349
|
+
# Cortex features
|
350
|
+
enableCortex=True,
|
351
|
+
cortexOperation="sast",
|
352
|
+
cortexStyle="conversational",
|
353
|
+
cortexFormat="plain",
|
354
|
+
cortexSemanticCache=True,
|
355
|
+
cortexPreserveSemantics=True,
|
356
|
+
cortexIntelligentRouting=True,
|
357
|
+
cortexSastProcessing=True,
|
358
|
+
cortexAmbiguityResolution=True,
|
359
|
+
cortexCrossLingualMode=False
|
360
|
+
)
|
361
|
+
```
|
362
|
+
|
363
|
+
### Cortex Capabilities
|
364
|
+
|
365
|
+
- **Semantic Caching**: Intelligent caching of semantic representations
|
366
|
+
- **Intelligent Routing**: Smart routing based on content analysis
|
367
|
+
- **Ambiguity Resolution**: Automatic resolution of ambiguous language
|
368
|
+
- **Cross-lingual Processing**: Multi-language semantic understanding
|
369
|
+
- **Semantic Preservation**: Maintains semantic meaning during optimization
|
370
|
+
|
371
|
+
## 🌐 Gateway Features
|
372
|
+
|
373
|
+
Cost Katana acts as a unified gateway to multiple AI providers:
|
374
|
+
|
375
|
+
### Provider Abstraction
|
376
|
+
|
377
|
+
```python
|
378
|
+
import cost_katana as ck
|
379
|
+
|
380
|
+
ck.configure(api_key='dak_your_key_here')
|
381
|
+
|
382
|
+
# Same interface, different providers
|
383
|
+
models = [
|
384
|
+
'nova-lite', # Amazon Nova
|
385
|
+
'claude-3-sonnet', # Anthropic Claude
|
386
|
+
'gemini-2.0-flash', # Google Gemini
|
387
|
+
'gpt-4', # OpenAI GPT
|
388
|
+
'llama-3.1-70b' # Meta Llama
|
389
|
+
]
|
390
|
+
|
391
|
+
for model in models:
|
392
|
+
response = ck.GenerativeModel(model).generate_content("Hello!")
|
393
|
+
print(f"{model}: {response.text[:50]}...")
|
394
|
+
```
|
395
|
+
|
396
|
+
### Intelligent Routing
|
397
|
+
|
398
|
+
```python
|
399
|
+
# Cost Katana automatically routes to the best provider
|
400
|
+
model = ck.GenerativeModel('balanced') # Uses intelligent routing
|
401
|
+
|
402
|
+
# Different optimization modes
|
403
|
+
fast_response = model.generate_content(
|
404
|
+
"Quick summary",
|
405
|
+
chat_mode='fastest' # Routes to fastest provider
|
406
|
+
)
|
407
|
+
|
408
|
+
cheap_response = model.generate_content(
|
409
|
+
"Detailed analysis",
|
410
|
+
chat_mode='cheapest' # Routes to most cost-effective provider
|
411
|
+
)
|
412
|
+
|
413
|
+
balanced_response = model.generate_content(
|
414
|
+
"Complex reasoning",
|
415
|
+
chat_mode='balanced' # Balances speed and cost
|
416
|
+
)
|
417
|
+
```
|
418
|
+
|
419
|
+
### Failover & Redundancy
|
420
|
+
|
421
|
+
```python
|
422
|
+
# Automatic failover if primary provider is down
|
423
|
+
model = ck.GenerativeModel('claude-3-sonnet')
|
424
|
+
|
425
|
+
try:
|
426
|
+
response = model.generate_content("Your prompt")
|
427
|
+
except ck.ModelNotAvailableError:
|
428
|
+
# Cost Katana automatically tries alternative providers
|
429
|
+
print("Primary model unavailable, using fallback...")
|
430
|
+
response = model.generate_content("Your prompt")
|
431
|
+
```
|
432
|
+
|
241
433
|
## 📊 Usage Analytics
|
242
434
|
|
243
435
|
Track your AI usage and costs:
|
@@ -355,6 +547,30 @@ class ChatSession:
|
|
355
547
|
def delete_conversation(self) -> None
|
356
548
|
```
|
357
549
|
|
550
|
+
### CostKatanaClient
|
551
|
+
|
552
|
+
```python
|
553
|
+
class CostKatanaClient:
|
554
|
+
def __init__(self, api_key: str = None, base_url: str = None, config_file: str = None)
|
555
|
+
|
556
|
+
# Core Methods
|
557
|
+
def send_message(self, message: str, model_id: str, **kwargs) -> Dict[str, Any]
|
558
|
+
def get_available_models(self) -> List[Dict[str, Any]]
|
559
|
+
def create_conversation(self, title: str = None, model_id: str = None) -> Dict[str, Any]
|
560
|
+
def get_conversation_history(self, conversation_id: str) -> Dict[str, Any]
|
561
|
+
def delete_conversation(self, conversation_id: str) -> Dict[str, Any]
|
562
|
+
|
563
|
+
# SAST Methods
|
564
|
+
def optimize_with_sast(self, prompt: str, **kwargs) -> Dict[str, Any]
|
565
|
+
def compare_sast_vs_traditional(self, prompt: str, **kwargs) -> Dict[str, Any]
|
566
|
+
def get_sast_vocabulary_stats(self) -> Dict[str, Any]
|
567
|
+
def search_semantic_primitives(self, term: str = None, **kwargs) -> Dict[str, Any]
|
568
|
+
def get_telescope_demo(self) -> Dict[str, Any]
|
569
|
+
def test_universal_semantics(self, concept: str, languages: List[str] = None) -> Dict[str, Any]
|
570
|
+
def get_sast_stats(self) -> Dict[str, Any]
|
571
|
+
def get_sast_showcase(self) -> Dict[str, Any]
|
572
|
+
```
|
573
|
+
|
358
574
|
### GenerateContentResponse
|
359
575
|
|
360
576
|
```python
|
@@ -364,12 +580,27 @@ class GenerateContentResponse:
|
|
364
580
|
thinking: Dict # AI reasoning (if available)
|
365
581
|
```
|
366
582
|
|
583
|
+
### UsageMetadata
|
584
|
+
|
585
|
+
```python
|
586
|
+
class UsageMetadata:
|
587
|
+
model: str # Model used
|
588
|
+
cost: float # Cost in USD
|
589
|
+
latency: float # Response time in seconds
|
590
|
+
total_tokens: int # Total tokens used
|
591
|
+
cache_hit: bool # Whether response was cached
|
592
|
+
risk_level: str # Risk assessment level
|
593
|
+
agent_path: List[str] # Multi-agent processing path
|
594
|
+
optimizations_applied: List[str] # Applied optimizations
|
595
|
+
```
|
596
|
+
|
367
597
|
## 🤝 Support
|
368
598
|
|
369
599
|
- **Documentation**: [docs.costkatana.com](https://docs.costkatana.com)
|
370
|
-
- **Discord Community**: [discord.gg/costkatana](https://discord.gg/
|
371
|
-
- **Email Support**:
|
600
|
+
- **Discord Community**: [discord.gg/costkatana](https://discord.gg/Wcwzw8wM)
|
601
|
+
- **Email Support**: abdul@hypothesize.tech
|
372
602
|
- **GitHub Issues**: [github.com/cost-katana/python-sdk](https://github.com/cost-katana/python-sdk)
|
603
|
+
- **GitHub Repository**: [github.com/Hypothesize-Tech/cost-katana-python](https://github.com/Hypothesize-Tech/cost-katana-python)
|
373
604
|
|
374
605
|
## 📄 License
|
375
606
|
|
@@ -9,10 +9,10 @@ Simple interface for AI models that routes through Cost Katana for:
|
|
9
9
|
|
10
10
|
Example:
|
11
11
|
import cost_katana as ck
|
12
|
-
|
12
|
+
|
13
13
|
# Configure once
|
14
14
|
ck.configure(config_file='config.json')
|
15
|
-
|
15
|
+
|
16
16
|
# Use like any AI library
|
17
17
|
model = ck.GenerativeModel('gemini-2.0-flash')
|
18
18
|
chat = model.start_chat()
|
@@ -21,49 +21,51 @@ Example:
|
|
21
21
|
"""
|
22
22
|
|
23
23
|
from .client import CostKatanaClient, get_global_client
|
24
|
-
from .models import
|
24
|
+
from .models import ChatSession
|
25
25
|
from .exceptions import (
|
26
26
|
CostKatanaError,
|
27
27
|
AuthenticationError,
|
28
28
|
ModelNotAvailableError,
|
29
29
|
RateLimitError,
|
30
|
-
CostLimitExceededError
|
30
|
+
CostLimitExceededError,
|
31
31
|
)
|
32
32
|
from .config import Config
|
33
33
|
|
34
|
-
__version__ = "1.0.
|
34
|
+
__version__ = "1.0.3"
|
35
35
|
__all__ = [
|
36
36
|
"configure",
|
37
|
-
"
|
37
|
+
"create_generative_model",
|
38
38
|
"ChatSession",
|
39
39
|
"CostKatanaClient",
|
40
40
|
"CostKatanaError",
|
41
|
-
"AuthenticationError",
|
41
|
+
"AuthenticationError",
|
42
42
|
"ModelNotAvailableError",
|
43
43
|
"RateLimitError",
|
44
44
|
"CostLimitExceededError",
|
45
|
-
"Config"
|
45
|
+
"Config",
|
46
46
|
]
|
47
47
|
|
48
48
|
# Import configure function from client
|
49
49
|
from .client import configure
|
50
50
|
|
51
|
-
|
51
|
+
|
52
|
+
def create_generative_model(model_name: str, **kwargs):
|
52
53
|
"""
|
53
54
|
Create a generative model instance.
|
54
|
-
|
55
|
+
|
55
56
|
Args:
|
56
57
|
model_name: Name of the model (e.g., 'gemini-2.0-flash', 'claude-3-sonnet', 'gpt-4')
|
57
58
|
**kwargs: Additional model configuration
|
58
|
-
|
59
|
+
|
59
60
|
Returns:
|
60
61
|
GenerativeModel instance
|
61
|
-
|
62
|
+
|
62
63
|
Example:
|
63
64
|
model = cost_katana.GenerativeModel('gemini-2.0-flash')
|
64
65
|
response = model.generate_content("Hello, world!")
|
65
66
|
"""
|
66
67
|
client = get_global_client()
|
67
|
-
|
68
|
+
|
68
69
|
from .models import GenerativeModel as GM
|
69
|
-
|
70
|
+
|
71
|
+
return GM(client, model_name, **kwargs)
|