Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Action: Generate personalized messages #474

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

belmai
Copy link
Contributor

@belmai belmai commented Oct 2, 2024

User description

TP-2510: "Create personalized message" action


PR Type

New AI Action added


Description

  • Implemented the generateMessage action to create personalized messages using LLM, with error handling and integration with OpenAI.
  • Defined fields and data points for message generation, including validation schemas using Zod.
  • Added extensive tests for both mocked and real OpenAI calls to ensure message generation accuracy and reliability.
  • Developed constants and prompt templates to guide LLM in generating structured and compliant messages.

Changes walkthrough 📝

Relevant files
Enhancement
8 files
datapoints.ts
Define data points for message generation                               

extensions/shelly/actions/generateMessage/config/datapoints.ts

  • Defined data points for subject and message.
  • Set value types for data points as strings.
  • +12/-0   
    fields.ts
    Define fields and validation schema for message form         

    extensions/shelly/actions/generateMessage/config/fields.ts

  • Defined fields for message form including communicationObjective,
    personalizationInput, and others.
  • Implemented validation schema using Zod.
  • +72/-0   
    index.ts
    Export fields, validation schema, and data points               

    extensions/shelly/actions/generateMessage/config/index.ts

    • Exported fields and validation schema.
    • Exported data points.
    +2/-0     
    generateMessage.ts
    Implement generateMessage action for personalized messages

    extensions/shelly/actions/generateMessage/generateMessage.ts

  • Implemented generateMessage action for personalized message
    generation.
  • Integrated with LLM for message generation.
  • Added error handling for message generation process.
  • +56/-0   
    index.ts
    Export generateMessage function                                                   

    extensions/shelly/actions/generateMessage/index.ts

    • Exported generateMessage function.
    +1/-0     
    constants.ts
    Define constants and prompt templates for LLM                       

    extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/constants.ts

  • Defined constants and prompt templates for LLM message generation.
  • Created structured output parser using Zod schema.
  • +132/-0 
    generateMessageWithLLM.ts
    Implement generateMessageWithLLM function with retry mechanism

    extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.ts

  • Implemented generateMessageWithLLM function for message generation.
  • Added retry mechanism for handling non-JSON responses.
  • +82/-0   
    index.ts
    Export generateMessageWithLLM function                                     

    extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/index.ts

    • Exported generateMessageWithLLM function.
    +1/-0     
    Tests
    4 files
    generateMessage.test.ts
    Add tests for message generation with mocked LLM                 

    extensions/shelly/actions/generateMessage/generateMessage.test.ts

  • Added tests for message generation with mocked LLM calls.
  • Verified message generation with and without additional instructions.
  • +128/-0 
    generateMessageRealOpenAI.test.ts
    Add tests for real OpenAI message generation                         

    extensions/shelly/actions/generateMessage/generateMessageRealOpenAI.test.ts

  • Added tests for real OpenAI calls in message generation.
  • Verified message content and structure.
  • +95/-0   
    generateMessageWithLLM.test.ts
    Add unit tests for generateMessageWithLLM function             

    extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLM.test.ts

  • Added unit tests for generateMessageWithLLM function.
  • Tested message generation for different scenarios and languages.
  • +88/-0   
    generateMessageWithLLMRealOpenAI.test.ts
    Add integration tests for generateMessageWithLLM with real OpenAI

    extensions/shelly/actions/generateMessage/lib/generateMessageWithLLM/generateMessageWithLLMRealOpenAI.test.ts

  • Added integration tests for generateMessageWithLLM using real OpenAI.
  • Verified message content for different scenarios.
  • +72/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @belmai belmai self-assigned this Oct 2, 2024
    @github-actions github-actions bot added enhancement New feature or request tests Adds or updates tests for an extension Review effort [1-5]: 3 labels Oct 2, 2024
    Copy link

    github-actions bot commented Oct 2, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling
    The error handling in the 'onEvent' function could be improved by providing more specific error messages based on the type of error encountered. This would help in debugging and maintaining the code.

    Parsing Logic
    The logic to parse the AIMessageChunk seems overly complex and could potentially be simplified or better handled within the structured output chain.

    Copy link

    github-actions bot commented Oct 2, 2024

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @belmai belmai merged commit c854074 into main Oct 2, 2024
    1 check passed
    @belmai belmai deleted the TP-2510_ai_action_personalized_message branch October 2, 2024 16:57
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    enhancement New feature or request Review effort [1-5]: 3 tests Adds or updates tests for an extension
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants