Skip to content

Instantly share code, notes, and snippets.

@calebdre
Last active June 15, 2024 17:22
Show Gist options
  • Save calebdre/e448fe85880194fefff05f6bd4311497 to your computer and use it in GitHub Desktop.
Save calebdre/e448fe85880194fefff05f6bd4311497 to your computer and use it in GitHub Desktop.
const collectFileData = async (dir: string) => {
// collect all the files in the directory
const files = findTsFiles(dir)
for (const file of files) {
// extract functions from each file
file.functions = extractFunctions(file.content)
for (const func of file.functions) {
// get the description for each function
const description = await getFunctionDescription(file, func.functionName)
if (description) {
func.description = description
// get the embedding for the description
func.embedding = await createEmbedding('', description)
}
}
}
return files
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment