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

fix: keyterms to keyterm #281

Merged
merged 1 commit into from
Feb 13, 2025
Merged

fix: keyterms to keyterm #281

merged 1 commit into from
Feb 13, 2025

Conversation

naomi-lgbt
Copy link
Contributor

@naomi-lgbt naomi-lgbt commented Feb 13, 2025

Proposed changes

Types of changes

What types of changes does your code introduce to the community Go SDK?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have lint'ed all of my code using repo standards
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Summary by CodeRabbit

  • Refactor
    • Standardized transcription configuration by shifting from multiple key terms to a singular key term input across various services, ensuring consistent behavior and simplified setup for transcription workflows.

@naomi-lgbt naomi-lgbt marked this pull request as ready for review February 13, 2025 18:35
Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

The changes across the codebase update the configuration and API options for transcription by renaming the field from Keyterms to Keyterm. This modification spans multiple example files (both REST and WebSocket) and client packages, affecting both prerecorded and live transcription options. The control flow remains unchanged aside from updating conditional checks that reference the renamed field.

Changes

File(s) Change Summary
examples/agent/websocket/simple/main.go Updated the agent's listening configuration: renamed Keyterms to Keyterm.
examples/speech-to-text/rest/.../main.go (callback, file, intent, sentiment, stream, summary, topic, url) Modified the PreRecordedTranscriptionOptions struct by renaming the Keyterms field to Keyterm in all REST examples.
examples/speech-to-text/websocket/.../main.go (http_callback, http_channel, microphone_callback, microphone_channel, replay) Renamed the Keyterms field to Keyterm in the LiveTranscriptionOptions or similar configurations in WebSocket examples.
pkg/client/agent/v1/websocket/new_using_chan.go
pkg/client/interfaces/v1/types-agent.go
Adjusted agent listening options by renaming Keyterms to Keyterm and updating related conditional checks.
pkg/client/interfaces/v1/types-prerecorded.go
pkg/client/interfaces/v1/types-stream.go
Updated transcription option structs by replacing Keyterms with Keyterm and adjusting JSON/schema tags.
pkg/client/listen/v1/rest/client.go
pkg/client/listen/v1/websocket/new_using_callbacks.go
pkg/client/listen/v1/websocket/new_using_chan.go
Changed usage in client methods, updating conditionals and parameters from Keyterms to Keyterm for consistency.

Possibly related PRs

Suggested reviewers

  • jpvajda
  • SandraRodgers
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
examples/speech-to-text/rest/topic/main.go (1)

36-36: Consider updating documentation to clarify usage.

The consistent renaming from Keyterms to Keyterm across all examples while maintaining the []string type suggests a potential change in the API's intended usage. Consider:

  1. Adding a comment in the examples clarifying whether multiple terms are still supported
  2. Updating the API documentation to reflect this change
examples/speech-to-text/rest/file/main.go (1)

1-1: Verify migration strategy for breaking changes.

The rename from Keyterms to Keyterm is consistently applied across all files. However, as this is a breaking change affecting both the Go API and JSON payload structure, please ensure:

  1. The major version is bumped (e.g., from v1.x.x to v2.0.0) following semver
  2. A migration guide is provided for users
  3. The changelog clearly documents this breaking change
  4. Consider providing a temporary backward compatibility layer if feasible
pkg/client/interfaces/v1/types-stream.go (1)

28-28: Breaking Change: Field renamed from Keyterms to Keyterm.

This change modifies a public API field name which could break existing client code. Consider:

  1. Adding a deprecation notice for the old field name
  2. Supporting both field names temporarily for backward compatibility
  3. Documenting this change in the changelog
pkg/client/listen/v1/websocket/new_using_chan.go (1)

73-76: Update error message to match new field name.

The error message uses plural "Keyterms" while the field name is singular "Keyterm". Consider updating for consistency:

-		klog.V(1).Info("Keyterms are only supported with nova-3 models.")
+		klog.V(1).Info("Keyterm is only supported with nova-3 models.")
pkg/client/agent/v1/websocket/new_using_chan.go (1)

73-76: Update error message to match new field name.

The error message uses plural "Keyterms" while the field name is singular "Keyterm". Consider updating for consistency:

-		klog.V(1).Info("Keyterms are only supported with nova-3 models.")
+		klog.V(1).Info("Keyterm is only supported with nova-3 models.")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d2dcd2 and be6bbcf.

📒 Files selected for processing (21)
  • examples/agent/websocket/simple/main.go (1 hunks)
  • examples/speech-to-text/rest/callback/callback/main.go (1 hunks)
  • examples/speech-to-text/rest/file/main.go (1 hunks)
  • examples/speech-to-text/rest/intent/main.go (1 hunks)
  • examples/speech-to-text/rest/sentiment/main.go (1 hunks)
  • examples/speech-to-text/rest/stream/main.go (1 hunks)
  • examples/speech-to-text/rest/summary/main.go (1 hunks)
  • examples/speech-to-text/rest/topic/main.go (1 hunks)
  • examples/speech-to-text/rest/url/main.go (1 hunks)
  • examples/speech-to-text/websocket/http_callback/main.go (1 hunks)
  • examples/speech-to-text/websocket/http_channel/main.go (1 hunks)
  • examples/speech-to-text/websocket/microphone_callback/main.go (1 hunks)
  • examples/speech-to-text/websocket/microphone_channel/main.go (1 hunks)
  • examples/speech-to-text/websocket/replay/main.go (1 hunks)
  • pkg/client/agent/v1/websocket/new_using_chan.go (1 hunks)
  • pkg/client/interfaces/v1/types-agent.go (1 hunks)
  • pkg/client/interfaces/v1/types-prerecorded.go (1 hunks)
  • pkg/client/interfaces/v1/types-stream.go (1 hunks)
  • pkg/client/listen/v1/rest/client.go (2 hunks)
  • pkg/client/listen/v1/websocket/new_using_callbacks.go (1 hunks)
  • pkg/client/listen/v1/websocket/new_using_chan.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Go Tests
🔇 Additional comments (16)
examples/speech-to-text/rest/callback/callback/main.go (1)

42-42:

❓ Verification inconclusive

Verify API design intention for Keyterm field.

The field type remains []string but the name change from Keyterms to Keyterm suggests single value usage. This could be a breaking change for clients using multiple terms.


🌐 Web query:

Does the Deepgram API support multiple key terms or is it limited to a single term?

💡 Result:

The Deepgram API supports multiple key terms through both its keywords and search features. Here's how they work:


1. Using Multiple Keywords

  • Purpose: Improve transcription accuracy for specific words by directing the model to prioritize them.
  • Implementation: Pass an array of keywords in your request:
    transcript = await deepgram.prerecorded.transcribe(
      { url: "http://your_url.com" },
      { keywords: ['keyword1', 'keyword2', 'keyword3'] }
    )
    This ensures Deepgram prioritizes transcribing these terms correctly[1][10].

2. Using Multiple Search Terms

  • Purpose: Locate exact phrases or words in transcripts and retrieve their timestamps.
  • Implementation:
    • While some interfaces (like Make.com’s Deepgram module) may initially appear limited to a single search term[4], you can use URL encoding to pass multiple terms:
      &search=term1&search=term2
      
    • Example workaround using HTTP requests:
      encodeURIComponent('term1') + '&search=' + encodeURIComponent('term2')
      This generates separate queries for each term[4].

Key Differences

Feature Use Case Format
keywords Boost transcription accuracy Array of strings
search Find exact terms in transcripts URL-encoded strings

For most use cases, keywords is ideal for ensuring critical terms are transcribed correctly, while search efficiently locates specific phrases post-transcription[10]. Both support multiple entries via their respective methods[1][4][10].

Citations:


Clarify Field Naming for Multiple Key Terms

The current implementation at line 42 in examples/speech-to-text/rest/callback/callback/main.go uses an array ([]string{"deepgram"}) for the Keyterm field. Our web query confirms that the Deepgram API supports multiple key terms when supplied as an array. However, the singular name Keyterm may mislead users into thinking only a single term is allowed.

  • Action Required: Confirm if the renaming from Keyterms to Keyterm is intentional. If the intent is to support multiple keywords, consider renaming the field (e.g., to Keywords) or update the documentation and example usage to reflect that multiple entries can be provided.
examples/speech-to-text/rest/summary/main.go (1)

36-36: Implementation is consistent with other examples.

examples/speech-to-text/rest/intent/main.go (1)

36-36: Implementation is consistent with other examples.

examples/speech-to-text/rest/sentiment/main.go (1)

36-36:

❓ Verification inconclusive

LGTM! Consider updating documentation.

The change from Keyterms to Keyterm is consistent with the API terminology update. The field type remains []string, maintaining backward compatibility.

Let's check if there are any documentation files that need to be updated:


🏁 Script executed:

#!/bin/bash
# Search for any documentation files containing "keyterms"
rg -i "keyterms" --type md

Length of output: 26


LGTM – Code Change Verified, but Please Manually Verify Documentation

The change from Keyterms to Keyterm in examples/speech-to-text/rest/sentiment/main.go at line 36 is consistent with the API update, and the field’s type remains []string, so there’s no functional change. However, our automated search using rg -i "keyterms" --type md did not return any results, which might indicate that documentation updates may not be needed—but please verify manually to ensure no related documentation references have been missed.

  • Code Change: Replacement from Keyterms to Keyterm is correct.
  • Documentation: Verify if any markdown or other documentation files reference the old field name.
examples/speech-to-text/rest/url/main.go (1)

34-34: LGTM!

The change from Keyterms to Keyterm is consistent with the API terminology update while maintaining the same functionality.

examples/speech-to-text/rest/stream/main.go (1)

36-36: LGTM!

The change from Keyterms to Keyterm is consistent with the API terminology update while maintaining the same functionality.

examples/speech-to-text/websocket/http_callback/main.go (1)

36-36:

❓ Verification inconclusive

Breaking Change: Update affects both REST and WebSocket interfaces.

The change from Keyterms to Keyterm is consistent with the API terminology update. However, since this change affects both REST and WebSocket interfaces, it's important to:

  1. Document this change in the changelog
  2. Consider bumping the major version if following semantic versioning
  3. Update the migration guide for API consumers

Let's check for version and changelog files:


🏁 Script executed:

#!/bin/bash
# Search for version and changelog files
fd -i "changelog|version"

Length of output: 316


Breaking Change Alert: Update Affects Both REST and WebSocket Interfaces

The renaming of the field from Keyterms to Keyterm (while still using a string slice) is consistent with the updated API terminology. However, because this change impacts both REST and WebSocket interfaces (specifically within LiveTranscriptionOptions), please ensure the following:

  • Changelog/Migration Documentation:
    Document this breaking change. Although no explicit changelog file was located in the search output, API versioning is managed in files under pkg/api/version/. If a separate changelog is maintained elsewhere, add the appropriate entry; otherwise, consider updating the version files as needed.

  • Version Bump:
    Revisit the versioning strategy (e.g., bump the major version if you’re following semantic versioning) to clearly signal API-breaking changes.

  • Migration Guide:
    Update the migration guide to help API consumers understand the change and adjust their implementations accordingly.

examples/speech-to-text/websocket/replay/main.go (1)

33-33: Approve the change but flag as breaking.

The rename from Keyterms to Keyterm is consistent with the PR objectives. However, this is a breaking change that will require users to update their code.

Please ensure that this breaking change is:

  1. Documented in the changelog
  2. Communicated to users
  3. Released with an appropriate version bump (major version)
examples/speech-to-text/websocket/http_channel/main.go (1)

40-40: LGTM! Change is consistent.

The rename from Keyterms to Keyterm matches the changes in other files.

pkg/client/interfaces/v1/types-agent.go (1)

38-40: Approve the change but note API impact.

The rename from Keyterms to Keyterm includes updating the JSON tag from "keyterms" to "keyterm". This change affects both the Go API and the JSON payload structure.

Please ensure that:

  1. The API documentation is updated to reflect this change
  2. Any example JSON payloads in the documentation are updated
  3. Integration tests verify the new JSON structure works correctly
examples/speech-to-text/rest/file/main.go (1)

36-36: LGTM! Change is consistent.

The rename from Keyterms to Keyterm matches the changes across both WebSocket and REST implementations.

pkg/client/interfaces/v1/types-prerecorded.go (1)

34-34: LGTM! Field rename consistently applied.

The field rename from Keyterms to Keyterm is consistently applied here, maintaining the same type and tags.

examples/speech-to-text/websocket/microphone_callback/main.go (1)

129-129: LGTM! Field renamed from Keyterms to Keyterm.

The change is consistent with the PR objective and maintains the same functionality, using the nova-3 model which supports key terms.

pkg/client/listen/v1/websocket/new_using_callbacks.go (1)

73-73: LGTM! Updated model compatibility check.

The field rename maintains the same validation logic, ensuring key terms are only used with nova-3 models.

pkg/client/listen/v1/rest/client.go (1)

79-79: LGTM! Updated model compatibility checks in REST endpoints.

The field rename maintains consistent validation logic for key terms across both DoFile and DoStream methods.

Also applies to: 125-125

examples/speech-to-text/websocket/microphone_channel/main.go (1)

228-228: LGTM! Field renamed from Keyterms to Keyterm.

The change is consistent with the PR objective and maintains the same functionality, using the nova-3 model which supports key terms.

@@ -394,7 +394,7 @@ func main() {
tOptions.Agent.Think.Model = "gpt-4o-mini"
tOptions.Agent.Think.Instructions = "You are a helpful AI assistant."
tOptions.Agent.Listen.Model = "nova-3"
tOptions.Agent.Listen.Keyterms = []string{"Bueller"}
tOptions.Agent.Listen.Keyterm = []string{"Bueller"}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM! Terminology update is consistent.

The change from Keyterms to Keyterm aligns with the PR objectives and maintains the same functionality.

Let's verify this change is consistent across the SDK:


🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining instances of "Keyterms" in the codebase
# to ensure the terminology update is complete.

echo "Searching for remaining instances of 'Keyterms'..."
rg -i "keyterms" --type go

Length of output: 706


Action Needed: Inconsistent Terminology Detected

  • The change in examples/agent/websocket/simple/main.go (line 397) to use Keyterm is correctly implemented and aligns with the PR objectives.
  • However, a search of the codebase shows that several log messages still reference "Keyterms":
    • pkg/client/agent/v1/websocket/new_using_chan.go
    • pkg/client/listen/v1/websocket/new_using_chan.go
    • pkg/client/listen/v1/websocket/new_using_callbacks.go
    • pkg/client/listen/v1/rest/client.go (2 occurrences)

Please verify whether these references should also be updated to Keyterm for consistency across the SDK, or if they are intentionally retained for backward compatibility. Adjust accordingly.

@naomi-lgbt naomi-lgbt merged commit 8b673cd into main Feb 13, 2025
3 checks passed
@naomi-lgbt naomi-lgbt deleted the fix/keyterm branch February 13, 2025 18:59
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
8 tasks
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.

2 participants