Program
9
Aim:
Take
the Institution name as input. Use Pydantic to define the schema for the
desired output and create a custom output parser. Invoke the Chain and Fetch
Results. Extract the below Institution related details from Wikipedia: The
founder of the Institution. When it was founded. The current branches in the
institution . How many employees are working in it. A brief 4-line summary of
the institution.
Theory:
This
program extracts structured information about an institution using a Pydantic
schema and a custom output parser.First, Pydantic is used to define the required
output format, including fields such as founder, year of establishment,
branches, number of employees, and a brief summary. This ensures the data is
organized and validated.Next, a custom output parser is created to convert raw
data (retrieved or simulated from Wikipedia) into the defined structured
format.A chain-like process is then implemented in which the institution name
is taken as input, relevant details are fetched, and the parser processes the
data step by step.Finally, the output is generated in a clean, structured form,
making it easy to understand and use.
Step
1: Import Pydantic library to create structured data models.
Step
2: Define a Pydantic schema to specify the required institution details.
Step
3: Create a custom parser to convert raw data into a structured format.
Step
4: Simulate fetching institution data (like from Wikipedia).
Step
5: Build a chain function to process and parse the data step by step.
Step
6: Provide the institution name as input and invoke the chain.
Step
7: Display the final structured output.
0 Comments