Find answers from the community

Updated 2 years ago

Hello guys I want to load the text from

At a glance

The community member in the post wants to load text from a "kb" (knowledge base) instead of a file. The comments indicate that the community members are discussing the difference between loading text from a file versus directly from a text source. One community member provides an example of how to load text from an iterable using the StringIterableReader and GPTTreeIndex classes, and suggests that the original poster wanted to load text directly from the text source, which is confirmed by another community member. There is no explicitly marked answer in the comments.

Hello guys, I want to load the text from kb instead of a file : kb = " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vel mauris pretium, porttitor justo consectetur, elementum quam. "

documents = SimpleDirectoryReader(input_files=["./file.txt"]).load_data()
L
0
5 comments
I'm not sure what you mean here -- what is the difference between a file and a kb here?
i found the answer : from llama_index import StringIterableReader, GPTTreeIndex

documents = StringIterableReader().load_data(
texts=["I went to the store", "I bought an apple"])
index = GPTTreeIndex.from_documents(documents)
query_engine = index.as_query_engine()
query_engine.query("what did I buy?")

response should be something like "You bought an apple."

ah, you wanted to load directly from text, nice!
exactly πŸ˜‰
Add a reply
Sign up and join the conversation on Discord