Skip to content

AttributeError: 'dict' object has no attribute 'model_json_schema' #89

@jakubLangr

Description

@jakubLangr

When running

class MachineUtilizationModel(ZepModel):
    action_txt: str = Field(default=None, description="Action text")
    action: bool = Field(default=False, description="Action flag")
    response: dict = Field(default=None, description="Response text")

    class Config:
        arbitrary_types_allowed = True

def sanitize_json_string(json_string):
    client = Zep()
    session_id = str(uuid.uuid4())

    print(f"Sanitizing JSON string: {json_string} in zep session: {session_id}")
    # Define the model schema
    model_schema = MachineUtilizationModel.schema()
    extracted_data = client.memory.extract(
        session_id=session_id,
        model=model_schema,
        last_n=1,  # Assuming the JSON string is the last message
        validate=True,  # Enable validation for better accuracy
        current_date_time='2024-07-02T07:46:49Z'  # Current date and time in ISO 8601 format
    )
    import ipdb; ipdb.set_trace()
    return extracted_data

I get

    extracted_data = client.memory.extract(
  File "/Users/jlangr/anaconda3/anaconda3/envs/b310/lib/python3.10/site-packages/zep_cloud/external_clients/memory.py", line 68, in extract
    model_schema = json.dumps(model.model_json_schema())
AttributeError: 'dict' object has no attribute 'model_json_schema'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions