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

feat(community): Provide fallback relationshipType in case it is not present in graph_transformer #7521

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hlminh2000
Copy link

@hlminh2000 hlminh2000 commented Jan 14, 2025

Although difficult to reproduce, I've ran into a few times when relationshipType was undefined and so the extraction fails.

In these cases I'd still like to have the relationship being captured in my knowledge graph, so it seems appropriate to provide the transformer with a fallback value it can use, in this case defaulted to "unknown". This also allows for the value to be overridden with something else in cases where "unknown" already means something in an existing context.

I'm happy to contribute to anything that may need to be updated to reflect this info, like documentations, just need a pointer :)

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 14, 2025
Copy link

vercel bot commented Jan 14, 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 14, 2025 1:47pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Jan 14, 2025 1:47pm

@dosubot dosubot bot added the auto:improvement Medium size change to existing code to handle new use-cases label Jan 14, 2025
@hlminh2000 hlminh2000 marked this pull request as draft January 14, 2025 13:48
@hlminh2000 hlminh2000 marked this pull request as ready for review January 14, 2025 13:48
@hlminh2000 hlminh2000 changed the title Provide fallback relationshipType in case it is not present in graph_transformer feat(community): Provide fallback relationshipType in case it is not present in graph_transformer Jan 14, 2025
@dosubot dosubot bot added auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs auto:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Jan 15, 2025
@@ -254,6 +258,7 @@ export class LLMGraphTransformer {
strictMode = true,
nodeProperties = [],
relationshipProperties = [],
fallbackRelationshipType = "unknown,
Copy link
Collaborator

@jacoblee93 jacoblee93 Jan 18, 2025

Choose a reason for hiding this comment

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

Think you're missing a quote here!

And don't forget to run yarn format

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.

Thanks for this!

CC @tomasonjo for a look as well

@tomasonjo
Copy link
Contributor

Actually, can you make the default fallback relationship type Null, so the default behavior isn't changed. When the fallback relationship is configured, then you can use it as fallback.

Also describe the new attribute in docstring please.

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 auto:improvement Medium size change to existing code to handle new use-cases auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants