Chat Engine - Condense Question Modeο
Condense question is a simple chat mode built on top of a query engine over your data.
For each chat interaction:
first generate a standalone question from conversation context and last message, then
query the query engine with the condensed question for a response.
This approach is simple, and works for questions directly related to the knowledge base. Since it always queries the knowledge base, it can have difficulty answering meta questions like βwhat did I ask you before?β
Get started in 5 lines of codeο
Load data and build index
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
data = SimpleDirectoryReader(input_dir="../data/paul_graham/").load_data()
index = GPTVectorStoreIndex.from_documents(data)
Configure chat engine
chat_engine = index.as_chat_engine(verbose=True)
Chat with your data
response = chat_engine.chat('What did Paul Graham do after YC?')
Querying with: What was the next step in Paul Graham's career after his involvement with Y Combinator?
print(response)
After his involvement with Y Combinator, Paul Graham went on to become a venture capitalist and angel investor. He founded the venture capital firm Y Combinator, which has invested in over 2,000 startups, including Airbnb, Dropbox, and Stripe. He also wrote several books on startups and entrepreneurship, and continues to write essays on technology and startups.
Ask a follow up question
response = chat_engine.chat('What about after that?')
Querying with: What other activities has Paul Graham been involved in since founding Y Combinator and writing books on startups and entrepreneurship?
print(response)
Since founding Y Combinator and writing books on startups and entrepreneurship, Paul Graham has been involved in a variety of activities. He has continued to write essays and blog posts on topics related to startups and entrepreneurship, and has also been involved in speaking engagements and interviews. He has also been involved in investing in startups, both through Y Combinator and through his own venture capital firm, YCVC. He has also been involved in teaching classes on entrepreneurship and startups at Stanford University and other institutions. Additionally, he has been involved in the development of software, such as the programming language Arc and the news aggregator Hacker News.
response = chat_engine.chat('Can you tell me more?')
Querying with: What other activities has Paul Graham been involved in since founding Y Combinator and writing books on startups and entrepreneurship?
print(response)
Since founding Y Combinator and writing books on startups and entrepreneurship, Paul Graham has been involved in a variety of activities. He has continued to write essays and blog posts on topics related to startups and entrepreneurship, and has also been involved in speaking engagements and interviews. He has also been involved in investing in startups, both through Y Combinator and through his own venture capital firm, YCVC. He has also been involved in teaching classes on entrepreneurship and startups at Stanford University and other institutions. Additionally, he has been involved in the development of software, such as the programming language Arc and the news aggregator Hacker News.
Reset conversation state
chat_engine.reset()
response = chat_engine.chat('What about after that?')
Querying with: What happens after the current situation?
print(response)
After realizing that he did not want to run a company, the narrator decides to build a subset of the project as an open source project. He focuses on building a new Lisp, which he does not have to hide the parentheses of. He hopes to lure Robert into working on the project with him, but Robert refuses. The narrator then recruits Dan Giffin, who had worked for Viaweb, and two undergrads who wanted summer jobs, and they begin working on the project. After a few months, the narrator realizes that the time he spent working on the project was not wasted after all, and he is able to use the knowledge he gained to help other startups.