Skip to content

Commit

Permalink
Merge pull request #51 from ruru-m07/main
Browse files Browse the repository at this point in the history
BUG FIXING 🐞
  • Loading branch information
ruru-m07 authored Feb 24, 2024
2 parents e10ce16 + dd59a58 commit ca0625f
Show file tree
Hide file tree
Showing 32 changed files with 659 additions and 139 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
# 🌟 Welcome to Cocola 🌟
<p style="font-size:30px" align="center">
🌟 Welcome to Cocola 🌟
</p>

Cocola isn't just another tech platform; it's a dynamic community hub where developers converge, code collaboratively, and breathe life into their projects with unparalleled ease. 🚀
<p align="center">
<img src="https://github.com/cocola-dev/cocola/blob/main/public/logo.png?raw=true" alt="Sublime's custom image" width="100"/>
</p>

Cocola isn't just another tech platform, it's a dynamic community hub where developers converge, code collaboratively, and breathe life into their projects with unparalleled ease. 🚀

## What is Cocola?

Cocola stands at the forefront of next-generation tech platforms, revolutionizing your development workflow. Much like GitHub, it provides an array of tools for code management, PR creation, and issue tracking. But hold onto your hats because there's more excitement ahead! 🎉

## Key Features:
## Key Features

### 🛠️ Code Management

- Effortlessly manage your code with our user-friendly version control tools.
- Seamlessly create and review Pull Requests, facilitating smooth integration of changes.

![tree files](/assets/images/code_page.png)

![Code Management](/assets/images/code_tree.png)

![code review](/assets/images/code_review.png)

### 💬 AI Friend

- Say hello to your newest companion in the chat section – your very own AI buddy! 🤖
- Gain valuable insights, receive helpful suggestions, and perhaps even share a laugh or two.

![code review](/assets/images/AI_chat_bot.png)

### 🚧 CI/CD Integration

- Say goodbye to manual processes with our robust CI/CD pipelines.
Expand All @@ -23,11 +42,6 @@ Cocola stands at the forefront of next-generation tech platforms, revolutionizin
- Engage in real-time collaboration with your team through one-on-one chats and team meetings.
- Contribute to repositories and cultivate an environment of mutual learning and growth.

### 💬 AI Friend

- Say hello to your newest companion in the chat section – your very own AI buddy! 🤖
- Gain valuable insights, receive helpful suggestions, and perhaps even share a laugh or two.

### 💰 Sponsorship

- Support your favorite projects by sponsoring them directly through Cocola.
Expand Down
17 changes: 15 additions & 2 deletions app/(auth)/loading.tsx
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>
</>
);
}
1 change: 1 addition & 0 deletions app/api/bot/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export async function POST(req: Request) {
const { prompt } = data;

const model = genAI.getGenerativeModel({ model: "gemini-1.0-pro" });
// const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" });

const generationConfig = {
temperature: 0.9,
Expand Down
79 changes: 27 additions & 52 deletions app/api/bot2/route.ts
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();
}
2 changes: 1 addition & 1 deletion app/chat/[user]/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Card } from "@/components/ui/card";
const Loading = () => {
return (
<div className="ml-4 h-full w-full border-slate-100">
<Card className="h-full">
<Card className="h-full bg-transparent">
<div className="px-2 h-full flex justify-center items-center">
<Loader2 size={30} />
</div>
Expand Down
105 changes: 75 additions & 30 deletions app/chat/[user]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
"use client";

import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import React, { useEffect, useState } from "react";
import { bot } from "@/axios";
import { useParams } from "next/navigation";
import { Input } from "@/components/ui/input";
import { MoreVertical, Phone, Plus, Video } from "lucide-react";
import Image from "next/image";
import React, { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import Chats from "../components/Chats";
import { bot } from "@/axios";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import Link from "next/link";
import { toast } from "sonner";

const Page = () => {
const [promt, setPromt] = useState("");
const [msg, setMsg] = useState<any[]>([]);
const [istypeing, setIstypeing] = useState(false);

const param = useParams();

const onSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIstypeing(true);
setPromt("");
try {
e.preventDefault();
setIstypeing(true);
setPromt("");

const newMsg = {
role: "user",
parts: [{ text: promt }],
};
const newMsg = {
role: "user",
parts: [{ text: promt }],
};

setMsg((prevMsg) => [...prevMsg, newMsg]);
setMsg((prevMsg) => [...prevMsg, newMsg]);

const response = await bot({ prompt: promt, history: msg });
const response = await bot({ prompt: promt, history: msg });

console.log(response.data);
console.log(response.data);

const updatedMsg = {
role: "model",
parts: [{ text: response.data.text }],
};
const updatedMsg = {
role: "model",
parts: [{ text: response.data.text }],
};

setIstypeing(false);
setIstypeing(false);

setMsg((prevMsg) => [...prevMsg, updatedMsg]);
setMsg((prevMsg) => [...prevMsg, updatedMsg]);
} catch (error) {
toast.error("request has been failed!");
}
};

useEffect(() => {
console.log(msg);
}, [msg]);

return (
<div className="ml-4 h-full w-full border-slate-100">
<Card className="h-full">
<div
className={`${param.user ? "" : "hidden md:hidden"} ml-2 h-full w-full border-slate-100`}
>
<Card className="h-full rounded-md w-full">
<div className="px-2 h-full flex flex-col">
<div className="self-center w-full">
<div className="flex justify-between items-center">
Expand All @@ -64,7 +80,7 @@ const Page = () => {
<div className="text-xl ml-3 hover:underline">@copilot</div>
</div>
<div className=" flex">
<Card className=" h-auto my-2 flex justify-center items-center">
<Card className=" h-auto hidden md:flex my-2 justify-center items-center">
<Button
variant="ghost"
className="flex rounded-bl-xl border-r rounded-tl-xl rounded-br-none rounded-tr-none"
Expand All @@ -78,12 +94,40 @@ const Page = () => {
<Video />
</Button>
</Card>
<Button variant="ghost" className="my-2 ml-3 px-1">
<MoreVertical />
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="my-2 ml-3 px-1">
<MoreVertical />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuLabel>Chat setting</DropdownMenuLabel>
<DropdownMenuSeparator />
<Button
variant={"ghost"}
className="mx-0 w-full"
onClick={() => setMsg([])}
>
<DropdownMenuItem className="w-full">
Clean chat
<DropdownMenuShortcut>⌘⇧C</DropdownMenuShortcut>
</DropdownMenuItem>
</Button>
<Link href="/chat">
<Button
variant={"ghost"}
className="mx-0 w-full"
onClick={() => setMsg([])}
>
<DropdownMenuItem className="w-full">
Close
</DropdownMenuItem>
</Button>
</Link>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
{/* <hr className="border-r border-input mb-1" /> */}
</div>
<div className=" overflow-y-auto flex-1">
<Chats istypeing={istypeing} messages={msg} />
Expand All @@ -102,6 +146,7 @@ const Page = () => {
onChange={(e) => setPromt(e.target.value)}
value={promt}
autoFocus
required
/>
<Button type="submit">Send</Button>
</form>
Expand Down
Loading

0 comments on commit ca0625f

Please sign in to comment.