`@cf.flow` `def gen_mock_data(goal: str):` `ag...
# marvin-ai
x
@cf.flow
def gen_mock_data(goal: str):
agent_data = cf.Agent(
name = "Website data structure generator",
instructions = """You are a data structure expert. Your task is to generate realistic mock data for a website. You can directly return final result data in tool call without any other comments.""",
# model = openai_model,
model = model, # anthropic sonnect 3.5
)
mock_data_task = cf.Task(
objective=f"""
Please follow these guidelines:
1. Include all necessary fields and relationships between data entities
2. Generate a reasonable amount of sample data (10-20 items per category)
3. Maintain data consistency across related entities
4. Use realistic values for:
- Names, titles, descriptions
- Dates and timestamps
- IDs and reference keys
- Numeric values and statistics
5. Follow these data quality rules:
- No null values unless explicitly requested
- Proper data types for each field
- Consistent formatting for dates and special fields
- Realistic data ranges and distributions
Generate mock data for the goal: {goal}""",
result_type=dict,
#  completion_tools=[],
agents=[agent_data],
)
json_data = mock_data_task.run(
max_agent_turns=3,
max_llm_calls=3,
)
print("Mock data:", json_data)
gen_mock_data("Generate a blog site mock data")
j
@xin li that is unexpected and I get it too - I will take a look
At some point this afternoon this suddenly started working correctly for me - nonetheless I've PR'd the changes I made because I think they are helpful. However I think this is a change on the Anthropic side to handle
object
(dict) responses better, not something in CF. Will continue to monitor. Here's the test script I used (on main):
Copy code
import controlflow as cf


@cf.flow
def gen_mock_data(goal: str):
    agent_data = cf.Agent(
        name="Website data structure generator",
        instructions="""You are a data structure expert. Your task is to generate realistic mock data for a website. You can directly return final result data in tool call without any other comments.""",
        model="anthropic/claude-3-5-sonnet-20240620",
    )
    mock_data_task = cf.Task(
        objective=f"""
        Please follow these guidelines:
    1. Include all necessary fields and relationships between data entities
    2. Generate a reasonable amount of sample data (10-20 items per category)
    3. Maintain data consistency across related entities
    4. Use realistic values for:
    - Names, titles, descriptions
    - Dates and timestamps
    - IDs and reference keys
    - Numeric values and statistics
    5. Follow these data quality rules:
    - No null values unless explicitly requested
    - Proper data types for each field
    - Consistent formatting for dates and special fields
    - Realistic data ranges and distributions
    
    6. In the interest of efficiency, don't exceed 1000 characters.
    
        Generate mock data for the goal: {goal}""",
        result_type=dict,
        #  completion_tools=[],
        agents=[agent_data],
    )
    json_data = mock_data_task.run(
        max_agent_turns=3,
        max_llm_calls=3,
    )
    print("Mock data:", json_data)


gen_mock_data("Generate a blog site mock data")