Find answers from the community

Updated 2 months ago

So sorry for yet another question Is

So sorry for yet another question! Is there a problem with the airtable reader? I am getting this error when I use the reader... I am not sure why..

Traceback (most recent call last): File "main.py", line 27, in <module> documents = reader.load_data(table_id = AIRTABLE_TABLE_ID, base_id = AIRTABLE_BASE_ID) File "/home/runner/focus-tech-V1/venv/lib/python3.10/site-packages/llama_index/readers/llamahub_modules/airtable/base.py", line 33, in load_data return [Document(f"{all_records}", extra_info={})] File "pydantic/main.py", line 332, in pydantic.main.BaseModel.__init__ TypeError: __init__() takes exactly 1 positional argument (2 given) 
L
t
12 comments
I think the reader is just outdated

Are you using download_loader ?

Try this: download_loader(..., refresh_cache=True)
Thanks. Now seem not to get an error there.

But now am getting this on another section of the code.. This had been working in previous version ~3 weeks ago.

Any idea?

Traceback (most recent call last):
File "main.py", line 53, in <module>
exec(f"{node_name} = Node(text=node_text, extra_info=extra_info, node_info=node_info)")
File "<string>", line 1, in <module>
NameError: name 'Node' is not defined. Did you mean: 'nodes'?

See my code below (pls don't laugh at it)..

create nodes list based on patterns

nodes = []
for document in documents:
text = document.text
matches1 = re.findall(pattern1, text)
matches2 = re.findall(pattern2, text)
matches3 = re.findall(pattern3, text)

takes quotes & people from matches & puts them into list of nodes

for quote, person, url in zip(matches1, matches2, matches3):
node_name = f"node{len(nodes) + 1}"
node_text = f"{quote}"
extra_info = {"Person": person}
node_info = {"url": url}
exec(f"{node_name} = Node(text=node_text, extra_info=extra_info, node_info=node_info)")
nodes.append(eval(node_name)
maybe I am doing something wrong with all my nodes computations?
Did you import Node?

from llama_index.schema import Node
(also no worries, your code looks fine ha!)
Yep - the issue seems to be that that the attributes of 'nodewithscore' have changed. See below.

Previously, nodes had attributes extra_info and node_info. & what I was doing was attaching the person who said a quote & the source URL to the node, so that I could then display it in my app.

Now even though I assign values to extra_info and node_info, they just appear under attribute metadata & I can't extract that from nodewithscore.

I think there is a way round but will have to look tomorrow...

Thanks for all your help as usual.

for node_with_score in response.source_nodes: source_quotes.append(node_with_score.node.text) source_people.append(node_with_score.extra_info.get("Person")) source_url.append(node_with_score.node_info.get("url"))


[NodeWithScore(node=TextNode(id_='824ec1d1-2322-4d4f-adba-3aa82107ab11', embedding=None, metadata={'Person': 'Trae Stephens and Markie Wagner'}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={}, hash='7b88201177e1bab59813d263b53edf1f30df221599e14379b7acc29eee642bb1', text='In the context of your quest, you can think of yourself as a player with specific resources, skills, and powers. These attributes influence the likelihood of you succeeding on your quest. For example, if you are a recent engineering graduate, you might have some computer science skills, and a lot of energy. On the other hand, if you are an older repeat founder, you might have less energy, and more familial commitments, but a large network of potential employees, management experience, and enough social capital to raise a large amount of money for an unproven idea.\n', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\n\n{content}', metadata_template='{key}: {value}', metadata_seperator='\n'), score=0.8020478524421146)
Ok apparently i needed to do this (thanks GPT).

--
Explanation:

To access the "Person" metadata, you need to navigate through the node object's extra_info attribute, so it should be node_with_score.node.extra_info.get("Person").

To access the "url" metadata, you need to navigate through the node object's node_info attribute, so it should be node_with_score.node.node_info.get("url").

With these changes, the corrected code will correctly extract the "Person" and "url" metadata attributes from the node object within each NodeWithScore object and store them in the source_people and source_url lists, respectively.
--

Seems to work but now being told: TypeError: Object of type NodeWithScore is not JSON serializable

😩
Sorry just reading this now haha
What's the current iteration of the code look like? What is complaining about JSON serializable?
This bit -

source_quotes = [] source_people = [] source_url = [] for node_with_score in response.source_nodes: source_quotes.append(node_with_score.node.text) source_people.append(node_with_score.node.extra_info.get("Person")) source_url.append(node_with_score.node.node_info.get("url")) # returns to front end return jsonify({'response': response, 'source_quotes': source_quotes, 'source_people': source_people, 'source_url': source_url})
I have fixed this this morning.

it was telling me that objects of type nodewithscore are not json serializable. so I just had to return only the response i.e. response.response, rather than response, which included all the now non-serializable bits. did not happen with the previous version.

thank you for all your help
Add a reply
Sign up and join the conversation on Discord