Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'page_content' #3799

Closed
SnoopyDevelops opened this issue Apr 29, 2023 · 7 comments
Closed

AttributeError: 'str' object has no attribute 'page_content' #3799

SnoopyDevelops opened this issue Apr 29, 2023 · 7 comments

Comments

@SnoopyDevelops
Copy link

SnoopyDevelops commented Apr 29, 2023

https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html

https://github.com/hwchase17/langchain/blob/master/docs/use_cases/question_answering/semantic-search-over-chat.ipynb

image

image

image

Apparently, split_documents function's input need to have attributes of page_content and metadata, but getting string list as input here

@PawelFaron
Copy link
Contributor

Please provide working code that can reproduce this issue.

@SnoopyDevelops
Copy link
Author

https://github.com/hwchase17/langchain/blob/master/docs/use_cases/question_answering/semantic-search-over-chat.ipynb

  1. Ingest chat embeddings
with open("messages.txt") as f:
    state_of_the_union = f.read()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
pages = text_splitter.split_text(state_of_the_union)

text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
texts = text_splitter.split_documents(pages)

@PawelFaron
Copy link
Contributor

PawelFaron commented May 4, 2023

As for me it looks like a bug in that example.
Change this:
texts = text_splitter.split_documents(pages)
To this:
texts = text_splitter.create_documents(pages)

@SnoopyDevelops
Copy link
Author

It worked. Can I create a pull request to fix this issue?

@PawelFaron
Copy link
Contributor

Sorry I created it already.

@SnoopyDevelops
Copy link
Author

No problem, Thanks for your help

dev2049 pushed a commit that referenced this issue May 5, 2023
Fixed the issue mentioned here:

#3799 (comment)

Co-authored-by: Pawel Faron <ext-pawel.faron@vaisala.com>
@ccwdb
Copy link

ccwdb commented Aug 13, 2023

Thanks for helpping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants