mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 03:31:02 +02:00
More CLI commands
This commit is contained in:
parent
4ac304e4b4
commit
e29bbbc54f
5 changed files with 1836 additions and 2 deletions
|
|
@ -33,6 +33,10 @@ Most CLI commands support these common options:
|
|||
- [`tg-show-token-costs`](tg-show-token-costs.md) - Display token cost configuration
|
||||
- [`tg-show-token-rate`](tg-show-token-rate.md) - Show token usage rates
|
||||
|
||||
**Prompt Management:**
|
||||
- [`tg-set-prompt`](tg-set-prompt.md) - Configure prompt templates and system prompts
|
||||
- [`tg-show-prompts`](tg-show-prompts.md) - Display configured prompt templates
|
||||
|
||||
### Flow Management
|
||||
|
||||
**Flow Operations:**
|
||||
|
|
@ -71,9 +75,9 @@ Most CLI commands support these common options:
|
|||
|
||||
**Library Management:**
|
||||
- [`tg-add-library-document`](tg-add-library-document.md) - Add documents to library
|
||||
- [`tg-show-library-documents`](tg-show-library-documents.md) - List documents in library
|
||||
- [`tg-remove-library-document`](tg-remove-library-document.md) - Remove documents from library
|
||||
- [`tg-show-library-documents`](tg-show-library-documents.md) - List library documents
|
||||
- [`tg-start-library-processing`](tg-start-library-processing.md) - Start library document processing
|
||||
- [`tg-start-library-processing`](tg-start-library-processing.md) - Start processing library documents
|
||||
- [`tg-stop-library-processing`](tg-stop-library-processing.md) - Stop library document processing
|
||||
- [`tg-show-library-processing`](tg-show-library-processing.md) - Show library processing status
|
||||
|
||||
|
|
|
|||
442
docs/cli/tg-set-prompt.md
Normal file
442
docs/cli/tg-set-prompt.md
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
# tg-set-prompt
|
||||
|
||||
Sets prompt templates and system prompts for TrustGraph LLM services.
|
||||
|
||||
## Synopsis
|
||||
|
||||
```bash
|
||||
# Set a prompt template
|
||||
tg-set-prompt --id TEMPLATE_ID --prompt TEMPLATE [options]
|
||||
|
||||
# Set system prompt
|
||||
tg-set-prompt --system SYSTEM_PROMPT
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `tg-set-prompt` command configures prompt templates and system prompts used by TrustGraph's LLM services. Prompt templates contain placeholders like `{{variable}}` that are replaced with actual values when invoked. System prompts provide global context for all LLM interactions.
|
||||
|
||||
Templates are stored in TrustGraph's configuration system and can be used with `tg-invoke-prompt` for consistent AI interactions.
|
||||
|
||||
## Options
|
||||
|
||||
### Prompt Template Mode
|
||||
|
||||
- `--id ID`: Unique identifier for the prompt template (required for templates)
|
||||
- `--prompt TEMPLATE`: Prompt template text with `{{variable}}` placeholders (required for templates)
|
||||
- `--response TYPE`: Response format - `text` or `json` (default: `text`)
|
||||
- `--schema SCHEMA`: JSON schema for structured responses (required when response is `json`)
|
||||
|
||||
### System Prompt Mode
|
||||
|
||||
- `--system PROMPT`: System prompt text (cannot be used with other options)
|
||||
|
||||
### Common Options
|
||||
|
||||
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Prompt Template
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "greeting" \
|
||||
--prompt "Hello {{name}}, welcome to {{place}}!"
|
||||
```
|
||||
|
||||
### Question-Answer Template
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "question" \
|
||||
--prompt "Answer this question based on the context: {{question}}\n\nContext: {{context}}"
|
||||
```
|
||||
|
||||
### JSON Response Template
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "extract-info" \
|
||||
--prompt "Extract key information from: {{text}}" \
|
||||
--response "json" \
|
||||
--schema '{"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "number"}}}'
|
||||
```
|
||||
|
||||
### Analysis Template
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "analyze" \
|
||||
--prompt "Analyze the following {{data_type}} and provide insights about {{focus_area}}:\n\n{{data}}\n\nFormat the response as {{format}}."
|
||||
```
|
||||
|
||||
### System Prompt
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--system "You are a helpful AI assistant. Always provide accurate, concise responses. When uncertain, clearly state your limitations."
|
||||
```
|
||||
|
||||
## Template Variables
|
||||
|
||||
### Variable Syntax
|
||||
Templates use `{{variable}}` syntax for placeholders:
|
||||
```bash
|
||||
# Template
|
||||
"Hello {{name}}, today is {{day}}"
|
||||
|
||||
# Usage
|
||||
tg-invoke-prompt greeting name="Alice" day="Monday"
|
||||
# Result: "Hello Alice, today is Monday"
|
||||
```
|
||||
|
||||
### Common Variables
|
||||
- `{{text}}` - Input text for processing
|
||||
- `{{question}}` - Question to answer
|
||||
- `{{context}}` - Background context
|
||||
- `{{data}}` - Data to analyze
|
||||
- `{{format}}` - Output format specification
|
||||
|
||||
## Response Types
|
||||
|
||||
### Text Response (Default)
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "summarize" \
|
||||
--prompt "Summarize this text in {{max_words}} words: {{text}}"
|
||||
```
|
||||
|
||||
### JSON Response
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "classify" \
|
||||
--prompt "Classify this text: {{text}}" \
|
||||
--response "json" \
|
||||
--schema '{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"category": {"type": "string"},
|
||||
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
|
||||
},
|
||||
"required": ["category", "confidence"]
|
||||
}'
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Document Processing Templates
|
||||
```bash
|
||||
# Document summarization
|
||||
tg-set-prompt \
|
||||
--id "document-summary" \
|
||||
--prompt "Provide a {{length}} summary of this document:\n\n{{document}}\n\nFocus on: {{focus_areas}}"
|
||||
|
||||
# Key point extraction
|
||||
tg-set-prompt \
|
||||
--id "extract-key-points" \
|
||||
--prompt "Extract the main points from: {{text}}\n\nReturn as a bulleted list."
|
||||
|
||||
# Document classification
|
||||
tg-set-prompt \
|
||||
--id "classify-document" \
|
||||
--prompt "Classify this document into one of these categories: {{categories}}\n\nDocument: {{text}}" \
|
||||
--response "json" \
|
||||
--schema '{"type": "object", "properties": {"category": {"type": "string"}, "confidence": {"type": "number"}}}'
|
||||
```
|
||||
|
||||
### Code Analysis Templates
|
||||
```bash
|
||||
# Code review
|
||||
tg-set-prompt \
|
||||
--id "code-review" \
|
||||
--prompt "Review this {{language}} code for {{focus}} issues:\n\n{{code}}\n\nProvide specific recommendations."
|
||||
|
||||
# Bug detection
|
||||
tg-set-prompt \
|
||||
--id "find-bugs" \
|
||||
--prompt "Analyze this code for potential bugs:\n\n{{code}}\n\nError context: {{error}}"
|
||||
|
||||
# Code explanation
|
||||
tg-set-prompt \
|
||||
--id "explain-code" \
|
||||
--prompt "Explain how this {{language}} code works:\n\n{{code}}\n\nTarget audience: {{audience}}"
|
||||
```
|
||||
|
||||
### Data Analysis Templates
|
||||
```bash
|
||||
# Data insights
|
||||
tg-set-prompt \
|
||||
--id "data-insights" \
|
||||
--prompt "Analyze this {{data_type}} data and provide insights:\n\n{{data}}\n\nFocus on: {{metrics}}"
|
||||
|
||||
# Trend analysis
|
||||
tg-set-prompt \
|
||||
--id "trend-analysis" \
|
||||
--prompt "Identify trends in this data over {{timeframe}}:\n\n{{data}}" \
|
||||
--response "json" \
|
||||
--schema '{"type": "object", "properties": {"trends": {"type": "array", "items": {"type": "string"}}}}'
|
||||
```
|
||||
|
||||
### Content Generation Templates
|
||||
```bash
|
||||
# Marketing copy
|
||||
tg-set-prompt \
|
||||
--id "marketing-copy" \
|
||||
--prompt "Create {{tone}} marketing copy for {{product}} targeting {{audience}}. Key features: {{features}}"
|
||||
|
||||
# Technical documentation
|
||||
tg-set-prompt \
|
||||
--id "tech-docs" \
|
||||
--prompt "Generate technical documentation for:\n\n{{code}}\n\nInclude: {{sections}}"
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Multi-Step Templates
|
||||
```bash
|
||||
# Research template
|
||||
tg-set-prompt \
|
||||
--id "research" \
|
||||
--prompt "Research question: {{question}}
|
||||
|
||||
Available sources: {{sources}}
|
||||
|
||||
Please:
|
||||
1. Analyze the question
|
||||
2. Review relevant sources
|
||||
3. Synthesize findings
|
||||
4. Provide conclusions
|
||||
|
||||
Format: {{output_format}}"
|
||||
```
|
||||
|
||||
### Conditional Templates
|
||||
```bash
|
||||
# Adaptive response template
|
||||
tg-set-prompt \
|
||||
--id "adaptive-response" \
|
||||
--prompt "Task: {{task}}
|
||||
Context: {{context}}
|
||||
Expertise level: {{level}}
|
||||
|
||||
If expertise level is 'beginner', provide simple explanations.
|
||||
If expertise level is 'advanced', include technical details.
|
||||
If task involves code, include examples.
|
||||
|
||||
Response:"
|
||||
```
|
||||
|
||||
### Structured Analysis Template
|
||||
```bash
|
||||
tg-set-prompt \
|
||||
--id "structured-analysis" \
|
||||
--prompt "Analyze: {{subject}}
|
||||
Criteria: {{criteria}}
|
||||
Data: {{data}}
|
||||
|
||||
Provide analysis in this structure:
|
||||
- Overview
|
||||
- Key Findings
|
||||
- Recommendations
|
||||
- Next Steps" \
|
||||
--response "json" \
|
||||
--schema '{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"overview": {"type": "string"},
|
||||
"key_findings": {"type": "array", "items": {"type": "string"}},
|
||||
"recommendations": {"type": "array", "items": {"type": "string"}},
|
||||
"next_steps": {"type": "array", "items": {"type": "string"}}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### Template Management
|
||||
```bash
|
||||
# Create template collection for specific domain
|
||||
domain="customer-support"
|
||||
templates=(
|
||||
"greeting:Hello! I'm here to help with {{issue_type}}. What can I assist you with?"
|
||||
"escalation:I understand your frustration with {{issue}}. Let me escalate this to {{department}}."
|
||||
"resolution:Great! I've resolved your {{issue}}. Is there anything else I can help with?"
|
||||
)
|
||||
|
||||
for template in "${templates[@]}"; do
|
||||
IFS=':' read -r id prompt <<< "$template"
|
||||
tg-set-prompt --id "${domain}-${id}" --prompt "$prompt"
|
||||
done
|
||||
```
|
||||
|
||||
## System Prompt Configuration
|
||||
|
||||
### General Purpose System Prompt
|
||||
```bash
|
||||
tg-set-prompt --system "You are a knowledgeable AI assistant. Provide accurate, helpful responses. When you don't know something, say so clearly. Always consider the context and be concise unless detail is specifically requested."
|
||||
```
|
||||
|
||||
### Domain-Specific System Prompt
|
||||
```bash
|
||||
tg-set-prompt --system "You are a technical documentation assistant specializing in software development. Focus on clarity, accuracy, and practical examples. Always include code snippets when relevant and explain complex concepts step-by-step."
|
||||
```
|
||||
|
||||
### Role-Based System Prompt
|
||||
```bash
|
||||
tg-set-prompt --system "You are a data analyst AI. When analyzing data, always consider statistical significance, potential biases, and limitations. Present findings objectively and suggest actionable insights."
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Missing Required Fields
|
||||
```bash
|
||||
Exception: Must specify --id for prompt
|
||||
```
|
||||
**Solution**: Provide both `--id` and `--prompt` for template creation.
|
||||
|
||||
### Invalid Response Type
|
||||
```bash
|
||||
Exception: Response must be one of: text json
|
||||
```
|
||||
**Solution**: Use only `text` or `json` for the `--response` option.
|
||||
|
||||
### Invalid JSON Schema
|
||||
```bash
|
||||
Exception: JSON schema must be valid JSON
|
||||
```
|
||||
**Solution**: Validate JSON schema syntax before using `--schema`.
|
||||
|
||||
### Conflicting Options
|
||||
```bash
|
||||
Exception: Can't use --system with other args
|
||||
```
|
||||
**Solution**: Use `--system` alone, or use template options without `--system`.
|
||||
|
||||
## Template Testing
|
||||
|
||||
### Test Template Creation
|
||||
```bash
|
||||
# Create and test a simple template
|
||||
tg-set-prompt \
|
||||
--id "test-template" \
|
||||
--prompt "Test template with {{variable1}} and {{variable2}}"
|
||||
|
||||
# Test the template
|
||||
tg-invoke-prompt test-template variable1="hello" variable2="world"
|
||||
```
|
||||
|
||||
### Validate JSON Templates
|
||||
```bash
|
||||
# Create JSON template
|
||||
tg-set-prompt \
|
||||
--id "json-test" \
|
||||
--prompt "Extract data from: {{text}}" \
|
||||
--response "json" \
|
||||
--schema '{"type": "object", "properties": {"result": {"type": "string"}}}'
|
||||
|
||||
# Test JSON response
|
||||
tg-invoke-prompt json-test text="Sample text for testing"
|
||||
```
|
||||
|
||||
### Template Iteration
|
||||
```bash
|
||||
# Version 1
|
||||
tg-set-prompt \
|
||||
--id "analysis-v1" \
|
||||
--prompt "Analyze: {{data}}"
|
||||
|
||||
# Version 2 (improved)
|
||||
tg-set-prompt \
|
||||
--id "analysis-v2" \
|
||||
--prompt "Analyze the following {{data_type}} and provide insights about {{focus}}:\n\n{{data}}\n\nConsider: {{considerations}}"
|
||||
|
||||
# Version 3 (structured)
|
||||
tg-set-prompt \
|
||||
--id "analysis-v3" \
|
||||
--prompt "Analyze: {{data}}" \
|
||||
--response "json" \
|
||||
--schema '{"type": "object", "properties": {"summary": {"type": "string"}, "insights": {"type": "array"}}}'
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Template Design
|
||||
```bash
|
||||
# Good: Clear, specific prompts
|
||||
tg-set-prompt \
|
||||
--id "good-summary" \
|
||||
--prompt "Summarize this {{document_type}} in {{word_count}} words, focusing on {{key_aspects}}:\n\n{{content}}"
|
||||
|
||||
# Better: Include context and constraints
|
||||
tg-set-prompt \
|
||||
--id "better-summary" \
|
||||
--prompt "Task: Summarize the following {{document_type}}
|
||||
Length: {{word_count}} words maximum
|
||||
Focus: {{key_aspects}}
|
||||
Audience: {{target_audience}}
|
||||
|
||||
Document:
|
||||
{{content}}
|
||||
|
||||
Summary:"
|
||||
```
|
||||
|
||||
### Variable Naming
|
||||
```bash
|
||||
# Use descriptive variable names
|
||||
tg-set-prompt \
|
||||
--id "descriptive-vars" \
|
||||
--prompt "Analyze {{data_source}} data from {{time_period}} for {{business_metric}} trends"
|
||||
|
||||
# Group related variables
|
||||
tg-set-prompt \
|
||||
--id "grouped-vars" \
|
||||
--prompt "Compare {{baseline_data}} vs {{comparison_data}} using {{analysis_method}}"
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `TRUSTGRAPH_URL`: Default API URL
|
||||
|
||||
## Related Commands
|
||||
|
||||
- [`tg-show-prompts`](tg-show-prompts.md) - Display configured prompts
|
||||
- [`tg-invoke-prompt`](tg-invoke-prompt.md) - Use prompt templates
|
||||
- [`tg-invoke-document-rag`](tg-invoke-document-rag.md) - Document-based AI queries
|
||||
|
||||
## API Integration
|
||||
|
||||
This command uses the [Config API](../apis/api-config.md) to store prompt templates and system prompts in TrustGraph's configuration system.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Clear Templates**: Write clear, specific prompt templates
|
||||
2. **Variable Names**: Use descriptive variable names
|
||||
3. **Response Types**: Choose appropriate response types for your use case
|
||||
4. **Schema Validation**: Always validate JSON schemas before setting
|
||||
5. **Version Control**: Consider versioning important templates
|
||||
6. **Testing**: Test templates thoroughly with various inputs
|
||||
7. **Documentation**: Document template variables and expected usage
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Template Not Working
|
||||
```bash
|
||||
# Check template exists
|
||||
tg-show-prompts | grep "template-id"
|
||||
|
||||
# Verify variable names match
|
||||
tg-invoke-prompt template-id var1="test" var2="test"
|
||||
```
|
||||
|
||||
### JSON Schema Errors
|
||||
```bash
|
||||
# Validate schema separately
|
||||
echo '{"type": "object"}' | jq .
|
||||
|
||||
# Test with simple schema first
|
||||
tg-set-prompt --id "test" --prompt "test" --response "json" --schema '{"type": "string"}'
|
||||
```
|
||||
|
||||
### System Prompt Issues
|
||||
```bash
|
||||
# Check current system prompt
|
||||
tg-show-prompts | grep -A5 "System prompt"
|
||||
|
||||
# Reset if needed
|
||||
tg-set-prompt --system "Default system prompt"
|
||||
```
|
||||
464
docs/cli/tg-set-token-costs.md
Normal file
464
docs/cli/tg-set-token-costs.md
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
# tg-set-token-costs
|
||||
|
||||
Sets token cost configuration for language models in TrustGraph.
|
||||
|
||||
## Synopsis
|
||||
|
||||
```bash
|
||||
tg-set-token-costs --model MODEL_ID -i INPUT_COST -o OUTPUT_COST [options]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `tg-set-token-costs` command configures the token pricing for language models used by TrustGraph. This information is used for cost tracking, billing, and resource management across AI operations.
|
||||
|
||||
Token costs are specified in dollars per million tokens and are stored in TrustGraph's configuration system for use by cost monitoring and reporting tools.
|
||||
|
||||
## Options
|
||||
|
||||
### Required Arguments
|
||||
|
||||
- `--model MODEL_ID`: Language model identifier
|
||||
- `-i, --input-costs COST`: Input token cost in $ per 1M tokens
|
||||
- `-o, --output-costs COST`: Output token cost in $ per 1M tokens
|
||||
|
||||
### Optional Arguments
|
||||
|
||||
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
|
||||
|
||||
## Examples
|
||||
|
||||
### Set Costs for GPT-4
|
||||
```bash
|
||||
tg-set-token-costs \
|
||||
--model "gpt-4" \
|
||||
-i 30.0 \
|
||||
-o 60.0
|
||||
```
|
||||
|
||||
### Set Costs for Claude Sonnet
|
||||
```bash
|
||||
tg-set-token-costs \
|
||||
--model "claude-3-sonnet" \
|
||||
-i 3.0 \
|
||||
-o 15.0
|
||||
```
|
||||
|
||||
### Set Costs for Local Model
|
||||
```bash
|
||||
tg-set-token-costs \
|
||||
--model "llama-2-7b" \
|
||||
-i 0.0 \
|
||||
-o 0.0
|
||||
```
|
||||
|
||||
### Set Costs with Custom API URL
|
||||
```bash
|
||||
tg-set-token-costs \
|
||||
--model "gpt-3.5-turbo" \
|
||||
-i 0.5 \
|
||||
-o 1.5 \
|
||||
-u http://production:8088/
|
||||
```
|
||||
|
||||
## Model Pricing Examples
|
||||
|
||||
### OpenAI Models (as of 2024)
|
||||
```bash
|
||||
# GPT-4 Turbo
|
||||
tg-set-token-costs --model "gpt-4-turbo" -i 10.0 -o 30.0
|
||||
|
||||
# GPT-4
|
||||
tg-set-token-costs --model "gpt-4" -i 30.0 -o 60.0
|
||||
|
||||
# GPT-3.5 Turbo
|
||||
tg-set-token-costs --model "gpt-3.5-turbo" -i 0.5 -o 1.5
|
||||
```
|
||||
|
||||
### Anthropic Models
|
||||
```bash
|
||||
# Claude 3 Opus
|
||||
tg-set-token-costs --model "claude-3-opus" -i 15.0 -o 75.0
|
||||
|
||||
# Claude 3 Sonnet
|
||||
tg-set-token-costs --model "claude-3-sonnet" -i 3.0 -o 15.0
|
||||
|
||||
# Claude 3 Haiku
|
||||
tg-set-token-costs --model "claude-3-haiku" -i 0.25 -o 1.25
|
||||
```
|
||||
|
||||
### Google Models
|
||||
```bash
|
||||
# Gemini Pro
|
||||
tg-set-token-costs --model "gemini-pro" -i 0.5 -o 1.5
|
||||
|
||||
# Gemini Ultra
|
||||
tg-set-token-costs --model "gemini-ultra" -i 8.0 -o 24.0
|
||||
```
|
||||
|
||||
### Local/Open Source Models
|
||||
```bash
|
||||
# Local models typically have no API costs
|
||||
tg-set-token-costs --model "llama-2-70b" -i 0.0 -o 0.0
|
||||
tg-set-token-costs --model "mistral-7b" -i 0.0 -o 0.0
|
||||
tg-set-token-costs --model "local-model" -i 0.0 -o 0.0
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Cost Tracking Setup
|
||||
```bash
|
||||
# Set up comprehensive cost tracking
|
||||
models=(
|
||||
"gpt-4:30.0:60.0"
|
||||
"gpt-3.5-turbo:0.5:1.5"
|
||||
"claude-3-sonnet:3.0:15.0"
|
||||
"claude-3-haiku:0.25:1.25"
|
||||
)
|
||||
|
||||
for model_config in "${models[@]}"; do
|
||||
IFS=':' read -r model input_cost output_cost <<< "$model_config"
|
||||
echo "Setting costs for $model..."
|
||||
tg-set-token-costs --model "$model" -i "$input_cost" -o "$output_cost"
|
||||
done
|
||||
```
|
||||
|
||||
### Environment-Specific Pricing
|
||||
```bash
|
||||
# Set different costs for different environments
|
||||
set_environment_costs() {
|
||||
local env_url="$1"
|
||||
local multiplier="$2" # Cost multiplier for environment
|
||||
|
||||
echo "Setting costs for environment: $env_url (multiplier: $multiplier)"
|
||||
|
||||
# Base costs
|
||||
declare -A base_costs=(
|
||||
["gpt-4"]="30.0:60.0"
|
||||
["claude-3-sonnet"]="3.0:15.0"
|
||||
["gpt-3.5-turbo"]="0.5:1.5"
|
||||
)
|
||||
|
||||
for model in "${!base_costs[@]}"; do
|
||||
IFS=':' read -r input_cost output_cost <<< "${base_costs[$model]}"
|
||||
|
||||
# Apply multiplier
|
||||
adjusted_input=$(echo "$input_cost * $multiplier" | bc -l)
|
||||
adjusted_output=$(echo "$output_cost * $multiplier" | bc -l)
|
||||
|
||||
echo " $model: input=$adjusted_input, output=$adjusted_output"
|
||||
tg-set-token-costs \
|
||||
--model "$model" \
|
||||
-i "$adjusted_input" \
|
||||
-o "$adjusted_output" \
|
||||
-u "$env_url"
|
||||
done
|
||||
}
|
||||
|
||||
# Production environment (full cost)
|
||||
set_environment_costs "http://prod:8088/" 1.0
|
||||
|
||||
# Development environment (reduced cost for budgeting)
|
||||
set_environment_costs "http://dev:8088/" 0.1
|
||||
```
|
||||
|
||||
### Cost Update Automation
|
||||
```bash
|
||||
# Automated cost updates from pricing file
|
||||
update_costs_from_file() {
|
||||
local pricing_file="$1"
|
||||
|
||||
if [ ! -f "$pricing_file" ]; then
|
||||
echo "Pricing file not found: $pricing_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Updating costs from: $pricing_file"
|
||||
|
||||
# Expected format: model_id,input_cost,output_cost
|
||||
while IFS=',' read -r model input_cost output_cost; do
|
||||
# Skip header line
|
||||
if [ "$model" = "model_id" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Updating $model: input=$input_cost, output=$output_cost"
|
||||
tg-set-token-costs --model "$model" -i "$input_cost" -o "$output_cost"
|
||||
|
||||
done < "$pricing_file"
|
||||
}
|
||||
|
||||
# Create example pricing file
|
||||
cat > model_pricing.csv << EOF
|
||||
model_id,input_cost,output_cost
|
||||
gpt-4,30.0,60.0
|
||||
gpt-3.5-turbo,0.5,1.5
|
||||
claude-3-sonnet,3.0,15.0
|
||||
claude-3-haiku,0.25,1.25
|
||||
EOF
|
||||
|
||||
# Update costs from file
|
||||
update_costs_from_file "model_pricing.csv"
|
||||
```
|
||||
|
||||
### Bulk Cost Management
|
||||
```bash
|
||||
# Bulk cost updates with validation
|
||||
bulk_cost_update() {
|
||||
local updates=(
|
||||
"gpt-4-turbo:10.0:30.0"
|
||||
"gpt-4:30.0:60.0"
|
||||
"claude-3-opus:15.0:75.0"
|
||||
"claude-3-sonnet:3.0:15.0"
|
||||
"gemini-pro:0.5:1.5"
|
||||
)
|
||||
|
||||
echo "Bulk cost update starting..."
|
||||
|
||||
for update in "${updates[@]}"; do
|
||||
IFS=':' read -r model input_cost output_cost <<< "$update"
|
||||
|
||||
# Validate costs are numeric
|
||||
if ! [[ "$input_cost" =~ ^[0-9]+\.?[0-9]*$ ]] || ! [[ "$output_cost" =~ ^[0-9]+\.?[0-9]*$ ]]; then
|
||||
echo "Error: Invalid cost format for $model"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Setting costs for $model..."
|
||||
if tg-set-token-costs --model "$model" -i "$input_cost" -o "$output_cost"; then
|
||||
echo "✓ Updated $model"
|
||||
else
|
||||
echo "✗ Failed to update $model"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Bulk update completed"
|
||||
}
|
||||
|
||||
bulk_cost_update
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Cost Tier Management
|
||||
```bash
|
||||
# Manage different cost tiers
|
||||
set_cost_tier() {
|
||||
local tier="$1"
|
||||
|
||||
case "$tier" in
|
||||
"premium")
|
||||
echo "Setting premium tier costs..."
|
||||
tg-set-token-costs --model "gpt-4" -i 30.0 -o 60.0
|
||||
tg-set-token-costs --model "claude-3-opus" -i 15.0 -o 75.0
|
||||
;;
|
||||
"standard")
|
||||
echo "Setting standard tier costs..."
|
||||
tg-set-token-costs --model "gpt-3.5-turbo" -i 0.5 -o 1.5
|
||||
tg-set-token-costs --model "claude-3-sonnet" -i 3.0 -o 15.0
|
||||
;;
|
||||
"budget")
|
||||
echo "Setting budget tier costs..."
|
||||
tg-set-token-costs --model "claude-3-haiku" -i 0.25 -o 1.25
|
||||
tg-set-token-costs --model "local-model" -i 0.0 -o 0.0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown tier: $tier"
|
||||
echo "Available tiers: premium, standard, budget"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Set costs for different tiers
|
||||
set_cost_tier "premium"
|
||||
set_cost_tier "standard"
|
||||
set_cost_tier "budget"
|
||||
```
|
||||
|
||||
### Dynamic Pricing Updates
|
||||
```bash
|
||||
# Update costs based on current market rates
|
||||
update_dynamic_pricing() {
|
||||
local pricing_api_url="$1" # Hypothetical pricing API
|
||||
|
||||
echo "Fetching current pricing from: $pricing_api_url"
|
||||
|
||||
# This would integrate with actual pricing APIs
|
||||
# For demonstration, using static data
|
||||
|
||||
declare -A current_prices=(
|
||||
["gpt-4"]="30.0:60.0"
|
||||
["gpt-3.5-turbo"]="0.5:1.5"
|
||||
["claude-3-sonnet"]="3.0:15.0"
|
||||
)
|
||||
|
||||
for model in "${!current_prices[@]}"; do
|
||||
IFS=':' read -r input_cost output_cost <<< "${current_prices[$model]}"
|
||||
|
||||
echo "Updating $model with current market rates..."
|
||||
tg-set-token-costs --model "$model" -i "$input_cost" -o "$output_cost"
|
||||
done
|
||||
}
|
||||
```
|
||||
|
||||
### Cost Validation
|
||||
```bash
|
||||
# Validate cost settings
|
||||
validate_costs() {
|
||||
local model="$1"
|
||||
local input_cost="$2"
|
||||
local output_cost="$3"
|
||||
|
||||
echo "Validating costs for $model..."
|
||||
|
||||
# Check cost reasonableness
|
||||
if (( $(echo "$input_cost < 0" | bc -l) )); then
|
||||
echo "Error: Input cost cannot be negative"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( $(echo "$output_cost < 0" | bc -l) )); then
|
||||
echo "Error: Output cost cannot be negative"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if output cost is typically higher
|
||||
if (( $(echo "$output_cost < $input_cost" | bc -l) )); then
|
||||
echo "Warning: Output cost is lower than input cost (unusual but not invalid)"
|
||||
fi
|
||||
|
||||
# Check for extremely high costs
|
||||
if (( $(echo "$input_cost > 100" | bc -l) )) || (( $(echo "$output_cost > 200" | bc -l) )); then
|
||||
echo "Warning: Costs are unusually high"
|
||||
fi
|
||||
|
||||
echo "Validation passed for $model"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Validate before setting
|
||||
if validate_costs "gpt-4" 30.0 60.0; then
|
||||
tg-set-token-costs --model "gpt-4" -i 30.0 -o 60.0
|
||||
fi
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Missing Required Arguments
|
||||
```bash
|
||||
Exception: error: the following arguments are required: --model, -i/--input-costs, -o/--output-costs
|
||||
```
|
||||
**Solution**: Provide all required arguments: model ID, input cost, and output cost.
|
||||
|
||||
### Invalid Cost Values
|
||||
```bash
|
||||
Exception: argument -i/--input-costs: invalid float value
|
||||
```
|
||||
**Solution**: Ensure cost values are valid numbers (e.g., 1.5, not "1.5a").
|
||||
|
||||
### API Connection Issues
|
||||
```bash
|
||||
Exception: Connection refused
|
||||
```
|
||||
**Solution**: Check API URL and ensure TrustGraph is running.
|
||||
|
||||
### Configuration Access Errors
|
||||
```bash
|
||||
Exception: Access denied to configuration
|
||||
```
|
||||
**Solution**: Verify user permissions for configuration management.
|
||||
|
||||
## Cost Monitoring Integration
|
||||
|
||||
### Cost Verification
|
||||
```bash
|
||||
# Verify costs were set correctly
|
||||
verify_costs() {
|
||||
local model="$1"
|
||||
|
||||
echo "Verifying costs for model: $model"
|
||||
|
||||
# Check current settings
|
||||
if costs=$(tg-show-token-costs | grep "$model"); then
|
||||
echo "Current costs: $costs"
|
||||
else
|
||||
echo "Error: No costs found for model $model"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Set and verify
|
||||
tg-set-token-costs --model "test-model" -i 1.0 -o 2.0
|
||||
verify_costs "test-model"
|
||||
```
|
||||
|
||||
### Cost Reporting Integration
|
||||
```bash
|
||||
# Generate cost report after updates
|
||||
generate_cost_report() {
|
||||
local report_file="cost_report_$(date +%Y%m%d_%H%M%S).txt"
|
||||
|
||||
echo "Cost Configuration Report - $(date)" > "$report_file"
|
||||
echo "======================================" >> "$report_file"
|
||||
|
||||
tg-show-token-costs >> "$report_file"
|
||||
|
||||
echo "Report generated: $report_file"
|
||||
}
|
||||
|
||||
# Update costs and generate report
|
||||
tg-set-token-costs --model "gpt-4" -i 30.0 -o 60.0
|
||||
generate_cost_report
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `TRUSTGRAPH_URL`: Default API URL
|
||||
|
||||
## Related Commands
|
||||
|
||||
- [`tg-show-token-costs`](tg-show-token-costs.md) - Display current token costs
|
||||
- [`tg-show-config`](tg-show-config.md) - Show configuration settings (if available)
|
||||
|
||||
## API Integration
|
||||
|
||||
This command uses the [Config API](../apis/api-config.md) to store token cost configuration in TrustGraph's configuration system.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Regular Updates**: Keep costs current with market rates
|
||||
2. **Validation**: Validate cost values before setting
|
||||
3. **Documentation**: Document cost sources and update procedures
|
||||
4. **Environment Consistency**: Maintain consistent costs across environments
|
||||
5. **Monitoring**: Track cost changes over time
|
||||
6. **Backup**: Export cost configurations for backup
|
||||
7. **Automation**: Automate cost updates where possible
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Costs Not Taking Effect
|
||||
```bash
|
||||
# Verify costs were set
|
||||
tg-show-token-costs | grep "model-name"
|
||||
|
||||
# Check API connectivity
|
||||
curl -s "$TRUSTGRAPH_URL/api/v1/config" > /dev/null
|
||||
```
|
||||
|
||||
### Incorrect Cost Calculations
|
||||
```bash
|
||||
# Verify cost format (per million tokens)
|
||||
# $30 per million tokens = 30.0, not 0.00003
|
||||
|
||||
# Check decimal precision
|
||||
echo "scale=6; 30/1000000" | bc -l # This gives cost per token
|
||||
```
|
||||
|
||||
### Permission Issues
|
||||
```bash
|
||||
# Check configuration access
|
||||
tg-show-token-costs
|
||||
|
||||
# Verify user has admin privileges for cost management
|
||||
```
|
||||
454
docs/cli/tg-show-prompts.md
Normal file
454
docs/cli/tg-show-prompts.md
Normal file
|
|
@ -0,0 +1,454 @@
|
|||
# tg-show-prompts
|
||||
|
||||
Displays all configured prompt templates and system prompts in TrustGraph.
|
||||
|
||||
## Synopsis
|
||||
|
||||
```bash
|
||||
tg-show-prompts [options]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `tg-show-prompts` command displays all prompt templates and the system prompt currently configured in TrustGraph. This includes template IDs, prompt text, response types, and JSON schemas for structured responses.
|
||||
|
||||
Use this command to review existing prompts, verify configurations, and understand available templates for use with `tg-invoke-prompt`.
|
||||
|
||||
## Options
|
||||
|
||||
### Optional Arguments
|
||||
|
||||
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
|
||||
|
||||
## Examples
|
||||
|
||||
### Display All Prompts
|
||||
```bash
|
||||
tg-show-prompts
|
||||
```
|
||||
|
||||
### Using Custom API URL
|
||||
```bash
|
||||
tg-show-prompts -u http://production:8088/
|
||||
```
|
||||
|
||||
## Output Format
|
||||
|
||||
The command displays prompts in formatted tables:
|
||||
|
||||
```
|
||||
System prompt:
|
||||
+---------+--------------------------------------------------+
|
||||
| prompt | You are a helpful AI assistant. Always provide |
|
||||
| | accurate, concise responses. When uncertain, |
|
||||
| | clearly state your limitations. |
|
||||
+---------+--------------------------------------------------+
|
||||
|
||||
greeting:
|
||||
+---------+--------------------------------------------------+
|
||||
| prompt | Hello {{name}}, welcome to {{place}}! |
|
||||
+---------+--------------------------------------------------+
|
||||
|
||||
question:
|
||||
+----------+-------------------------------------------------+
|
||||
| prompt | Answer this question based on the context: |
|
||||
| | {{question}} |
|
||||
| | |
|
||||
| | Context: {{context}} |
|
||||
+----------+-------------------------------------------------+
|
||||
|
||||
extract-info:
|
||||
+----------+-------------------------------------------------+
|
||||
| prompt | Extract key information from: {{text}} |
|
||||
| response | json |
|
||||
| schema | {"type": "object", "properties": { |
|
||||
| | "name": {"type": "string"}, |
|
||||
| | "age": {"type": "number"}}} |
|
||||
+----------+-------------------------------------------------+
|
||||
```
|
||||
|
||||
### Template Information
|
||||
|
||||
For each template, the output shows:
|
||||
- **prompt**: The template text with variable placeholders
|
||||
- **response**: Response format (`text` or `json`)
|
||||
- **schema**: JSON schema for structured responses (when applicable)
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Template Discovery
|
||||
```bash
|
||||
# Find all available templates
|
||||
tg-show-prompts | grep "^[a-zA-Z]" | grep ":"
|
||||
|
||||
# Find templates with specific keywords
|
||||
tg-show-prompts | grep -B5 -A5 "analyze"
|
||||
```
|
||||
|
||||
### Template Verification
|
||||
```bash
|
||||
# Check if specific template exists
|
||||
if tg-show-prompts | grep -q "my-template:"; then
|
||||
echo "Template exists"
|
||||
else
|
||||
echo "Template not found"
|
||||
fi
|
||||
```
|
||||
|
||||
### Configuration Review
|
||||
```bash
|
||||
# Review current system prompt
|
||||
tg-show-prompts | grep -A10 "System prompt:"
|
||||
|
||||
# Check JSON response templates
|
||||
tg-show-prompts | grep -B2 -A5 "response.*json"
|
||||
```
|
||||
|
||||
### Template Inventory
|
||||
```bash
|
||||
# Count total templates
|
||||
template_count=$(tg-show-prompts | grep -c "^[a-zA-Z][^:]*:$")
|
||||
echo "Total templates: $template_count"
|
||||
|
||||
# List template names only
|
||||
tg-show-prompts | grep "^[a-zA-Z][^:]*:$" | sed 's/:$//'
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Template Analysis
|
||||
```bash
|
||||
# Analyze template complexity
|
||||
analyze_templates() {
|
||||
echo "Template Analysis"
|
||||
echo "================"
|
||||
|
||||
tg-show-prompts > temp_prompts.txt
|
||||
|
||||
# Count variables per template
|
||||
echo "Templates with variables:"
|
||||
grep -B1 -A5 "{{" temp_prompts.txt | \
|
||||
grep "^[a-zA-Z]" | \
|
||||
while read template; do
|
||||
var_count=$(grep -A5 "$template" temp_prompts.txt | grep -o "{{[^}]*}}" | wc -l)
|
||||
echo " $template $var_count variables"
|
||||
done
|
||||
|
||||
# Find JSON response templates
|
||||
echo -e "\nJSON Response Templates:"
|
||||
grep -B1 "response.*json" temp_prompts.txt | \
|
||||
grep "^[a-zA-Z]" | \
|
||||
sed 's/:$//'
|
||||
|
||||
rm temp_prompts.txt
|
||||
}
|
||||
|
||||
analyze_templates
|
||||
```
|
||||
|
||||
### Template Documentation Generator
|
||||
```bash
|
||||
# Generate template documentation
|
||||
generate_template_docs() {
|
||||
local output_file="template_documentation.md"
|
||||
|
||||
echo "# TrustGraph Prompt Templates" > "$output_file"
|
||||
echo "Generated on $(date)" >> "$output_file"
|
||||
echo "" >> "$output_file"
|
||||
|
||||
# Extract system prompt
|
||||
echo "## System Prompt" >> "$output_file"
|
||||
tg-show-prompts | \
|
||||
awk '/System prompt:/,/^\+.*\+$/' | \
|
||||
grep "| prompt" | \
|
||||
sed 's/| prompt | //' | \
|
||||
sed 's/ *|$//' >> "$output_file"
|
||||
|
||||
echo "" >> "$output_file"
|
||||
echo "## Templates" >> "$output_file"
|
||||
|
||||
# Extract each template
|
||||
tg-show-prompts | \
|
||||
grep "^[a-zA-Z][^:]*:$" | \
|
||||
sed 's/:$//' | \
|
||||
while read template_id; do
|
||||
echo "" >> "$output_file"
|
||||
echo "### $template_id" >> "$output_file"
|
||||
|
||||
# Get template details
|
||||
tg-show-prompts | \
|
||||
awk "/^$template_id:/,/^$/" | \
|
||||
while read line; do
|
||||
if [[ "$line" =~ ^\|\ prompt ]]; then
|
||||
echo "**Prompt:**" >> "$output_file"
|
||||
echo '```' >> "$output_file"
|
||||
echo "$line" | sed 's/| prompt[[:space:]]*| //' | sed 's/ *|$//' >> "$output_file"
|
||||
echo '```' >> "$output_file"
|
||||
elif [[ "$line" =~ ^\|\ response ]]; then
|
||||
response_type=$(echo "$line" | sed 's/| response[[:space:]]*| //' | sed 's/ *|$//')
|
||||
echo "**Response Type:** $response_type" >> "$output_file"
|
||||
elif [[ "$line" =~ ^\|\ schema ]]; then
|
||||
echo "**JSON Schema:**" >> "$output_file"
|
||||
echo '```json' >> "$output_file"
|
||||
echo "$line" | sed 's/| schema[[:space:]]*| //' | sed 's/ *|$//' >> "$output_file"
|
||||
echo '```' >> "$output_file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "Documentation generated: $output_file"
|
||||
}
|
||||
|
||||
generate_template_docs
|
||||
```
|
||||
|
||||
### Template Validation
|
||||
```bash
|
||||
# Validate template configurations
|
||||
validate_templates() {
|
||||
echo "Template Validation Report"
|
||||
echo "========================="
|
||||
|
||||
tg-show-prompts > temp_prompts.txt
|
||||
|
||||
# Check for templates without variables
|
||||
echo "Templates without variables:"
|
||||
grep -B1 -A5 "^[a-zA-Z]" temp_prompts.txt | \
|
||||
grep -v "{{" | \
|
||||
grep "^[a-zA-Z][^:]*:$" | \
|
||||
sed 's/:$//' | \
|
||||
while read template; do
|
||||
if ! grep -A5 "$template:" temp_prompts.txt | grep -q "{{"; then
|
||||
echo " - $template"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check JSON templates have schemas
|
||||
echo -e "\nJSON templates without schemas:"
|
||||
grep -B1 -A10 "response.*json" temp_prompts.txt | \
|
||||
grep -B10 -A10 "response.*json" | \
|
||||
while read -r line; do
|
||||
if [[ "$line" =~ ^([a-zA-Z][^:]*):$ ]]; then
|
||||
template="${BASH_REMATCH[1]}"
|
||||
if ! grep -A10 "$template:" temp_prompts.txt | grep -q "schema"; then
|
||||
echo " - $template"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
rm temp_prompts.txt
|
||||
}
|
||||
|
||||
validate_templates
|
||||
```
|
||||
|
||||
### Template Usage Examples
|
||||
```bash
|
||||
# Generate usage examples for templates
|
||||
generate_usage_examples() {
|
||||
local template_id="$1"
|
||||
|
||||
echo "Usage examples for template: $template_id"
|
||||
echo "========================================"
|
||||
|
||||
# Extract template and find variables
|
||||
tg-show-prompts | \
|
||||
awk "/^$template_id:/,/^$/" | \
|
||||
grep "| prompt" | \
|
||||
sed 's/| prompt[[:space:]]*| //' | \
|
||||
sed 's/ *|$//' | \
|
||||
while read prompt_text; do
|
||||
echo "Template:"
|
||||
echo "$prompt_text"
|
||||
echo ""
|
||||
|
||||
# Extract variables
|
||||
variables=$(echo "$prompt_text" | grep -o "{{[^}]*}}" | sed 's/[{}]//g' | sort | uniq)
|
||||
|
||||
if [ -n "$variables" ]; then
|
||||
echo "Variables:"
|
||||
for var in $variables; do
|
||||
echo " - $var"
|
||||
done
|
||||
echo ""
|
||||
|
||||
echo "Example usage:"
|
||||
cmd="tg-invoke-prompt $template_id"
|
||||
for var in $variables; do
|
||||
case "$var" in
|
||||
*name*) cmd="$cmd $var=\"John Doe\"" ;;
|
||||
*text*|*content*) cmd="$cmd $var=\"Sample text content\"" ;;
|
||||
*question*) cmd="$cmd $var=\"What is this about?\"" ;;
|
||||
*context*) cmd="$cmd $var=\"Background information\"" ;;
|
||||
*) cmd="$cmd $var=\"value\"" ;;
|
||||
esac
|
||||
done
|
||||
echo "$cmd"
|
||||
else
|
||||
echo "No variables found."
|
||||
echo "Usage: tg-invoke-prompt $template_id"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Generate examples for specific template
|
||||
generate_usage_examples "question"
|
||||
```
|
||||
|
||||
### Environment Comparison
|
||||
```bash
|
||||
# Compare templates between environments
|
||||
compare_environments() {
|
||||
local env1_url="$1"
|
||||
local env2_url="$2"
|
||||
|
||||
echo "Comparing templates between environments"
|
||||
echo "======================================"
|
||||
|
||||
# Get templates from both environments
|
||||
tg-show-prompts -u "$env1_url" | grep "^[a-zA-Z][^:]*:$" | sed 's/:$//' | sort > env1_templates.txt
|
||||
tg-show-prompts -u "$env2_url" | grep "^[a-zA-Z][^:]*:$" | sed 's/:$//' | sort > env2_templates.txt
|
||||
|
||||
echo "Environment 1 ($env1_url): $(wc -l < env1_templates.txt) templates"
|
||||
echo "Environment 2 ($env2_url): $(wc -l < env2_templates.txt) templates"
|
||||
echo ""
|
||||
|
||||
# Find differences
|
||||
echo "Templates only in Environment 1:"
|
||||
comm -23 env1_templates.txt env2_templates.txt | sed 's/^/ - /'
|
||||
|
||||
echo -e "\nTemplates only in Environment 2:"
|
||||
comm -13 env1_templates.txt env2_templates.txt | sed 's/^/ - /'
|
||||
|
||||
echo -e "\nCommon templates:"
|
||||
comm -12 env1_templates.txt env2_templates.txt | sed 's/^/ - /'
|
||||
|
||||
rm env1_templates.txt env2_templates.txt
|
||||
}
|
||||
|
||||
# Compare development and production
|
||||
compare_environments "http://dev:8088/" "http://prod:8088/"
|
||||
```
|
||||
|
||||
### Template Export/Import
|
||||
```bash
|
||||
# Export templates to JSON
|
||||
export_templates() {
|
||||
local output_file="$1"
|
||||
|
||||
echo "Exporting templates to: $output_file"
|
||||
|
||||
echo "{" > "$output_file"
|
||||
echo " \"export_date\": \"$(date -Iseconds)\"," >> "$output_file"
|
||||
echo " \"system_prompt\": \"$(tg-show-prompts | awk '/System prompt:/,/^\+.*\+$/' | grep '| prompt' | sed 's/| prompt[[:space:]]*| //' | sed 's/ *|$//' | sed 's/"/\\"/g')\"," >> "$output_file"
|
||||
echo " \"templates\": {" >> "$output_file"
|
||||
|
||||
first=true
|
||||
tg-show-prompts | \
|
||||
grep "^[a-zA-Z][^:]*:$" | \
|
||||
sed 's/:$//' | \
|
||||
while read template_id; do
|
||||
if [ "$first" = "false" ]; then
|
||||
echo "," >> "$output_file"
|
||||
fi
|
||||
first=false
|
||||
|
||||
echo -n " \"$template_id\": {" >> "$output_file"
|
||||
|
||||
# Extract template details
|
||||
tg-show-prompts | \
|
||||
awk "/^$template_id:/,/^$/" | \
|
||||
while read line; do
|
||||
if [[ "$line" =~ ^\|\ prompt ]]; then
|
||||
prompt=$(echo "$line" | sed 's/| prompt[[:space:]]*| //' | sed 's/ *|$//' | sed 's/"/\\"/g')
|
||||
echo -n "\"prompt\": \"$prompt\"" >> "$output_file"
|
||||
elif [[ "$line" =~ ^\|\ response ]]; then
|
||||
response=$(echo "$line" | sed 's/| response[[:space:]]*| //' | sed 's/ *|$//')
|
||||
echo -n ", \"response\": \"$response\"" >> "$output_file"
|
||||
elif [[ "$line" =~ ^\|\ schema ]]; then
|
||||
schema=$(echo "$line" | sed 's/| schema[[:space:]]*| //' | sed 's/ *|$//' | sed 's/"/\\"/g')
|
||||
echo -n ", \"schema\": \"$schema\"" >> "$output_file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "}" >> "$output_file"
|
||||
done
|
||||
|
||||
echo " }" >> "$output_file"
|
||||
echo "}" >> "$output_file"
|
||||
|
||||
echo "Export completed: $output_file"
|
||||
}
|
||||
|
||||
# Export current templates
|
||||
export_templates "templates_backup.json"
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Connection Issues
|
||||
```bash
|
||||
Exception: Connection refused
|
||||
```
|
||||
**Solution**: Check API URL and ensure TrustGraph is running.
|
||||
|
||||
### Permission Errors
|
||||
```bash
|
||||
Exception: Access denied
|
||||
```
|
||||
**Solution**: Verify user permissions for configuration access.
|
||||
|
||||
### No Templates Found
|
||||
```bash
|
||||
# Empty output or no templates section
|
||||
```
|
||||
**Solution**: Check if any templates are configured with `tg-set-prompt`.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `TRUSTGRAPH_URL`: Default API URL
|
||||
|
||||
## Related Commands
|
||||
|
||||
- [`tg-set-prompt`](tg-set-prompt.md) - Create/update prompt templates
|
||||
- [`tg-invoke-prompt`](tg-invoke-prompt.md) - Use prompt templates
|
||||
- [`tg-invoke-document-rag`](tg-invoke-document-rag.md) - Document-based queries
|
||||
|
||||
## API Integration
|
||||
|
||||
This command uses the [Config API](../apis/api-config.md) to retrieve prompt templates and system prompts from TrustGraph's configuration system.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Regular Review**: Periodically review templates for relevance and accuracy
|
||||
2. **Documentation**: Document template purposes and expected variables
|
||||
3. **Version Control**: Track template changes over time
|
||||
4. **Testing**: Verify templates work as expected after viewing
|
||||
5. **Organization**: Use consistent naming conventions for templates
|
||||
6. **Cleanup**: Remove unused or outdated templates
|
||||
7. **Backup**: Export templates for backup and migration purposes
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Formatting Issues
|
||||
```bash
|
||||
# If output is garbled or truncated
|
||||
export COLUMNS=120
|
||||
tg-show-prompts
|
||||
```
|
||||
|
||||
### Missing Templates
|
||||
```bash
|
||||
# Check if templates are actually configured
|
||||
tg-show-prompts | grep -c "^[a-zA-Z].*:$"
|
||||
|
||||
# Verify API connectivity
|
||||
curl -s "$TRUSTGRAPH_URL/api/v1/config" > /dev/null
|
||||
```
|
||||
|
||||
### Template Not Displaying
|
||||
```bash
|
||||
# Check template was set correctly
|
||||
tg-set-prompt --id "test" --prompt "test template"
|
||||
tg-show-prompts | grep "test:"
|
||||
```
|
||||
470
docs/cli/tg-show-token-costs.md
Normal file
470
docs/cli/tg-show-token-costs.md
Normal file
|
|
@ -0,0 +1,470 @@
|
|||
# tg-show-token-costs
|
||||
|
||||
Displays token cost configuration for language models in TrustGraph.
|
||||
|
||||
## Synopsis
|
||||
|
||||
```bash
|
||||
tg-show-token-costs [options]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `tg-show-token-costs` command displays the configured token pricing for all language models in TrustGraph. This information shows input and output costs per million tokens, which is used for cost tracking, billing, and resource management.
|
||||
|
||||
The costs are displayed in a tabular format showing model names and their associated pricing in dollars per million tokens.
|
||||
|
||||
## Options
|
||||
|
||||
### Optional Arguments
|
||||
|
||||
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
|
||||
|
||||
## Examples
|
||||
|
||||
### Display All Token Costs
|
||||
```bash
|
||||
tg-show-token-costs
|
||||
```
|
||||
|
||||
### Using Custom API URL
|
||||
```bash
|
||||
tg-show-token-costs -u http://production:8088/
|
||||
```
|
||||
|
||||
## Output Format
|
||||
|
||||
The command displays costs in a formatted table:
|
||||
|
||||
```
|
||||
+----------------+-------------+--------------+
|
||||
| model | input, $/Mt | output, $/Mt |
|
||||
+----------------+-------------+--------------+
|
||||
| gpt-4 | 30.000 | 60.000 |
|
||||
| gpt-3.5-turbo | 0.500 | 1.500 |
|
||||
| claude-3-sonnet| 3.000 | 15.000 |
|
||||
| claude-3-haiku | 0.250 | 1.250 |
|
||||
| local-model | 0.000 | 0.000 |
|
||||
+----------------+-------------+--------------+
|
||||
```
|
||||
|
||||
### Column Details
|
||||
|
||||
- **model**: Language model identifier
|
||||
- **input, $/Mt**: Cost per million input tokens in USD
|
||||
- **output, $/Mt**: Cost per million output tokens in USD
|
||||
|
||||
### Missing Configuration
|
||||
|
||||
If a model has incomplete cost configuration:
|
||||
```
|
||||
+----------------+-------------+--------------+
|
||||
| model | input, $/Mt | output, $/Mt |
|
||||
+----------------+-------------+--------------+
|
||||
| unconfigured | - | - |
|
||||
+----------------+-------------+--------------+
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
### Cost Monitoring
|
||||
```bash
|
||||
# Check current cost configuration
|
||||
tg-show-token-costs
|
||||
|
||||
# Monitor costs over time
|
||||
echo "$(date): $(tg-show-token-costs)" >> cost_history.log
|
||||
```
|
||||
|
||||
### Cost Analysis
|
||||
```bash
|
||||
# Find most expensive models
|
||||
tg-show-token-costs | grep -v "model" | sort -k3 -nr
|
||||
|
||||
# Find free/local models
|
||||
tg-show-token-costs | grep "0.000"
|
||||
```
|
||||
|
||||
### Budget Planning
|
||||
```bash
|
||||
# Calculate potential costs for usage scenarios
|
||||
analyze_costs() {
|
||||
echo "Cost Analysis for Usage Scenarios"
|
||||
echo "================================="
|
||||
|
||||
# Extract cost data
|
||||
tg-show-token-costs | grep -v "model" | \
|
||||
while read -r line; do
|
||||
model=$(echo "$line" | awk '{print $1}' | tr -d '|' | tr -d ' ')
|
||||
input_cost=$(echo "$line" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$line" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$input_cost" != "-" && "$output_cost" != "-" ]]; then
|
||||
echo "Model: $model"
|
||||
echo " 1M input tokens: \$${input_cost}"
|
||||
echo " 1M output tokens: \$${output_cost}"
|
||||
echo " 10K conversation (5K in/5K out): \$$(echo "scale=3; ($input_cost * 5 + $output_cost * 5) / 1000" | bc -l)"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
analyze_costs
|
||||
```
|
||||
|
||||
### Environment Comparison
|
||||
```bash
|
||||
# Compare costs across environments
|
||||
compare_costs() {
|
||||
local env1_url="$1"
|
||||
local env2_url="$2"
|
||||
|
||||
echo "Cost Comparison"
|
||||
echo "==============="
|
||||
echo "Environment 1: $env1_url"
|
||||
tg-show-token-costs -u "$env1_url"
|
||||
|
||||
echo ""
|
||||
echo "Environment 2: $env2_url"
|
||||
tg-show-token-costs -u "$env2_url"
|
||||
}
|
||||
|
||||
compare_costs "http://dev:8088/" "http://prod:8088/"
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Cost Reporting
|
||||
```bash
|
||||
# Generate detailed cost report
|
||||
generate_cost_report() {
|
||||
local report_file="token_costs_$(date +%Y%m%d_%H%M%S).txt"
|
||||
|
||||
echo "TrustGraph Token Cost Report" > "$report_file"
|
||||
echo "Generated: $(date)" >> "$report_file"
|
||||
echo "============================" >> "$report_file"
|
||||
echo "" >> "$report_file"
|
||||
|
||||
tg-show-token-costs >> "$report_file"
|
||||
|
||||
echo "" >> "$report_file"
|
||||
echo "Cost Analysis:" >> "$report_file"
|
||||
echo "==============" >> "$report_file"
|
||||
|
||||
# Add cost analysis
|
||||
total_models=$(tg-show-token-costs | grep -c "|" | awk '{print $1-3}') # Subtract header rows
|
||||
free_models=$(tg-show-token-costs | grep -c "0.000")
|
||||
paid_models=$((total_models - free_models))
|
||||
|
||||
echo "Total models configured: $total_models" >> "$report_file"
|
||||
echo "Paid models: $paid_models" >> "$report_file"
|
||||
echo "Free models: $free_models" >> "$report_file"
|
||||
|
||||
# Find most expensive models
|
||||
echo "" >> "$report_file"
|
||||
echo "Most expensive models (by output cost):" >> "$report_file"
|
||||
tg-show-token-costs | grep -v "model" | grep -v "^\+" | \
|
||||
sort -k3 -nr | head -3 >> "$report_file"
|
||||
|
||||
echo "Report saved: $report_file"
|
||||
}
|
||||
|
||||
generate_cost_report
|
||||
```
|
||||
|
||||
### Cost Validation
|
||||
```bash
|
||||
# Validate cost configuration
|
||||
validate_cost_config() {
|
||||
echo "Cost Configuration Validation"
|
||||
echo "============================="
|
||||
|
||||
local issues=0
|
||||
|
||||
# Check for unconfigured models
|
||||
unconfigured=$(tg-show-token-costs | grep -c "\-")
|
||||
if [ "$unconfigured" -gt 0 ]; then
|
||||
echo "⚠ Warning: $unconfigured models have incomplete cost configuration"
|
||||
tg-show-token-costs | grep "\-"
|
||||
issues=$((issues + 1))
|
||||
fi
|
||||
|
||||
# Check for zero-cost models (might be intentional)
|
||||
zero_cost=$(tg-show-token-costs | grep -c "0.000.*0.000")
|
||||
if [ "$zero_cost" -gt 0 ]; then
|
||||
echo "ℹ Info: $zero_cost models configured with zero cost (likely local models)"
|
||||
fi
|
||||
|
||||
# Check for unusual cost patterns
|
||||
tg-show-token-costs | grep -v "model" | grep -v "^\+" | \
|
||||
while read -r line; do
|
||||
input_cost=$(echo "$line" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$line" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
model=$(echo "$line" | awk '{print $1}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$input_cost" != "-" && "$output_cost" != "-" ]]; then
|
||||
# Check if output cost is lower than input cost (unusual)
|
||||
if (( $(echo "$output_cost < $input_cost" | bc -l) )); then
|
||||
echo "⚠ Warning: $model has output cost lower than input cost"
|
||||
issues=$((issues + 1))
|
||||
fi
|
||||
|
||||
# Check for extremely high costs
|
||||
if (( $(echo "$input_cost > 100" | bc -l) )) || (( $(echo "$output_cost > 200" | bc -l) )); then
|
||||
echo "⚠ Warning: $model has unusually high costs"
|
||||
issues=$((issues + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$issues" -eq 0 ]; then
|
||||
echo "✓ Cost configuration appears valid"
|
||||
else
|
||||
echo "Found $issues potential issues"
|
||||
fi
|
||||
}
|
||||
|
||||
validate_cost_config
|
||||
```
|
||||
|
||||
### Cost Tracking
|
||||
```bash
|
||||
# Track cost changes over time
|
||||
track_cost_changes() {
|
||||
local history_file="cost_history.txt"
|
||||
local current_file="current_costs.tmp"
|
||||
|
||||
# Get current costs
|
||||
tg-show-token-costs > "$current_file"
|
||||
|
||||
# Check if this is first run
|
||||
if [ ! -f "$history_file" ]; then
|
||||
echo "$(date): Initial cost configuration" >> "$history_file"
|
||||
cat "$current_file" >> "$history_file"
|
||||
echo "---" >> "$history_file"
|
||||
else
|
||||
# Compare with last known state
|
||||
if ! diff -q "$history_file" "$current_file" > /dev/null 2>&1; then
|
||||
echo "$(date): Cost configuration changed" >> "$history_file"
|
||||
|
||||
# Show differences
|
||||
echo "Changes:" >> "$history_file"
|
||||
diff "$history_file" "$current_file" | tail -n +1 >> "$history_file"
|
||||
|
||||
echo "New configuration:" >> "$history_file"
|
||||
cat "$current_file" >> "$history_file"
|
||||
echo "---" >> "$history_file"
|
||||
|
||||
echo "Cost changes detected and logged to $history_file"
|
||||
else
|
||||
echo "No cost changes detected"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm "$current_file"
|
||||
}
|
||||
|
||||
track_cost_changes
|
||||
```
|
||||
|
||||
### Export Cost Data
|
||||
```bash
|
||||
# Export costs to CSV
|
||||
export_costs_csv() {
|
||||
local output_file="$1"
|
||||
|
||||
echo "model,input_cost_per_million,output_cost_per_million" > "$output_file"
|
||||
|
||||
tg-show-token-costs | grep -v "model" | grep -v "^\+" | \
|
||||
while read -r line; do
|
||||
model=$(echo "$line" | awk '{print $1}' | tr -d '|' | tr -d ' ')
|
||||
input_cost=$(echo "$line" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$line" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$model" != "" ]]; then
|
||||
echo "$model,$input_cost,$output_cost" >> "$output_file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Costs exported to: $output_file"
|
||||
}
|
||||
|
||||
# Export to CSV
|
||||
export_costs_csv "token_costs.csv"
|
||||
|
||||
# Export to JSON
|
||||
export_costs_json() {
|
||||
local output_file="$1"
|
||||
|
||||
echo "{" > "$output_file"
|
||||
echo " \"export_date\": \"$(date -Iseconds)\"," >> "$output_file"
|
||||
echo " \"models\": [" >> "$output_file"
|
||||
|
||||
first=true
|
||||
tg-show-token-costs | grep -v "model" | grep -v "^\+" | \
|
||||
while read -r line; do
|
||||
model=$(echo "$line" | awk '{print $1}' | tr -d '|' | tr -d ' ')
|
||||
input_cost=$(echo "$line" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$line" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$model" != "" ]]; then
|
||||
if [ "$first" = "false" ]; then
|
||||
echo "," >> "$output_file"
|
||||
fi
|
||||
first=false
|
||||
|
||||
echo " {" >> "$output_file"
|
||||
echo " \"model\": \"$model\"," >> "$output_file"
|
||||
echo " \"input_cost\": \"$input_cost\"," >> "$output_file"
|
||||
echo " \"output_cost\": \"$output_cost\"" >> "$output_file"
|
||||
echo -n " }" >> "$output_file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "" >> "$output_file"
|
||||
echo " ]" >> "$output_file"
|
||||
echo "}" >> "$output_file"
|
||||
|
||||
echo "Costs exported to: $output_file"
|
||||
}
|
||||
|
||||
export_costs_json "token_costs.json"
|
||||
```
|
||||
|
||||
### Cost Calculation Tools
|
||||
```bash
|
||||
# Calculate costs for usage scenarios
|
||||
calculate_usage_cost() {
|
||||
local model="$1"
|
||||
local input_tokens="$2"
|
||||
local output_tokens="$3"
|
||||
|
||||
echo "Calculating cost for $model usage:"
|
||||
echo " Input tokens: $input_tokens"
|
||||
echo " Output tokens: $output_tokens"
|
||||
|
||||
# Extract costs for specific model
|
||||
costs=$(tg-show-token-costs | grep "$model")
|
||||
|
||||
if [ -z "$costs" ]; then
|
||||
echo "Error: Model $model not found in cost configuration"
|
||||
return 1
|
||||
fi
|
||||
|
||||
input_cost=$(echo "$costs" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$costs" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$input_cost" == "-" || "$output_cost" == "-" ]]; then
|
||||
echo "Error: Incomplete cost configuration for $model"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Calculate total cost
|
||||
total_cost=$(echo "scale=6; ($input_tokens * $input_cost / 1000000) + ($output_tokens * $output_cost / 1000000)" | bc -l)
|
||||
|
||||
echo " Input cost: \$$(echo "scale=6; $input_tokens * $input_cost / 1000000" | bc -l)"
|
||||
echo " Output cost: \$$(echo "scale=6; $output_tokens * $output_cost / 1000000" | bc -l)"
|
||||
echo " Total cost: \$${total_cost}"
|
||||
}
|
||||
|
||||
# Example usage calculations
|
||||
calculate_usage_cost "gpt-4" 1000 500
|
||||
calculate_usage_cost "claude-3-sonnet" 5000 2000
|
||||
```
|
||||
|
||||
### Model Cost Comparison
|
||||
```bash
|
||||
# Compare costs across models for same usage
|
||||
compare_model_costs() {
|
||||
local input_tokens="${1:-1000}"
|
||||
local output_tokens="${2:-500}"
|
||||
|
||||
echo "Cost comparison for $input_tokens input + $output_tokens output tokens:"
|
||||
echo "====================================================================="
|
||||
|
||||
tg-show-token-costs | grep -v "model" | grep -v "^\+" | \
|
||||
while read -r line; do
|
||||
model=$(echo "$line" | awk '{print $1}' | tr -d '|' | tr -d ' ')
|
||||
input_cost=$(echo "$line" | awk '{print $2}' | tr -d '|' | tr -d ' ')
|
||||
output_cost=$(echo "$line" | awk '{print $3}' | tr -d '|' | tr -d ' ')
|
||||
|
||||
if [[ "$model" != "" && "$input_cost" != "-" && "$output_cost" != "-" ]]; then
|
||||
total_cost=$(echo "scale=4; ($input_tokens * $input_cost / 1000000) + ($output_tokens * $output_cost / 1000000)" | bc -l)
|
||||
printf "%-20s \$%s\n" "$model" "$total_cost"
|
||||
fi
|
||||
done | sort -k2 -n
|
||||
}
|
||||
|
||||
# Compare costs for typical usage
|
||||
compare_model_costs 1000 500
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Connection Issues
|
||||
```bash
|
||||
Exception: Connection refused
|
||||
```
|
||||
**Solution**: Check API URL and ensure TrustGraph is running.
|
||||
|
||||
### Permission Errors
|
||||
```bash
|
||||
Exception: Access denied
|
||||
```
|
||||
**Solution**: Verify user permissions for configuration access.
|
||||
|
||||
### No Models Configured
|
||||
```bash
|
||||
# Empty table or no data
|
||||
```
|
||||
**Solution**: Configure model costs with `tg-set-token-costs`.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `TRUSTGRAPH_URL`: Default API URL
|
||||
|
||||
## Related Commands
|
||||
|
||||
- [`tg-set-token-costs`](tg-set-token-costs.md) - Configure token costs
|
||||
- [`tg-show-config`](tg-show-config.md) - Show other configuration settings (if available)
|
||||
|
||||
## API Integration
|
||||
|
||||
This command uses the [Config API](../apis/api-config.md) to retrieve token cost configuration from TrustGraph's configuration system.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Regular Review**: Check cost configurations regularly
|
||||
2. **Cost Tracking**: Monitor cost changes over time
|
||||
3. **Validation**: Validate cost configurations for accuracy
|
||||
4. **Documentation**: Document cost sources and update procedures
|
||||
5. **Reporting**: Generate regular cost reports for budget planning
|
||||
6. **Comparison**: Compare costs across environments
|
||||
7. **Automation**: Automate cost monitoring and alerting
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Missing Cost Data
|
||||
```bash
|
||||
# Check if models are configured
|
||||
tg-show-token-costs | grep -c "model"
|
||||
|
||||
# Verify specific model exists
|
||||
tg-show-token-costs | grep "model-name"
|
||||
```
|
||||
|
||||
### Formatting Issues
|
||||
```bash
|
||||
# If table is garbled
|
||||
export COLUMNS=120
|
||||
tg-show-token-costs
|
||||
```
|
||||
|
||||
### Incomplete Data
|
||||
```bash
|
||||
# Look for models with missing costs
|
||||
tg-show-token-costs | grep "\-"
|
||||
|
||||
# Set missing costs
|
||||
tg-set-token-costs --model "incomplete-model" -i 1.0 -o 2.0
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue