From fdbfebd65d252c7066878d1eabafbe5c7715ba2d Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 29 Mar 2025 19:13:20 +0000 Subject: [PATCH] Extract prompts to markdown files and add dynamic prompt selection based on transcript content --- prompts/default.md | 14 ++++++++++++++ prompts/idea_app.md | 12 ++++++++++++ summarize_transcripts.py | 26 ++++++++++++++++++-------- 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 prompts/default.md create mode 100644 prompts/idea_app.md diff --git a/prompts/default.md b/prompts/default.md new file mode 100644 index 0000000..c794624 --- /dev/null +++ b/prompts/default.md @@ -0,0 +1,14 @@ +Please provide a concise summary of the following transcript. +Focus on the main topics, key points, and any action items or decisions mentioned. +Keep the summary short, clear, and well-structured. + +Transcript: +{transcript} + +Summary: +{summary} + +Action items: +- [ ] Item one +- [ ] Item two +- [ ] ... \ No newline at end of file diff --git a/prompts/idea_app.md b/prompts/idea_app.md new file mode 100644 index 0000000..88ef1c5 --- /dev/null +++ b/prompts/idea_app.md @@ -0,0 +1,12 @@ +Please analyze this transcript about an app idea and provide a structured summary focusing on: +1. The core app concept and its main purpose +2. Key features and functionality discussed +3. Target audience or user base +4. Any technical considerations or implementation details +5. Potential challenges or concerns raised +6. Next steps or action items mentioned + +Transcript: +{transcript} + +Summary: \ No newline at end of file diff --git a/summarize_transcripts.py b/summarize_transcripts.py index 38e1e40..be0eb16 100755 --- a/summarize_transcripts.py +++ b/summarize_transcripts.py @@ -10,16 +10,26 @@ def read_transcript(transcript_file: Path) -> str: with open(transcript_file, 'r', encoding='utf-8') as f: return f.read() +def load_prompt_template(transcript_text: str) -> str: + """Load the appropriate prompt template based on transcript content.""" + prompt_dir = Path("prompts") + + # Check if transcript contains app-related content + if "idea" in transcript_text.lower() and "app" in transcript_text.lower(): + prompt_file = prompt_dir / "idea_app.md" + else: + prompt_file = prompt_dir / "default.md" + + with open(prompt_file, 'r', encoding='utf-8') as f: + return f.read() + def process_transcript(transcript_text: str) -> str: """Process a transcript using LLaMA to generate a summary.""" - prompt = f"""Please provide a concise summary of the following transcript. -Focus on the main topics, key points, and any action items or decisions mentioned. -Keep the summary clear and well-structured. - -Transcript: -{transcript_text} - -Summary:""" + # Load the appropriate prompt template + prompt_template = load_prompt_template(transcript_text) + + # Format the prompt with the transcript + prompt = prompt_template.format(transcript=transcript_text) # Use Ollama to generate the summary response = ollama.chat(model='llama2', messages=[