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. "
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."