-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(semantic): add Hyde Code and Keywords strategy documentation
Added documentation for Hyde Code and Keywords strategy with detailed steps and code snippets.
- Loading branch information
Showing
7 changed files
with
114 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
layout: default | ||
title: Hyde Code Strategy | ||
nav_order: 3 | ||
parent: Semantic | ||
--- | ||
|
||
Code file: HydeCodeStrategy.ts | ||
|
||
1. generate hyde doc code from the user query | ||
2. retrieve code snippets by hyde code from the codebase | ||
3. summarize the code snippets and return the result | ||
|
||
```typescript | ||
channel.appendLine("=".repeat(80)); | ||
channel.appendLine(`= Hyde Keywords Strategy: ${this.constructor.name} =`); | ||
channel.appendLine("=".repeat(80)); | ||
|
||
this.step = HydeStep.Propose; | ||
let documents = await this.generateDocument(); | ||
let hydeCode = documents.content; | ||
|
||
this.step = HydeStep.Retrieve; | ||
let chunks = await this.retrieveChunks(hydeCode); | ||
|
||
this.step = HydeStep.Evaluate; | ||
let evaluateContext: KeywordEvaluateContext = { | ||
step: this.step, | ||
question: this.query, | ||
code: chunks.map(item => item.text).join("\n"), | ||
language: "" | ||
}; | ||
|
||
if (chunks.length === 0) { | ||
channel.appendLine("No code snippets found."); | ||
return new StrategyOutput("", []); | ||
} | ||
|
||
channel.appendLine("\n"); | ||
channel.appendLine(" --- Summary --- "); | ||
let evaluateIns = await PromptManager.getInstance().renderHydeTemplate(this.step, this.documentType, evaluateContext); | ||
return new StrategyOutput(await executeIns(evaluateIns), chunks); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
layout: default | ||
title: Hyde Keywords Strategy | ||
nav_order: 2 | ||
parent: Semantic | ||
--- | ||
|
||
Code file: HydeKeywordsStrategy.ts | ||
|
||
1. generate keywords from the user query | ||
2. retrieve code snippets by query from the codebase | ||
3. summarize the code snippets and return the result | ||
|
||
```typescript | ||
this.step = HydeStep.Propose; | ||
let documents = await this.generateDocument(); | ||
let keywords = documents.content; | ||
|
||
this.step = HydeStep.Retrieve; | ||
let queryTerm = this.createQueryTerm(keywords); | ||
let chunkItems = await this.retrieveChunks(queryTerm); | ||
|
||
this.step = HydeStep.Evaluate; | ||
let evaluateContext: KeywordEvaluateContext = { | ||
step: this.step, | ||
question: keywords.question, | ||
code: chunkItems.map(item => item.text).join("\n"), | ||
language: "" | ||
}; | ||
|
||
if (chunkItems.length === 0) { | ||
channel.appendLine("No code snippets found."); | ||
return new StrategyOutput("", []); | ||
} | ||
|
||
channel.appendLine("\n"); | ||
channel.appendLine(" --- Summary --- "); | ||
let evaluateIns = await PromptManager.getInstance().renderHydeTemplate(this.step, this.documentType, evaluateContext); | ||
return new StrategyOutput(await executeIns(evaluateIns), chunkItems); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters