llama_index [好的第一期]:修复VectorIndexAutoRetriever默认的"prompt_template_str",

1mrurvl1  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(54)

错误描述

当使用VectorIndexAutoRetriever时,如果没有向构造函数提供prompt_template_str参数,将使用以下默认模板:
llama_index.core.indices.vector_store.retrievers.auto_retriever.prompts import DEFAULT_VECTOR_STORE_QUERY_PROMPT_TMPL
此模板有一个语法错误和一个可以进行的微小更改,以便更好地可视化提示。

版本

0.10.49

重现步骤

错误可以在这里找到:

... # More code

EXAMPLES = f"""\
<< Example 1. >>
Data Source:
```json
{example_info.json(indent=4)}

User Query:
{example_query}

Structured Request:

{example_output.json()}
# <--------- MISSING  ``` 

... # More code

此外,为了美化代码,还可以在这里进行一个微小的更改:

... # More code

<< Example 2. >>
Data Source:
```json
{example_info_2.json(indent=4)}

User Query:
{example_query_2}

Structured Request:

{example_output_2.json()}
# <---- Trailing space

... # More code


#### 相关日志/回溯

* 无响应*
7cjasjjr

7cjasjjr1#

你好!我在这里帮助你解决在等待人工维护者时遇到的任何错误、问题或贡献。
DEFAULT_VECTOR_STORE_QUERY_PROMPT_TMPL 中的语法错误确实是因为 EXAMPLES 部分的代码块缺少一个闭合的反引号。此外,第二个示例的结构化请求中有一个尾随空格。以下是修正后的代码片段:

EXAMPLES = f"""\
<< Example 1. >>
Data Source:
```json
{example_info.json(indent=4)}

用户查询:
{example_query}
结构化请求:

{example_output.json()}
```  # Added missing closing backtick

<< Example 2. >>
Data Source:
```json
{example_info_2.json(indent=4)}

用户查询:
{example_query_2}
结构化请求:

{example_output_2.json()}
```  # Removed trailing space
""".replace(
    "{", "{{"
).replace(
    "}", "}}"
)

这应该解决了语法错误,并提高了提示模板 1(https://github.com/run-llama/llama_index/blob/main/llama-index-core/llama_index/core/indices/vector_store/retrievers/auto_retriever/prompts.py)2(https://github.com/run-llama/llama_index/blob/main/llama-index-legacy/llama_index/legacy/indices/vector_store/retrievers/auto_retriever/prompts.py) 的可读性。

  • 要继续与 Dosu 对话,请提及 @dosu。*
dsf9zpds

dsf9zpds2#

感谢@dosu,我将打开一个PR。

jjjwad0x

jjjwad0x3#

太好了!如果您在处理PR时需要进一步的帮助,请随时提问。祝您编码愉快!

  • 要继续与Dosu交谈,请提及@dosu。*

相关问题