To create a response to a user's natural language query, the code follows these steps:
Parse the input query using parse_query(), which internally calls parser::parse_nl() to convert the natural language query into a structured format.
Rephrase the query if necessary, or proceed with the initial query by extracting keywords using get_keywords().
Perform a search for relevant code snippets using search_snippets(), which calls the semantic.search() method to retrieve matching snippets.
If needed, grow the relevant snippet using grow_snippet(), which extends the snippet's surrounding lines while maintaining its token count within a predefined limit.
Construct an AnswerResponse object with the user ID, session ID, query ID, and the snippets obtained.
Convert the AnswerResponse into a webserver::Response and return it to the user.
Please note that this is a simplified explanation of the process. The actual code may have additional checks and logic.
Looking at the response and comparing, the biggest improvement would be crossing the file boundary in the explanation step.
- llm rephrases the last conversation entry into a standalone, context-free search query
- rephrased query is embedded, top-k results retrieved from the vector db
- llm selects a top-1 winner from the top-k results
- llm answers the question given conversational context and the top-1 code search result
(from https://github.com/BloopAI/bloop/blob/8905a36388ce7b9dadaedf...)