[Question]: chatbot to facilitate development. #8562
Replies: 2 comments
-
🤖 Hi @buckmaxwell, good to see you again! From your question, it seems like you're trying to use LlamaIndex to answer questions about the code in your repository. However, LlamaIndex, specifically the However, there are a few things you could try to improve the results:
from llama_index import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader('data').load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_chat_engine(chat_mode="context")
response = query_engine.chat("What did the author do growing up?")
print(response)
response = query_engine.chat("Oh interesting, tell me more.")
print(response) This solution was suggested in a similar issue: [Bug]: Running the chatbot customization tutorial doesn't load context data
from llama_index import SimpleDirectoryReader
filename_fn = lambda filename: {'file_name': filename}
# automatically sets the metadata of each document according to filename_fn
documents = SimpleDirectoryReader(input_files=text_list, file_metadata=filename_fn).load_data()
print(documents[0].text)
print(documents[0].metadata) This solution was suggested in a similar issue: [Question]: Indexes built from text don't produce good answers
I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Hey @buckmaxwell, you are right that the default configuration of the project is optimized for indexing natural language text files. You'd need to do a bit of customization to get the best performance for code. For example, it's better to use a code specific parser: https://docs.llamaindex.ai/en/stable/module_guides/loading/node_parsers/root.html#text-splitter-customization |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question Validation
Question
What I want to do is simple - at the root of a code repository run the following.
My expectation would have been that I could then ask questions about the code and it would be kind of like chat gpt 4 but I wouldn't need to provide all the extra context.
It isn't working that way though - it doesn't seem to be able to answer any questions - as if the indexer was only built for understanding text files and docs not for reading code. Is there another reader or indexer I could be using? Or another way to solve this problem?
Beta Was this translation helpful? Give feedback.
All reactions