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

add prompt hava json test code #14311

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add prompt hava json test code #14311

wants to merge 2 commits into from

Conversation

danerlt
Copy link

@danerlt danerlt commented Jun 22, 2024

Description

add prompt hava json test code

Fixes # (issue)

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • [ x] No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • [x ] No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [x ] Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • [ x] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 22, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 23, 2024
@logan-markewich logan-markewich enabled auto-merge (squash) June 23, 2024 19:58
@logan-markewich
Copy link
Collaborator

Looks like the test doesn't pass?

@danerlt
Copy link
Author

danerlt commented Jun 24, 2024

@logan-markewich Yes, the test code I've written is specifically for Issue 14310. Once this issue is resolved, the tests should pass successfully.

@logan-markewich
Copy link
Collaborator

So, we should fix the issue then before merging this PR, otherwise cicd will always fail 😅

@danerlt
Copy link
Author

danerlt commented Jul 2, 2024

@logan-markewich You can merge the PR after resolving this issue.

@tibor-reiss
Copy link
Contributor

Hi @danerlt , @logan-markewich, this issue is not llama-index specific. From std python, this already fails with KeyError:
prompt_txt = 'hello {text} {foo} \noutput format:\n```json\n{"name": "llamaindex"}\n```' prompt_txt.format(**{'text': 'world', 'foo': 'bar'})

And even this: prompt_txt.format(**{'text': 'world', 'foo': 'bar', '"name"': 'something'})
Error is: ValueError: Invalid format specifier ' "llamaindex"' for object of type 'str'

That's how the string-formatting works :)

Solution is to double up the braces: prompt_txt = 'hello {text} {foo} \noutput format:\n```json\n{{"name": "llamaindex"}}\n```'
Docs: https://docs.python.org/3/library/string.html#formatstrings

@danerlt
Copy link
Author

danerlt commented Jul 4, 2024

@tibor-reiss Thank you for your response. I understand that this issue pertains to the standard library, but I prefer not to alter the JSON format with double braces. Instead, I would like to address it using jinja2, similar to how the langchain framework handles such matters.

@logan-markewich
Copy link
Collaborator

@danerlt jinja is python only though.

Tbh there are plans to unify prompts between python and typescript packages, possibly using something like liquid.

Then, if we also centralize prompts to some central registry, it will be much easier to work with

Being honest though, this work is probably 2 months away though (many other higher priority items right now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants