[Question]: Using LSP to generate a knowledge graph for a code base. #8375
Replies: 3 comments
-
Hello, this is very interesting. Certainly, for code use case, leveraging more semantic structure in the codebase could lead to better results. Some questions:
If you have a specific repo, perhaps you could try to create a notebook around using crabviz to aid in node splitting and metadata extraction, we could work towards merging that if it makes sense. |
Beta Was this translation helpful? Give feedback.
-
LSP is actually language agnostic. Crabviz was just to illustrate what's possible. In an actual implementation that can be integrated with llama_index, I guess one needs to use an LSP python client library to interface with a specific LSP server. Get the data from it and build Documents, nodes and eventually the knowledge graph from that. |
Beta Was this translation helpful? Give feedback.
-
🤖 Hello, Your idea of using the Language Server Protocol (LSP) to build a knowledge graph with LlamaIndex for querying a large codebase is indeed feasible and worth pursuing. In LlamaIndex, the The Here is a sample code snippet from the class KnowledgeGraphIndex(BaseIndex[KG]):
...
def as_retriever(self, **kwargs: Any) -> BaseRetriever:
from llama_index.indices.knowledge_graph.retrievers import (
KGRetrieverMode,
KGTableRetriever,
)
if len(self.index_struct.embedding_dict) > 0 and "retriever_mode" not in kwargs:
kwargs["retriever_mode"] = KGRetrieverMode.HYBRID
return KGTableRetriever(self, **kwargs)
... This code shows that the LlamaIndex framework can be used to build a knowledge graph and query it using keywords or embeddings or both. The Language Server Protocol (LSP) can be used to provide the query string to the You can find more details about the
I hope this helps! If you have any more questions, feel free to ask. Best, 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.
-
Question Validation
Question
Hello,
I am very new to machine learning and to Llama_index and LLM's in general. Still exploring the concepts.
I was looking into possible ways of running a LLM locally against a large codebase and so far not much success.
One idea I've had while reading through the documentation and how Llama_index works is to potentially build a knowledge graph (Or perhaps another type of index will be more suitable for a codebase?) using The Language Server Protocol (LSP).
Is this an idea worth pursuing?
For example, I have found this project released recently that seems to do something similar : https://github.com/chanhx/crabviz
Potentially the components of the graph, using LSP, can be methods and functions or more granular parts of the code. Perhaps it will optimise the process of querying a codebase much better!
Beta Was this translation helpful? Give feedback.
All reactions