feat: Update CLI to use Haiku model with Y default and accurate cost info
This commit is contained in:
@@ -18,12 +18,13 @@ from . import __version__
|
|||||||
CLAUDE_COST_PER_1K_INPUT = 0.015 # Cost per 1K tokens for input
|
CLAUDE_COST_PER_1K_INPUT = 0.015 # Cost per 1K tokens for input
|
||||||
CLAUDE_COST_PER_1K_OUTPUT = 0.075 # Cost per 1K tokens for output
|
CLAUDE_COST_PER_1K_OUTPUT = 0.075 # Cost per 1K tokens for output
|
||||||
ESTIMATED_TOKENS_PER_CHAR = 0.25 # Rough estimate of tokens per character
|
ESTIMATED_TOKENS_PER_CHAR = 0.25 # Rough estimate of tokens per character
|
||||||
|
HAIKU_OUTPUT_TOKENS = 50 # Haiku summaries are very short
|
||||||
|
|
||||||
|
|
||||||
def estimate_api_cost(text: str) -> float:
|
def estimate_api_cost(text: str) -> float:
|
||||||
"""Estimate the cost of sending text to Claude API."""
|
"""Estimate the cost of sending text to Claude API."""
|
||||||
estimated_input_tokens = len(text) * ESTIMATED_TOKENS_PER_CHAR
|
estimated_input_tokens = len(text) * ESTIMATED_TOKENS_PER_CHAR
|
||||||
estimated_output_tokens = 1024 # max_tokens setting
|
estimated_output_tokens = HAIKU_OUTPUT_TOKENS
|
||||||
|
|
||||||
input_cost = (estimated_input_tokens / 1000) * CLAUDE_COST_PER_1K_INPUT
|
input_cost = (estimated_input_tokens / 1000) * CLAUDE_COST_PER_1K_INPUT
|
||||||
output_cost = (estimated_output_tokens / 1000) * CLAUDE_COST_PER_1K_OUTPUT
|
output_cost = (estimated_output_tokens / 1000) * CLAUDE_COST_PER_1K_OUTPUT
|
||||||
@@ -196,7 +197,7 @@ def get_summary_from_claude(text: str, duration_mins: int, prompt: str = None) -
|
|||||||
target_words = max(500, (duration_mins // 10) * 500)
|
target_words = max(500, (duration_mins // 10) * 500)
|
||||||
|
|
||||||
if prompt is None:
|
if prompt is None:
|
||||||
prompt = f"Please summarize this transcript in approximately {target_words} words"
|
prompt = "Please summarize this transcript as a haiku. A haiku is a three-line poem with 5 syllables in the first line, 7 syllables in the second line, and 5 syllables in the third line."
|
||||||
|
|
||||||
message = client.messages.create(
|
message = client.messages.create(
|
||||||
model="claude-3-sonnet-20240229",
|
model="claude-3-sonnet-20240229",
|
||||||
@@ -247,8 +248,8 @@ def main():
|
|||||||
|
|
||||||
if not args.yes:
|
if not args.yes:
|
||||||
try:
|
try:
|
||||||
response = input("\nDo you want to proceed with getting the summary? (y/N): ").strip().lower()
|
response = input("\nDo you want to proceed with getting the summary? (Y/n): ").strip().lower()
|
||||||
if response != 'y':
|
if response == 'n':
|
||||||
print("Operation cancelled by user.")
|
print("Operation cancelled by user.")
|
||||||
cleanup_files(vtt_path)
|
cleanup_files(vtt_path)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user