-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Multi-Step Form * feat: changes ui * feat: Gemini Integaretion
- Loading branch information
Showing
6 changed files
with
98 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,54 @@ | ||
import { GoogleGenerativeAI } from "@google/generative-ai"; | ||
|
||
const MODEL_NAME = "gemini-1.5-pro"; | ||
const API_KEY1 = process.env.NEXT_PUBLIC_GEMINI_API_KEY as string; | ||
|
||
const chatHistory = [ | ||
{ | ||
role: "user", | ||
parts: [ | ||
{ | ||
text: `You are an expert in generating cover letter. Your task is to generate cover letter for given job description and resume details. If you are unable to generate then provide output as Information is insufficient!!`, | ||
}, | ||
], | ||
}, | ||
{ | ||
role: "model", | ||
parts: [{ text: "How can I help you ?" }], | ||
}, | ||
]; | ||
|
||
type Props = { | ||
jobDescription: string; | ||
project: string; | ||
skills: string; | ||
experience: string; | ||
}; | ||
|
||
export async function getCoverLetter({ | ||
jobDescription, | ||
project, | ||
skills, | ||
experience, | ||
}: Props) { | ||
if (!API_KEY1) throw new Error("Invalid Api Key!"); | ||
|
||
const genAI = new GoogleGenerativeAI(API_KEY1); | ||
const model = genAI.getGenerativeModel({ model: MODEL_NAME }); | ||
|
||
model.generationConfig = { | ||
temperature: 0.9, | ||
topK: 1, | ||
topP: 1, | ||
}; | ||
|
||
const chat = model.startChat({ | ||
history: chatHistory, | ||
}); | ||
|
||
const result = await chat.sendMessage( | ||
`Job Description : \n${jobDescription}.\n Projects : \n${project} \nSkills: \n${skills} \nExperience: \n${experience}` | ||
); | ||
const response = result.response; | ||
return response.text(); | ||
} |