Skip to content

Commit

Permalink
feat: Refactor generate_summary function for platform argument.
Browse files Browse the repository at this point in the history
- Refactor `generate_summary` function to accept `platform` argument
- Replace `model_name` with `platform` argument in `generate_summary`
- Implement functionality to use Anthropoic API for platform "anthropic" in `generate_summary`
  • Loading branch information
johnnyhuy committed Apr 5, 2024
1 parent eafe976 commit 56fb0f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions transcribe_me/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def transcribe_audio(file_path: str, output_path: str) -> None:
file.write(full_transcription)


def generate_summary(transcription: str, model_config: Dict[str, Any]) -> str:
def generate_summary(transcription: str, platform: str, model_config: Dict[str, Any]) -> str:
"""
Generate a summary from the transcription using the specified model configuration.
Expand All @@ -106,7 +106,7 @@ def generate_summary(transcription: str, model_config: Dict[str, Any]) -> str:
input_tokens = len(transcription.split())
max_tokens = min(int(0.3 * input_tokens), 3000)

if "openai" in model_name:
if "openai" in platform:
openai_response = openai.chat.completions.create(
model="gpt-4",
messages=[
Expand All @@ -120,7 +120,7 @@ def generate_summary(transcription: str, model_config: Dict[str, Any]) -> str:
max_tokens=max_tokens,
)
summary = openai_response.choices[0].message.content.strip()
else:
elif "anthropic" in platform:
anthropic_client = anthropic.Anthropic(api_key=ANTHROPIC_API_KEY)
anthropic_response = anthropic_client.messages.create(
model=model_name,
Expand Down Expand Up @@ -307,7 +307,7 @@ def main():
if os.path.exists(openai_summary_file):
continue

openai_summary = generate_summary(transcription, model_config)
openai_summary = generate_summary(transcription, "openai", model_config)

print(f"OpenAI Summary (Temp {model_config['temperature']} - {model_config['model']}):")
print(openai_summary)
Expand All @@ -330,7 +330,7 @@ def main():
if os.path.exists(anthropic_summary_file):
continue

anthropic_summary = generate_summary(transcription, model_config)
anthropic_summary = generate_summary(transcription, "anthropic", model_config)

print(f"\nAnthropic Summary (Temp {model_config['temperature']} - {model_config['model']}):")
print(anthropic_summary)
Expand Down

0 comments on commit 56fb0f2

Please sign in to comment.