dllmforge.IE_agent_schema_generator¶
Schema Generator module for automatically generating Pydantic models based on user descriptions and example documents using LLM.
Classes
|
Parse Python code from LLM responses that may contain markdown. |
|
Class for generating Pydantic schemas using LLM |
- class dllmforge.IE_agent_schema_generator.PythonCodeOutputParser(*args: Any, name: str | None = None)[source]¶
Parse Python code from LLM responses that may contain markdown.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'protected_namespaces': ()}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class dllmforge.IE_agent_schema_generator.SchemaGenerator(config: SchemaConfig | None = None, llm_api: LangchainAPI | None = None, task_description: str | None = None, example_doc: str | None = None, user_schema_path: Path | None = None, output_path: str | Path | None = None)[source]¶
Class for generating Pydantic schemas using LLM
This class supports two usage modes:
CONFIG MODE: Pass a SchemaConfig object ```python config = SchemaConfig(
task_description=”Extract person info”, output_path=”schema.py”
DIRECT MODE: Pass arguments directly (no config object) ```python generator = SchemaGenerator(
task_description=”Extract person info”, output_path=”schema.py”
Both modes support all parameters: - task_description (REQUIRED in direct mode) - example_doc (optional: text or file path) - user_schema_path (optional: load existing schema) - output_path (optional: where to save generated schema) - llm_api (optional: custom LLM configuration)
Initialize the schema generator.
You can use either config (SchemaConfig), or pass the individual parameters directly.
- Parameters:
config – Schema generation configuration (if provided, individual params are ignored)
llm_api – Optional pre-configured LangchainAPI instance
task_description – Description of the information extraction task (direct mode)
example_doc – Example document to help with schema generation (direct mode)
user_schema_path – Path to user-provided schema Python file (direct mode)
output_path – Path to save generated schema (direct mode)
- __init__(config: SchemaConfig | None = None, llm_api: LangchainAPI | None = None, task_description: str | None = None, example_doc: str | None = None, user_schema_path: Path | None = None, output_path: str | Path | None = None)[source]¶
Initialize the schema generator.
You can use either config (SchemaConfig), or pass the individual parameters directly.
- Parameters:
config – Schema generation configuration (if provided, individual params are ignored)
llm_api – Optional pre-configured LangchainAPI instance
task_description – Description of the information extraction task (direct mode)
example_doc – Example document to help with schema generation (direct mode)
user_schema_path – Path to user-provided schema Python file (direct mode)
output_path – Path to save generated schema (direct mode)
- create_schema_generation_prompt() ChatPromptTemplate[source]¶
Create prompt template for generating Pydantic schema