Find answers from the community

s
F
Y
a
P
Updated 9 months ago

@Logan M @WhiteFang_Jr

@Logan M @WhiteFang_Jr
Hi, hope you are doing good. I was wondering, now that I have a list of nodes with scores, is there a way to give them to a synthesizer? I tried a lot of stuff to no avail. I cannot plug it directly into a query engine, as i need to add one node by hand (patient information).
My current approach is:
Attachment
Screenshot_from_2024-01-31_10-01-47.png
R
f
2 comments
You can try this
Plain Text
from llama_index import get_response_synthesizer

custom_synthesizer = get_response_synthesizer(response_mode="compact")

response = custom_synthesizer.synthesize(query_str, node_with_scores)
Thank you, I got it to work building this code:

Plain Text
def generate_response(retrieved_nodes, query_str,patient_information, qa_prompt, llm):
    context_str = "\n\n".join([r.get_content() for r in retrieved_nodes])
    fmt_qa_prompt = qa_prompt.format(context_str=context_str, query_str=query_str, patient_information=patient_information)

    print(fmt_qa_prompt)
    response = llm.complete(fmt_qa_prompt)
    return str(response), fmt_qa_prompt
Add a reply
Sign up and join the conversation on Discord