Skip to content

Commit c90e213

Browse files
committed
Update version to 1.0.2 in setup.py and __init__.py; implement SAST command structure in cli.py and client.py, adding methods for SAST optimization, comparison, vocabulary search, and statistics retrieval.
1 parent fbf1bb8 commit c90e213

File tree

6 files changed

+942
-58
lines changed

6 files changed

+942
-58
lines changed

README.md

Lines changed: 231 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ balanced_response = model.generate_content(
219219

220220
## 🖥️ Command Line Interface
221221

222-
Cost Katana includes a CLI for easy interaction:
222+
Cost Katana includes a comprehensive CLI for easy interaction:
223223

224224
```bash
225225
# Initialize configuration
@@ -238,6 +238,198 @@ cost-katana chat --model gemini-2.0-flash
238238
cost-katana chat --config my-config.json
239239
```
240240

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+
241433
## 📊 Usage Analytics
242434

243435
Track your AI usage and costs:
@@ -355,6 +547,30 @@ class ChatSession:
355547
def delete_conversation(self) -> None
356548
```
357549

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+
358574
### GenerateContentResponse
359575

360576
```python
@@ -364,6 +580,20 @@ class GenerateContentResponse:
364580
thinking: Dict # AI reasoning (if available)
365581
```
366582

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+
367597
## 🤝 Support
368598

369599
- **Documentation**: [docs.costkatana.com](https://docs.costkatana.com)

cost_katana/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
from .config import Config
3333

34-
__version__ = "1.0.0"
34+
__version__ = "1.0.3"
3535
__all__ = [
3636
"configure",
3737
"create_generative_model",

0 commit comments

Comments
 (0)