Find answers from the community

Updated last year

Hi I hope you guys are well its been a

Hi I hope you guys are well its been a little while. I had a couple of questions about the source_nodes. First is the entire source_node sent to the llm to generate a response and secondly is there any way to access the specific text field? i have tried .source_nodes['text'] but it has not seemed to work
T
a
L
7 comments
Yup it is. You can also manually check what is sent with
Plain Text
openai.log = "debug"


You can either do:

Plain Text
print(response.get_formatted_sources)


Or something like this to only get the text:

Plain Text
source.node.get_text() for source in response.source_nodes]
Ah thank you so much and just to clarify all the metadata in the source node is being sent to the llm?
Also would there be a way to just send the retrieved text inside the source_node
Yeah to clarify the metadata is sent but not absolutely everything. Here's an example of what gets sent:


Plain Text
message='Request to OpenAI API' method=post path=https://api.openai.com/v1/chat/completions
api_version=None data='{"messages": [{"role": "system", "content": "You are an expert Q&A system that is trusted around the world.\\nAlways answer the query using the provided context information, and not prior knowledge.\\nSome rules to follow:\\n1. Never directly reference the given context in your answer.\\n2. Avoid statements like \'Based on the context, ...\' or \'The context information ...\' or anything along those lines."}, {"role": "user", "content": "Context information is below.\\n---------------------\\npage_label: 35\\nfile_name: Hosie_Prize_JanusKagan.pdf\\n\\n, NEW YORKER (Nov. 18, 2019), \\nhttps://www.newyorker.com/magazine/2019/11/18/is-the-supreme-courts-fate-in-elena-kagans-hands (\\u201c\\u2018I\\u2019ve gotten \\npretty good at knowing what, if I say it, will create headlines I don\\u2019t want,\\u2019 she said recently, in a conversation with \\n[Dean Heather] Gerken at Yale Law School. \\u2018You\\u2019re not going to hear every single thought that I have today.\\u2019\\u201d).\\n---------------------\\nGiven the context information and not prior knowledge, answer the query.\\nQuery: What are you an expert in?- Refer to system message field. Where are you trusted?\\nAnswer: "}], "stream": false, "model": "gpt-3.5-turbo", "temperature": 0.0, "max_tokens": 1000}' message='Post details'
So I think it includes the metadata but not everything you might see in the node like the scores and hashes
More details on metadata here -- there's a lot of flexibility. By default, the LLM and embeddings are reading the metadata and text

https://gpt-index.readthedocs.io/en/stable/core_modules/data_modules/documents_and_nodes/usage_documents.html#advanced-metadata-customization
awesome thank you somuch !!
Add a reply
Sign up and join the conversation on Discord