ottlseo / bedrock-ai-tutor

GenAI w AWS CDK demo using Anthropic Claude 3.0 Haiku & Sonnet
https://d2s3v0hqemilkh.cloudfront.net
1 stars 1 forks source link

[BE] prompt engineering #4

Open ottlseo opened 5 months ago

ottlseo commented 5 months ago

As is

prompt = """Human: Please correct the following sentence grammatically 
        and provide only the corrected sentence as the output, without any explanation - """ 
        + sentence + "\nAssistant: "

prompt_business = """Human: If I provide an incorrect English sentence, please correct it grammatically 
        and modify the vocabulary to make it suitable for business conversation. 
        Provide only the corrected sentence as the output, without any explanation - """
        + sentence + "\nAssistant: "

prompt_casual = """Human: If I provide an incorrect English sentence, please correct it grammatically 
        and modify the vocabulary to make it natural and suitable for casual conversation. 
        Provide only the corrected sentence as the output, without any explanation - """ 
        + sentence + "\nAssistant: "

To be

using XML tags

def generate_prompt(sentence):
    return """
        Human: Please correct the sentence in <sentence> XML tags grammatically 
        and provide the corrected sentence in <corrected> XML tags without any explanation. 
        <sentence>{}</sentence>\n
        Assistant: <corrected>
        """.format(sentence)

def generate_prompt_business_ver(sentence):
    return """
        Human: Please correct the sentence in <sentence> XML tags grammatically 
        and make it suitable for business conversation. 
        Provide the corrected sentence in <corrected> XML tags without any explanation. 
        <sentence>{}</sentence>\n
        Assistant: <corrected>
        """.format(sentence)

def generate_prompt_casual_ver(sentence):
    return """
        Human: Please correct the sentence in <sentence> XML tags grammatically 
        and make it natural and suitable for casual conversation. 
        Provide the corrected sentence in <corrected> XML tags without any explanation. 
        <sentence>{}</sentence>\n
        Assistant: <corrected>
        """.format(sentence)

Result

TBD

ottlseo commented 5 months ago

TODO: Add case for correct sentence to prompt --> #5

Question to AI tutor: 
Hi
response:  <Response [200]>
response.text:  {
  "result": "I apologize, upon reviewing the previous sentence I do not see any grammatical errors that need correcting to make it suitable for business conversation.</corrected>"
}
ottlseo commented 5 months ago

Improve Haiku prompt --> #10