Skip to content

baml#13

Merged
bmdavis419 merged 5 commits intomainfrom
staging
Dec 20, 2025
Merged

baml#13
bmdavis419 merged 5 commits intomainfrom
staging

Conversation

@bmdavis419
Copy link
Collaborator

@bmdavis419 bmdavis419 commented Dec 20, 2025

Greptile Summary

migrated AI functionality from Vercel AI SDK to BAML for better prompt management and type safety. the migration consolidates prompt definitions into .baml files with built-in testing, replacing inline TypeScript prompts.

key changes:

  • replaced generateObject with BAML function calls (b.ClassifyComment, b.GetSponsor)
  • moved prompts from TypeScript strings to BAML configuration files
  • reduced retry attempts from 3 to 2
  • added comprehensive BAML test cases for sponsor detection

issues found:

  • ClassifyComment prompt removed "packaging mistake" criteria (typo in title/description/thumbnail, missing links), changing what gets flagged as editing mistakes
  • getSponsor now lowercases video descriptions before processing, which wasn't done previously and could affect sponsor detection accuracy

Confidence Score: 3/5

  • This PR has logic changes that alter existing behavior in comment classification and sponsor detection.
  • Score reflects two logic-level changes that modify existing feature behavior: (1) missing "packaging mistake" criteria in comment classification will cause certain types of editing mistakes to not be detected, and (2) lowercasing video descriptions changes sponsor detection input. While the BAML migration itself is well-structured with good test coverage, these behavior changes need verification.
  • Pay close attention to packages/channel-sync/src/baml_src/comment-sentiment.baml (missing prompt criteria) and packages/channel-sync/src/ai/index.ts (description lowercasing)

Important Files Changed

Filename Overview
packages/channel-sync/src/ai/index.ts Migrated from AI SDK to BAML for LLM calls. Simplified code by removing schema definitions. Changed retry count from 3 to 2. Return type changed from result.object to result, but BAML should maintain the same interface.
packages/channel-sync/src/baml_src/comment-sentiment.baml Defines ClassifyComment function with BAML. The prompt has been modified and is missing the "packaging mistake" criteria from the original prompt, which could affect editing mistake detection behavior.
packages/channel-sync/src/baml_src/video-sponsor.baml Defines GetSponsor function with BAML. Includes comprehensive test cases for different sponsor scenarios. Prompt appears functionally equivalent to the original implementation.

bmdavis419 and others added 5 commits December 19, 2025 23:39
<!-- greptile_comment -->

<h3>Greptile Summary</h3>


Migrated AI prompt management from the AI SDK to BAML for both comment classification and sponsor extraction. The migration maintains backward compatibility with existing code - all field names (`isPositiveComment`, `sponsorName`, `sponsorKey`) match what the rest of the codebase expects.

**Key changes:**
- Replaced manual `generateObject` calls with BAML functions `ClassifyComment` and `GetSponsor`
- Moved OpenRouter client configuration from TypeScript to BAML config file
- Added postinstall hook to auto-generate BAML client code
- Included comprehensive test cases in BAML schemas
- Unused AI SDK dependencies (`@ai-sdk/groq`, `@openrouter/ai-sdk-provider`, `ai`) remain in `package.json` but are no longer imported

**Note:** The previous review comment about field name mismatch is no longer valid - the BAML schema correctly defines `isPositiveComment`, not `isPositive`.

<h3>Confidence Score: 4/5</h3>


- Safe to merge - migration maintains backward compatibility with existing code
- The migration is well-executed with matching field names and proper configuration. Score reflects one minor concern: lowercasing video description in `index.ts:38` may affect sponsor detection accuracy if URLs or patterns are case-sensitive (already flagged in previous thread)
- Pay attention to `packages/channel-sync/src/ai/index.ts` due to the `.toLocaleLowerCase()` transformation that could affect sponsor detection

<h3>Important Files Changed</h3>




| Filename | Overview |
|----------|----------|
| packages/channel-sync/src/ai/index.ts | Migrated from AI SDK to BAML, simplified code by removing manual prompt construction and schema definitions |
| packages/channel-sync/src/baml_src/comment-sentiment.baml | New BAML schema for comment classification with proper field names matching existing code |
| packages/channel-sync/src/baml_src/video-sponsor.baml | New BAML schema for sponsor extraction with lowercase requirement in prompt and comprehensive test cases |
| packages/channel-sync/package.json | Added BAML dependency and postinstall hook to auto-generate client code |

</details>



<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->
@bmdavis419 bmdavis419 merged commit b0c0084 into main Dec 20, 2025
1 of 3 checks passed
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

function ClassifyComment(comment: string, videoSponsor: string | null) -> CommentSentiment {
client OpenrouterGptOssClient
prompt #"
Read this comment decide if it mentions an editing mistake (something wrong with the video's audio, video, title, thumbnail, or description), the video's sponsor, and/or is a question.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: prompt missing "packaging mistake" criteria from original implementation. original prompt checked for "typo in title/description/thumbnail, missing link in description, etc." under editing mistakes. this changes what gets flagged as editing mistakes.

Suggested change
Read this comment decide if it mentions an editing mistake (something wrong with the video's audio, video, title, thumbnail, or description), the video's sponsor, and/or is a question.
Read this comment decide if it mentions an editing mistake (something wrong with the video's audio, video, title, thumbnail, or description) or a packaging mistake (typo in title/description/thumbnail, missing link in description, etc.), the video's sponsor, and/or is a question.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/channel-sync/src/baml_src/comment-sentiment.baml
Line: 11:11

Comment:
**logic:** prompt missing "packaging mistake" criteria from original implementation. original prompt checked for "typo in title/description/thumbnail, missing link in description, etc." under editing mistakes. this changes what gets flagged as editing mistakes.

```suggestion
        Read this comment decide if it mentions an editing mistake (something wrong with the video's audio, video, title, thumbnail, or description) or a packaging mistake (typo in title/description/thumbnail, missing link in description, etc.), the video's sponsor, and/or is a question.
```

How can I resolve this? If you propose a fix, please make it concise.

import { b } from '../baml_client';

const retrySchedule = Schedule.intersect(Schedule.spaced('1 minute'), Schedule.recurs(3));
const retrySchedule = Schedule.intersect(Schedule.spaced('1 minute'), Schedule.recurs(2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: retry count reduced from 3 to 2. could increase failure rate for transient API issues.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/channel-sync/src/ai/index.ts
Line: 5:5

Comment:
**style:** retry count reduced from 3 to 2. could increase failure rate for transient API issues.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

`,
schema: sponsorOutputSchema
}),
try: () => b.GetSponsor(data.sponsorPrompt, data.videoDescription.toLocaleLowerCase()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: toLocaleLowerCase() added to video description. original implementation didn't lowercase the description. this changes the input to the LLM and could affect sponsor detection accuracy, especially for sponsors with specific capitalization in descriptions. was this lowercasing intentional to improve sponsor matching, or unintended change?

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/channel-sync/src/ai/index.ts
Line: 38:38

Comment:
**logic:** `toLocaleLowerCase()` added to video description. original implementation didn't lowercase the description. this changes the input to the LLM and could affect sponsor detection accuracy, especially for sponsors with specific capitalization in descriptions. was this lowercasing intentional to improve sponsor matching, or unintended change?

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant