Skip to content

#332 pydantic schema validation #341

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

Merged
merged 3 commits into from
Jun 5, 2024
Merged

Conversation

PeriniM
Copy link
Contributor

@PeriniM PeriniM commented Jun 4, 2024

Added Pydantic Schema

You can specify a schema based on pydantic like the following:

class Project(BaseModel):
    title: str = Field(description="The title of the project")
    description: str = Field(description="The description of the project")

class Projects(BaseModel):
    projects: List[Project]

and use it inside the graph object:

smart_scraper_graph = SmartScraperGraph(
    prompt=...,
    source=...,
    schema=Projects,
    config=graph_config
)

Added append_node method

You can now append a new node to an existing graph like:

new_parse_node = ParseNode(
    input="doc",
    output=["parsed_doc"],
    node_config={
        "chunk_size": 4096,
        "verbose": True,
    },
    node_name="new_parse_node",

)

smart_scraper_graph = SmartScraperGraph(
    prompt=...,
    source=...,
    config=graph_config,
)

smart_scraper_graph.append_node(new_parse_node)

be sure to have a unique name to the new node to avoid conflicts

@PeriniM PeriniM requested a review from VinciGit00 June 4, 2024 21:42
Copy link
Collaborator

@VinciGit00 VinciGit00 left a comment

Choose a reason for hiding this comment

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

LG TM

@VinciGit00 VinciGit00 merged commit a7443a7 into pre/beta Jun 5, 2024
1 check passed
@VinciGit00 VinciGit00 deleted the 332-pydantic-schema-validation branch June 5, 2024 07:05
Copy link

github-actions bot commented Jun 5, 2024

🎉 This PR is included in version 1.6.0-beta.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Jun 9, 2024

🎉 This PR is included in version 1.7.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants