-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgemini.js
72 lines (53 loc) · 2.19 KB
/
gemini.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const { GoogleGenerativeAI } = require("@google/generative-ai");
// Access your API key as an environment variable (see "Set up your API key" above)
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash"});
const generationConfig = {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 8192,
responseMimeType: "application/json",
};
const chat = model.startChat({
generationConfig,
history: [
],
});
export async function genDescription(description) {
try{
const prompt = `Description: ${description} , Depending on the work description give me list(more than two options) of summaries (in 3 -4 lines) in array format from which I can choose one, in JSON Format(a list of strings)`
const result = await chat.sendMessage(prompt);
let text = result.response.text();
text = JSON.parse(text)
console.log({text});
return text;
}catch(e){
console.log({e});
return {
description:"Give Another Description"
}
}
}
export async function calculateATS(jobDescription, resumeText) {
const prompt = `Calculate a resume score out of 100 for resume description given below with respect to Job Description (You must give me a score, use any score algorithm, use keyword matching, Skills Match, Experience, Education ) example :{
resume_score:score,
breakdown:breakdown,
details:details
}) : Resume Description :(${resumeText}) , Job Description : (${jobDescription})`
const result = await chat.sendMessage(prompt);
console.log(result.response.text());
const text = JSON.parse(result.response.text());
return text;
}
export async function giveSuggestions(resumeDescription, title){
const prompt = `Resume Desccription : ${resumeDescription}, Job Title :${title} , Depending on the resume description give me some suggestions , example :{
experience : experience description suggestions,(a string)
project : project description suggestions,(a string)
skills : suggestions based on skills(a string)
}`
const result = await chat.sendMessage(prompt);
console.log(result.response.text());
const text = JSON.parse(result.response.text());
return text;
}