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

JSON error when passing image_url #521

Open
luiz-alma opened this issue Jan 13, 2025 · 10 comments · May be fixed by #539
Open

JSON error when passing image_url #521

luiz-alma opened this issue Jan 13, 2025 · 10 comments · May be fixed by #539

Comments

@luiz-alma
Copy link

When I'm passing a formatted context to braintrust.build like so: prompt.build(context=context, query=query, image_url=image_url), I'm getting json.decoder.JSONDecodeError: Invalid control character at: line 1 column 23 (char 22). That happens whenever context has some line breaks.

I tried removing the image_url and it works. Also tried removing the context and leaving image_url, which also works. Seems like there's some issue with parsing the prompt variables.

@ankrgyl
Copy link
Contributor

ankrgyl commented Jan 13, 2025

Hi there, can you share a repro (ideally the prompt, or a similar prompt that still reproduces the issue)?

@luiz-alma
Copy link
Author

Here's the simplest version that's failing:

query_variables = {'context': '\n        ###### USER CONTEXT ######', 'query': 'is avocado ok?', 'image_url': ''}

I basically call this with:
prompt.built(context=query_variables["context"], query=query_variables["query"], image_url=query_variables["image_url"])

@ankrgyl
Copy link
Contributor

ankrgyl commented Jan 13, 2025

We need a prompt definition that reproduces it to be able to assist you further.

@luiz-alma
Copy link
Author

Does it work if I send a prompt_id and revision?

@ankrgyl
Copy link
Contributor

ankrgyl commented Jan 13, 2025

Only if you add one of us, e.g. [email protected], as a user to your account with "Engineer" privileges.

@luiz-alma
Copy link
Author

It's really simple implementation:
Screenshot 2025-01-13 at 1 24 24 PM

@luiz-alma
Copy link
Author

@ankrgyl any updates?

@ankrgyl
Copy link
Contributor

ankrgyl commented Jan 19, 2025

Hi @luiz-alma we confirmed the repro and will take a look at it sometime this week.

@ibolmo
Copy link
Contributor

ibolmo commented Jan 24, 2025

hi @luiz-alma. thank you for reporting and being patient with us!

I've got a possible fix here.

will follow-up when we get this ready for you to try

@luiz-alma
Copy link
Author

awesome! thanks for the update

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 a pull request may close this issue.

3 participants