LLMGraphTransformer.convert_to_graph_documents(documents) AttributeError: объект 'str' не имеет атрибута 'content'Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 LLMGraphTransformer.convert_to_graph_documents(documents) AttributeError: объект 'str' не имеет атрибута 'content'

Сообщение Anonymous »

Код: Выделить всё

from langchain_core.documents import Document

text = """
Marie Curie, born in 1867, was a Polish and naturalised-French physicist and chemist who conducted pioneering research on radioactivity.
She was the first woman to win a Nobel Prize, the first person to win a Nobel Prize twice, and the only person to win a Nobel Prize in two scientific fields.
Her husband, Pierre Curie, was a co-winner of her first Nobel Prize, making them the first-ever married couple to win the Nobel Prize and launching the Curie family legacy of five Nobel Prizes.
She was, in 1906, the first woman to become a professor at the University of Paris.
"""
documents = [Document(page_content=text)]
graph_documents = llm_transformer.convert_to_graph_documents(documents)
print(f"Nodes:{graph_documents[0].nodes}")
print(f"Relationships:{graph_documents[0].relationships}")---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
 in ()
8 """
9 documents = [Document(page_content=text)]
---> 10 graph_documents = llm_transformer.convert_to_graph_documents(documents)
11 print(f"Nodes:{graph_documents[0].nodes}")
12 print(f"Relationships:{graph_documents[0].relationships}")

2 frames
/usr/local/lib/python3.10/dist-packages/langchain_experimental/graph_transformers/llm.py in process_response(self, document)
593             nodes_set = set()
594             relationships = []
--> 595             parsed_json = self.json_repair.loads(raw_schema.content)
596             for rel in parsed_json:
597                 # Nodes need to be deduplicated using a set

AttributeError: 'str' object has no attribute 'content'
Я использую среду Colab Notebooks, Llm использует API HuggingFaceH4/starchat2-15b-v0.1
Я нашел аналогичную проблему на GitHub --https://github.com/langchain-ai/langchain/issues/21482

Подробнее здесь: https://stackoverflow.com/questions/785 ... eerror-str
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Python-Convert docx в pdf с помощью docx2pdf import Convert, но выдает ошибки AttributeError: Word.Application.Documents
    Anonymous » » в форуме Python
    0 Ответы
    30 Просмотры
    Последнее сообщение Anonymous
  • Почему оба Convert.ToInt32(Byte) и Convert.ToInt32(Byte[]) компилируются, но Convert.ToInt32(byte[]) выдает исключение в
    Anonymous » » в форуме C#
    0 Ответы
    23 Просмотры
    Последнее сообщение Anonymous
  • Объект DataFrame не имеет атрибута str - ошибка .str.replace
    Anonymous » » в форуме Python
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous
  • AttributeError: объект «str» не имеет атрибута «обновление» в игре.
    Anonymous » » в форуме Python
    0 Ответы
    97 Просмотры
    Последнее сообщение Anonymous
  • Декодирование JWT, AttributeError: объект 'str' не имеет атрибута 'decode'
    Anonymous » » в форуме Python
    0 Ответы
    48 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Python»