11import { GoogleGenerativeAI } from "@google/generative-ai"
2- import { Document } from "@langchain/core/documents"
32import { commit_main_summary_prompt , pr_summary_prompt } from "../prompt"
4-
3+ import fs from 'fs' ; // Add this import at the top
4+ import { summary_pr_mistral } from "./mistral"
55
66export interface CodeChange {
77 filename : string ;
@@ -27,67 +27,35 @@ export const aisummariseCommit = async (diff: string,commitMessage:string) => {
2727}
2828
2929export const aisummarisePR = async ( codes :CodeChange [ ] , pullReqTitle : string , pullReqMessage :string ) => {
30- const full_code :string = codes . map ( ( code ) => code . patch + code . filename ) . join ( '\n' ) ;
31-
32- // const pr_prompt = pr_summary_prompt({
33- // title:pullReqTitle,
34- // description:pullReqMessage,
35- // file_diff:full_code
36- // })
37-
38- // const prompt: MessageParam[] = [{
39- // role: 'user',
40- // content: `${pr_prompt}`
41- // }]
42-
43- // const main_summary = await generateCompletionClaude(prompt)
44-
45- const main_summary = await await model . generateContent ( [
46- pr_summary_prompt ( {
47- title :pullReqTitle ,
48- description :pullReqMessage ,
49- file_diff :full_code
50- } )
51- ] )
52-
53-
54- return main_summary . response . text ( )
55- }
56-
30+ const full_code :string = codes . map ( ( code ) => code . patch + code . filename ) . join ( '' ) ;
5731
32+ const system_prompt = pr_summary_prompt ( {
33+ title :pullReqTitle ,
34+ description :pullReqMessage ,
35+ file_diff :full_code
36+ } )
37+ const prompt = 'Summerise this PR'
5838
59- // This summarize code generate summary for the RAG
60- export const summarizecode = async ( doc :Document ) => {
61- console . log ( "getting summary for" , doc . metadata . source ) ;
62- try {
63- const code = doc . pageContent . slice ( 0 , 10000 ) ;
64- const response = await model . generateContent ( [
65- `You are an inteligen software engineer who specialize in onboarding junior software engineers on the project
66- You are onboaring juniors software engineer and explaing to them the purpose of the ${ doc . metadata . source } file
67-
68- Here is the code:
69- --------
70- ${ code }
71- --------
72- Give a summary no more than 100 words of the code above`
73-
74- ] )
75-
76- return response . response . text ( )
77-
78- } catch ( error ) {
79- return ''
80- }
81-
82- }
39+ const main = await summary_pr_mistral ( system_prompt , prompt )
40+ return main
41+
42+ // fs.writeFileSync(`'full_code_${i}.txt'`, full_code, 'utf8'); // Add this line to save the code
43+ // i++;
44+ // console.log("Title:", pullReqTitle)
45+ // fs.writeFileSync(`'title_${i}.txt'`, pullReqTitle, 'utf8'); // Add this line to save the code
46+
47+ // console.log("Description:",pullReqMessage)
48+ // fs.writeFileSync(`'description_${i}.txt'`, pullReqMessage, 'utf8'); // Add this line to save the code
49+ // console.log('code',full_code)
8350
84- export async function aigenerateEmbedding ( summary :string ) {
85- const model = genAI . getGenerativeModel ( {
86- model : "text-embedding-004"
87- } )
51+ // const main_summary = await model.generateContent([
52+ // pr_summary_prompt({
53+ // title:pullReqTitle,
54+ // description:pullReqMessage,
55+ // file_diff:full_code
56+ // })
57+ // ])
8858
89- const result = await model . embedContent ( summary )
90- const embedding = result . embedding
91- return embedding . values
92- }
9359
60+ //return main_summary.response.text()
61+ }
0 commit comments