Storia-AI/sage

Feature request: Linkify code symbols in the model response

開放

#54 建立於 2024年10月4日

 (0 則留言) (0 個反應) (0 位負責人)Python (116 個分叉)auto 404
hacktoberfest🔥 difficulty: 3

倉庫指標

星標
 (1,267 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Given an LLM response that contains a code symbol (e.g. class name, method, etc.), we should link it to its exact location on GitHub. For instance, if you're chatting with Hugging Face's Transformers library:

  • Original response: "To define a BERT model using the Hugging Face Transformers library, you can use the BertModel class."

  • Link-ified response: "To define a BERT model using the Hugging Face Transformers library, you can use the BertModel class."

This should be done as a post-processing step in chat.py, once the model is done streaming.

Work items:

  1. Produce an AST (Abstract Syntax Tree) for every file in the repository. This can be done via the tree_sitter library, which we're already using in chunk.py.
  2. Identify class / method / file names in the model response, potentially using regular expressions.
  3. Look up the strings matched by the regular expressions in the per-file ASTs.
  4. Map the code symbol to a github URL.

貢獻者指南