gpt4 book ai didi

python - 为 Haystack 模板指定备用路径

转载 作者:太空狗 更新时间:2023-10-30 00:49:25 24 4
gpt4 key购买 nike

The Haystack documentation states that :

Additionally, we’re providing use_template=True on the text field. This allows us to use a data template (rather than error-prone concatenation) to build the document the search engine will index. You’ll need to create a new template inside your template directory called search/indexes/myapp/note_text.txt

不幸的是,没有关于如果您想要一个不同名称的模板该怎么做的信息。

是否可以指定 haystack 文档模板的路径?

最佳答案

该死,我已经找了一个星期了。

Its listed under the SearchField API documentation ,它是搜索索引中实际字段的父类(super class)。

SearchField.template_name

Allows you to override the name of the template to use when preparing data. By default, the data templates for fields are located within your TEMPLATE_DIRS under a path like search/indexes/{app_label}/{model_name}_{field_name}.txt. This option lets you override that path (though still within TEMPLATE_DIRS).

Example:

bio = CharField(use_template=True, template_name='myapp/data/bio.txt')

You can also provide a list of templates, as loader.select_template is used under the hood.

Example:

bio = CharField(use_template=True, template_name=['myapp/data/bio.txt', 'myapp/bio.txt', 'bio.txt'])

关于python - 为 Haystack 模板指定备用路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29888563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com