file:# import dotenv# dotenv.load_dotenv()from langchain.prompts import FewShotPromptTemplate, PromptTemplatefrom langchain.chat_models import ChatOpenAIfrom langchain.pydantic_v1 import BaseModelfrom langchain_experimental.tabular_synthetic_data.base import SyntheticDataGeneratorfrom langchain_experimental.tabular_synthetic_data.openai import create_openai_data_generator, OPENAI_TEMPLATEfrom langchain_experimental.tabular_synthetic_data.prompts import SYNTHETIC_FEW_SHOT_SUFFIX, SYNTHETIC_FEW_SHOT_PREFIX1. Define Your Data Model‚ÄãEvery dataset has a structure or a "schema". The MedicalBilling class below serves as our schema for the synthetic data. By defining this, we're informing our synthetic data generator about the shape and nature of data we expect.class MedicalBilling(BaseModel):    patient_id: int    patient_name: str    diagnosis_code: str    procedure_code: str    total_charge: float    insurance_claim_amount: floatFor instance, every record will have a patient_id that's an integer, a patient_name that's a string, and so on.2. Sample Data‚ÄãTo guide the synthetic data generator, it's useful to provide it with a few real-world-like examples. These examples serve as a "seed" - they're representative of the kind of data you want, and the generator will use them to create more data that looks similar.Here are some fictional medical billing records:examples = [    {"example": """Patient ID: 123456, Patient Name: John Doe, Diagnosis Code:         J20.9, Procedure Code: 99203, Total Charge: $500, Insurance Claim Amount: $350"""},    {"example": """Patient ID: 789012, Patient Name: Johnson Smith, Diagnosis         Code: M54.5, Procedure Code: 99213, Total Charge: $150, Insurance Claim Amount: $120"""},    {"example": """Patient ID: 345678, Patient Name: Emily Stone, Diagnosis Code:         E11.9, Procedure Code: 99214, Total Charge: $300, Insurance Claim Amount: $250"""},]3. Craft a Prompt Template‚ÄãThe generator doesn't magically know how to create our data;
Open In Colab
Open In Colab ->: file:# import dotenv# dotenv.load_dotenv()from langchain.prompts import FewShotPromptTemplate, PromptTemplatefrom langchain.chat_models import ChatOpenAIfrom langchain.pydantic_v1 import BaseModelfrom langchain_experimental.tabular_synthetic_data.base import SyntheticDataGeneratorfrom langchain_experimental.tabular_synthetic_data.openai import create_openai_data_generator, OPENAI_TEMPLATEfrom langchain_experimental.tabular_synthetic_data.prompts import SYNTHETIC_FEW_SHOT_SUFFIX, SYNTHETIC_FEW_SHOT_PREFIX1. Define Your Data Model‚ÄãEvery dataset has a structure or a "schema". The MedicalBilling class below serves as our schema for the synthetic data. By defining this, we're informing our synthetic data generator about the shape and nature of data we expect.class MedicalBilling(BaseModel):    patient_id: int    patient_name: str    diagnosis_code: str    procedure_code: str    total_charge: float    insurance_claim_amount: floatFor instance, every record will have a patient_id that's an integer, a patient_name that's a string, and so on.2. Sample Data‚ÄãTo guide the synthetic data generator, it's useful to provide it with a few real-world-like examples. These examples serve as a "seed" - they're representative of the kind of data you want, and the generator will use them to create more data that looks similar.Here are some fictional medical billing records:examples = [    {"example": """Patient ID: 123456, Patient Name: John Doe, Diagnosis Code:         J20.9, Procedure Code: 99203, Total Charge: $500, Insurance Claim Amount: $350"""},    {"example": """Patient ID: 789012, Patient Name: Johnson Smith, Diagnosis         Code: M54.5, Procedure Code: 99213, Total Charge: $150, Insurance Claim Amount: $120"""},    {"example": """Patient ID: 345678, Patient Name: Emily Stone, Diagnosis Code:         E11.9, Procedure Code: 99214, Total Charge: $300, Insurance Claim Amount: $250"""},]3. Craft a Prompt Template‚ÄãThe generator doesn't magically know how to create our data;