a
    dg	                     @   s   d dl mZmZmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ edgd	d
Zdeeeef ee f ee
ee	 eedddZdS )    )AnyDictOptionalTypeUnion)create_structured_output_chain)BaseLLMOutputParserBasePromptTemplate)
ChatOpenAI)PromptTemplate)	BaseModel)SyntheticDataGeneratorZexamplez	{example})Zinput_variablestemplateN)output_schemallmpromptoutput_parserkwargsreturnc                 K   s(   t | ||fd|i|}t||d}|S )af  
    Create an instance of SyntheticDataGenerator tailored for OpenAI models.

    This function creates an LLM chain designed for structured output based on the
    provided schema, language model, and prompt template. The resulting chain is then
    used to instantiate and return a SyntheticDataGenerator.

    Args:
        output_schema (Union[Dict[str, Any], Type[BaseModel]]): Schema for expected
        output. This can be either a dictionary representing a valid JsonSchema or a
        Pydantic BaseModel class.


        llm (ChatOpenAI): OpenAI language model to use.

        prompt (BasePromptTemplate): Template to be used for generating prompts.


        output_parser (Optional[BaseLLMOutputParser], optional): Parser for
        processing model outputs. If none is provided, a default will be inferred
        from the function types.


        kwargs: Additional keyword arguments to be passed to
        `create_structured_output_chain`.


    Returns: SyntheticDataGenerator: An instance of the data generator set up with
    the constructed chain.

    Usage:
        To generate synthetic data with a structured output, first define your desired
        output schema. Then, use this function to create a SyntheticDataGenerator
        instance. After obtaining the generator, you can utilize its methods to produce
        the desired synthetic data.
    r   )r   Z	llm_chain)r   r   )r   r   r   r   r   chain	generator r   /var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_experimental/tabular_synthetic_data/openai.pycreate_openai_data_generator   s    ,r   )N)typingr   r   r   r   r   Z!langchain.chains.openai_functionsr   Zlangchain.schemar   r	   Zlangchain_community.chat_modelsr
   Zlangchain_core.promptsr   Zpydanticr   Z2langchain_experimental.tabular_synthetic_data.baser   ZOPENAI_TEMPLATEstrr   r   r   r   r   <module>   s     