Fix minor issues in self-query retriever prompt formatting (#4450)

# Fix minor issues in self-query retriever prompt formatting

I noticed a few minor issues with the self-query retriever's prompt
while using it, so here's PR to fix them 😇

## Who can review?

Community members can review the PR once tests pass. Tag
maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

        @hwchase17 - project lead

        Tracing / Callbacks
        - @agola11

        Async
        - @agola11

        DataLoader Abstractions
        - @eyurtsev

        LLM/Chat Wrappers
        - @hwchase17
        - @agola11

        Tools / Toolkits
        - @vowelparrot
 -->
parallel_dir_loader
Nick Omeyer 1 year ago committed by GitHub
parent d969f43ed8
commit f46710d408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -61,7 +61,7 @@ def _format_attribute_info(info: Sequence[AttributeInfo]) -> str:
for i in info: for i in info:
i_dict = dict(i) i_dict = dict(i)
info_dicts[i_dict.pop("name")] = i_dict info_dicts[i_dict.pop("name")] = i_dict
return json.dumps(info_dicts, indent=2).replace("{", "{{").replace("}", "}}") return json.dumps(info_dicts, indent=4).replace("{", "{{").replace("}", "}}")
def _get_prompt( def _get_prompt(

@ -4,8 +4,8 @@ from langchain import PromptTemplate
SONG_DATA_SOURCE = """\ SONG_DATA_SOURCE = """\
```json ```json
{ {
content: "Lyrics of a song", "content": "Lyrics of a song",
attributes: { "attributes": {
"artist": { "artist": {
"type": "string", "type": "string",
"description": "Name of the song artist" "description": "Name of the song artist"
@ -33,7 +33,9 @@ FULL_ANSWER = """\
"query": "teenager love", "query": "teenager love",
"filter": "and(or(eq(\\"artist\\", \\"Taylor Swift\\"), eq(\\"artist\\", \\"Katy Perry\\")), \ "filter": "and(or(eq(\\"artist\\", \\"Taylor Swift\\"), eq(\\"artist\\", \\"Katy Perry\\")), \
lt(\\"length\\", 180), eq(\\"genre\\", \\"pop\\"))" lt(\\"length\\", 180), eq(\\"genre\\", \\"pop\\"))"
}}""" }}
```\
"""
NO_FILTER_ANSWER = """\ NO_FILTER_ANSWER = """\
```json ```json
@ -103,7 +105,7 @@ A comparison statement takes the form: `comp(attr, val)`:
A logical operation statement takes the form `op(statement1, statement2, ...)`: A logical operation statement takes the form `op(statement1, statement2, ...)`:
- `op` ({allowed_operators}): logical operator - `op` ({allowed_operators}): logical operator
- `statement1`, `statement2`, ... (comparison statements or logical operation \ - `statement1`, `statement2`, ... (comparison statements or logical operation \
statements): one or more statements to appy the operation to statements): one or more statements to apply the operation to
Make sure that you only use the comparators and logical operators listed above and \ Make sure that you only use the comparators and logical operators listed above and \
no others. no others.
@ -125,8 +127,8 @@ DEFAULT_SUFFIX = """\
Data Source: Data Source:
```json ```json
{{{{ {{{{
content: {content}, "content": "{content}",
attributes: {attributes} "attributes": {attributes}
}}}} }}}}
``` ```

Loading…
Cancel
Save