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

Use custom prompt #95

Closed
ahmedriad1 opened this issue Dec 11, 2022 · 2 comments
Closed

Use custom prompt #95

ahmedriad1 opened this issue Dec 11, 2022 · 2 comments

Comments

@ahmedriad1
Copy link

I was wondering how can I use a custom prompt/template for the index.query() method.

@jerryjliu
Copy link
Collaborator

@ahmedriad1 good question! We're currently hard at work adding documentation, and a how-to for custom prompts is one of the main items.

In the meantime, I can help you directly. Which index are you using? I can send you a code snippet of the prompt templates, how to add it in as an argment.

@jerryjliu
Copy link
Collaborator

viveksilimkhan1 pushed a commit to viveksilimkhan1/llama_index that referenced this issue Oct 30, 2023
* better factory setup for textcat task

* better factory setup for textcat task

* better typing for examples from reader, allow for providing template/examples directly in config for textcat task

* rm commented out prints, underscore private vars

* fix textcat tests to use new factory

* make factory func for NER task as well, split out template

* Remove identifier from type name

* Add split_label docstring

* fix some types for textcat/ner tasks

* update custom task sections to note we recommend using some factory func for registering a task

* Include template in the docstrings

* fix import in usage examples

* Add initial implementation of JinjaReader

...And apply it to the NER task. The JinjaReader returns a str so that
it's easier to work on jinja2.Environment downstream.

* Make template non-optional

* Apply template to textcat

* Add jinja_reader to init

* Raise a ValueError if template is None

We don't expect the user to pass a None value.
I think it's better if we just raise an error rather than implicitly
using the DEFAULT_XX_TEMPLATE

* Add tests to check if external templates actually works

* Update some tests

* Update file extension for .jinja2 files

Jinja templates don't have a prescribed extension, but we've been using
.jinja2 files before (also reflects that we're using the jinja2
library for parsing), so let's use that.

* Add template parameter to README

* Add JinjaReader to README API docs

* Link template in the README and adjust tables

* ignore sqlalchemy MovedIn20Warning

* Change JinjaReader to FileReader

Much better to make this a generic file reader and remove any
restrictions regarding jinja or jinja2 files.

* convert relation task to use factory funciton pattern

* use v2 spancat template for v2

* add v2 textcat since we're adding template field

* start adding textcat.v2 README section

* use v2 tasks for everything (except rel)

* document template, link to code

* don't blindly cast in reader

* typo

* README typos and updates

* add template file reader to rel and spancat

* fix template type

* add jinja as well as jinja2 to manifest

* Apply suggestions from code review

* make TemplateConfigType just a str since the reader resolves to a str

* remove template callable and just use it as str

---------

Co-authored-by: Kabir Khan <kabir@explosion.ai>
Co-authored-by: Raphael Mitsch <r.mitsch@outlook.com>
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

No branches or pull requests

2 participants