Find answers from the community

Updated 2 years ago

is there a way to pass column

At a glance

The community member is trying to pass column descriptions to the LLM (Large Language Model) so that they are reflected in the API request being sent with the custom prompt. They have tried using context_query_kwargs and _get_table_context but nothing seems to work. Another community member suggests that the extra context descriptions should go into the context_query_kwargs dictionary, which should be a dictionary of table name to extra description. The community member has tried this but it still doesn't reflect in their request. After some discussion, the community member finds that the issue was with the formatting of the context_query_kwargs dictionary, and they were able to resolve the issue by implementing the suggested format.

Useful resources
is there a way to pass column descriptions to the llm so that it is reflected in the api request being sent with the custom prompt? have tried everything from context_query_kwargs to _get_table_context nothing seems to work for me
L
S
19 comments
Any extra context descriptions go into the context_query_kwargs dict. It's just dict of table name -> extra description

https://github.com/jerryjliu/llama_index/blob/0061ce44879eacbb4181002c02d37fafd5921fc8/llama_index/indices/struct_store/sql_query.py#L362
logan i have done this and sent this code exactly
but it wont reflect in my requesr
What llama index version do you have? The source code does not lie πŸ§™β€β™‚οΈ
only the latest good sir
is my implementation incorrect?
I think a nested dictionary may not work πŸ€” it should be a dictionary of type Dict[str, str], not Dict[str, Dict]

But I see output logs in your terminal. If it's working, it will show up at the end of the table descr logs (you'll probably have to scroll right to see it)

Also just to double check, pip show llama-index will confirm the version πŸ‘Œ
Plain Text
context_query_kwargs = {
    "your_table_name": {
        "record_id": "Unique identifier for a record. The record can represent various communication mediums such as a WhatsApp message, an email, or an SMS text message.",
        "record_type": "Type of the record. Values can be one of email, WhatsApp, SMS, or MMS.",
        "record_date": "Date and time of the record when the email/message/text was sent.",
        "record_from": "Details of the sender of the record. Contains the name of the sender, the phone number of the sender, and/or the email address of the sender.",
        "record_to": "Details of the receiver(s) of the record. Can be multiple receivers. Contains the names, phone numbers, and/or email addresses of the receivers.",
        "record_body": "Content of the record (email/message/text) comprising the substantive text message or email that was transmitted.",
        "record_file_id": "The file_id of the source file from another table called 'Files'. This corresponds to the file that this record was parsed/extracted from.",
        "record_attach": "Array of attachments associated with the record/email/text/WhatsApp. This is a list/array of S3 paths to the corresponding attachment files.",
        "additional_info": "Contains a JSON with additional information associated with a record.",
        "tags": "Array of tags associated with the record.",
        "add_to_timeline": "A boolean flag indicating if the record should be added to the Timeline.",
        "record_threat": "Identifies the thread of the record. In case of emails, this is the Subject of the email thread. In case of WhatsApp, this is the group/direct message name."
    }
}
i get this but im having some trouble understanding
how would you format this?
Just a giant string

Plain Text
{"your_table_name": """record_id: Unique...
record_type: ...
..."""}
checked the version 0.8.20
alright that makes sense
implementing right now let me get back to you
well it works, thank you logan
got another error to lose sleep over
untilnext timeπŸ±β€πŸ‘€πŸ±β€πŸ‘€
Haha good luck! πŸ™
Add a reply
Sign up and join the conversation on Discord