-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arihan/mar 31 summarize and upsert code snippets from reposplitter (#57)
* Add summary function for code snippets
- Loading branch information
Showing
4 changed files
with
33 additions
and
4 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ const keys = [ | |
'source', | ||
'text', | ||
'ext', | ||
'summary', | ||
'repository', | ||
'branch', | ||
'userId', | ||
|
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,19 @@ | ||
import {LLMChain} from 'langchain/chains' | ||
import {OpenAI} from 'langchain/llms/openai' | ||
import {PromptTemplate} from 'langchain/prompts' | ||
|
||
const prompt = PromptTemplate.fromTemplate( | ||
`You are AI that make desc of code snippet. Many keywords, straight to point, 1 line. | ||
Code:#!/bin/sh\ngroovyc src/*.groovy\ngroovy src/Main.groovy --cp src/ | ||
AI:Compiles and runs a Groovy program using the source files in the \"src\" directory. | ||
Code:{code} | ||
AI:` | ||
) | ||
|
||
export async function AISummary(code: string, modelName: string = 'gpt-3.5-turbo', temperature: number = 0) { | ||
const model = new OpenAI({temperature, modelName}) | ||
const codeChain = new LLMChain({llm: model, prompt}) | ||
return await codeChain.call({code}) | ||
} |