Skip to content

unwrap pyodide object correctly #8466

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

arnavsinghvi11
Copy link
Collaborator

@arnavsinghvi11 arnavsinghvi11 commented Jun 26, 2025

Fix for #8448

pyodide wraps generated python code in a Pyproxy object that cant be JSON-encoded so .toJS() properly converts python to js object which can. resolves failing cases mentioned in #8448

[[ ## final_generated_code ## ]]
def final_answer():
    result = 2 * 5 + 4
    return {"answer": result}

final_answer()

[[ ## code_output ## ]]
# Previously incorrect - {}
# Now correctly outputs - {"answer": 14}
echo '{"code": "{\\"answer\\": 14}"}' \
  | deno run --allow-read dspy/primitives/runner.js

# Previously incorrect - {"output":{}}
# Now correctly outputs - {"output":{"answer":14}}

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants