-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from ruru-m07/main
BUG FIXING 🐞
- Loading branch information
Showing
32 changed files
with
659 additions
and
139 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 |
---|---|---|
@@ -1,5 +1,18 @@ | ||
import Loader from "@/components/Loader"; | ||
import Loader2 from "@/components/Loader2"; | ||
import { CardWrapper } from "@/components/auth/card-wrapper"; | ||
|
||
export default function Loading() { | ||
return <Loader />; | ||
return ( | ||
<> | ||
<CardWrapper | ||
headerLabel="Welcome back" | ||
backButtonLabel="" | ||
backButtonHref="/register" | ||
> | ||
<div className="w-full h-auto my-10 flex justify-center items-center"> | ||
<Loader2 /> | ||
</div> | ||
</CardWrapper> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,67 +1,42 @@ | ||
import { genAI } from "@/lib/genAI"; | ||
import { HarmBlockThreshold, HarmCategory } from "@google/generative-ai"; | ||
import { NextResponse } from "next/server"; | ||
const fs = require("fs"); | ||
|
||
export async function GET() { | ||
return NextResponse.json({ message: "Hello from Gemini!" }); | ||
} | ||
|
||
export async function POST(req: Request) { | ||
const data = await req.text(); | ||
const model = genAI.getGenerativeModel({ model: "gemini-1.0-pro" }); | ||
// Access your API key as an environment variable (see "Set up your API key" above) | ||
|
||
const generationConfig = { | ||
temperature: 0.9, | ||
topK: 1, | ||
topP: 1, | ||
maxOutputTokens: 2048, | ||
}; | ||
// Converts local file information to a GoogleGenerativeAI.Part object. | ||
function fileToGenerativePart(path: string, mimeType: string) { | ||
return { | ||
inlineData: { | ||
data: Buffer.from(fs.readFileSync(path)).toString("base64"), | ||
mimeType, | ||
}, | ||
}; | ||
} | ||
|
||
const safetySettings = [ | ||
{ | ||
category: HarmCategory.HARM_CATEGORY_HARASSMENT, | ||
threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH, | ||
}, | ||
{ | ||
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, | ||
threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH, | ||
}, | ||
{ | ||
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, | ||
threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH, | ||
}, | ||
{ | ||
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, | ||
threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH, | ||
}, | ||
]; | ||
async function run() { | ||
// For text-and-image input (multimodal), use the gemini-pro-vision model | ||
const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); | ||
|
||
const chat = model.startChat({ | ||
generationConfig, | ||
safetySettings, | ||
history: [ | ||
{ | ||
role: "user", | ||
parts: [ | ||
{ | ||
text: "you r a AI chatBot that gime me the answer to the question., your name is Cocola AI, cocola chatBot or Cocola is your famous name. u need to try give answer as posible, give answer like u r chating with someone that is your friend. don't give me response in MD formate u can give me response in simple text formate. i hope u understand what i am saying to you.", | ||
}, | ||
], | ||
}, | ||
{ | ||
role: "model", | ||
parts: [ | ||
{ | ||
text: "SureHey there! I'm Cocola, your friendly chatbot. 😊\n\nFeel free to ask me anything, and I'll do my best to help. I'm still under development, but I'm learning new things all the time.\n\nLet's chat! 💬", | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
const prompt = "hello"; | ||
|
||
const imageParts = [fileToGenerativePart("./image1.png", "image/png")]; | ||
|
||
console.log(imageParts); | ||
|
||
const result = await model.generateContent([prompt, ...imageParts]); | ||
const response = await result.response; | ||
const text = response.text(); | ||
console.log(text); | ||
|
||
const result = await chat.sendMessage(data); | ||
const response = result.response; | ||
const text = response.text(); | ||
return Response.json({ text }); | ||
} | ||
|
||
return Response.json({ text }); | ||
run(); | ||
} |
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
Oops, something went wrong.