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(google-common): Search grounding formatting #7471

Merged

Conversation

afirstenberg
Copy link
Contributor

Problem:
If using a subclass of BaseGoogleSearchOutputParser where the input doesn't have grounding info, it attempts to dereference undefined.

Solution:
Return the input text, unchanged, if there is no grounding info to annotate.

Fix and tests for same.

Copy link

vercel bot commented Jan 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jan 9, 2025 11:45am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Jan 9, 2025 11:45am

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. auto:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Jan 6, 2025
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Agh thanks. Remember to run yarn format!

@@ -198,7 +198,7 @@ export class SimpleGoogleSearchOutputParser extends BaseGoogleSearchOutputParser

protected textSuffix(_text: string, grounding: GroundingInfo): string {
let ret = "\n";
const chunks: GeminiGroundingChunk[] = grounding.metadata.groundingChunks;
const chunks: GeminiGroundingChunk[] = grounding?.metadata?.groundingChunks ??[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: run yarn format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh! Fixed

@jacoblee93
Copy link
Collaborator

Thanks!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Jan 10, 2025
@jacoblee93 jacoblee93 merged commit e6fad4a into langchain-ai:main Jan 10, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature lgtm PRs that are ready to be merged as-is size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants