Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anthropic Sonnet has trouble with dict result type #385

Open
jlowin opened this issue Nov 14, 2024 · 1 comment
Open

Anthropic Sonnet has trouble with dict result type #385

jlowin opened this issue Nov 14, 2024 · 1 comment
Labels
bug Something isn't working question Further information is requested

Comments

@jlowin
Copy link
Member

jlowin commented Nov 14, 2024

Description

Reported in Slack - Sonnet repeatedly stumbles with return_type=dict. https://prefect-community.slack.com/archives/C079VLLH5D3/p1731491267965619

Example 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
        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")

Version Information

ControlFlow version: 0.11.3.dev19+g0b0c9fb
       Prefect version: 3.1.0
LangChain Core version: 0.3.15
        Python version: 3.12.2
              Platform: macOS-15.1-arm64-arm-64bit
                  Path: /Users/jlowin/Developer/controlflow

Additional Context

No response

@jlowin jlowin added the bug Something isn't working label Nov 14, 2024
@github-actions github-actions bot added the question Further information is requested label Nov 14, 2024
@teocns
Copy link
Contributor

teocns commented Nov 24, 2024

Does merged PR #387 close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants