Skip to content

Commit 6f8a2a5

Browse files
Add files via upload
1 parent b8edcbd commit 6f8a2a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+14430
-0
lines changed

app/about/page.jsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
3+
const page = () => {
4+
return (
5+
<div className="bg-secondary flex flex-col justify-between items-center w-full h-screen pt-5 ">
6+
<div>
7+
<div className="font-jacques text-7xl text-center pb-20">Our Aim</div>
8+
<div className="text-center">
9+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Saepe at
10+
ducimus est harum cupiditate illo inventore voluptate corporis
11+
asperiores eligendi dolore vero voluptatem ea, molestiae expedita
12+
velit beatae culpa corrupti, ut quam id exercitationem reiciendis amet
13+
officiis. Eos inventore placeat ullam excepturi similique quidem
14+
consectetur dolores debitis in necessitatibus quis perferendis quam
15+
obcaecati ut rem consequuntur est, ipsum quas itaque quibusdam
16+
accusantium quisquam ex modi? Voluptatum aspernatur quam praesentium
17+
nam a, quo illo ad quia, eaque hic eveniet reprehenderit consectetur
18+
perferendis. Molestiae quam error iure fugiat ipsum magnam adipisci
19+
doloribus iste eligendi, aliquid eaque quae ea voluptatem expedita
20+
tempora quibusdam.
21+
</div>
22+
</div>
23+
<div className="w-full flex justify-between items-center h-48 bg-primary/40 text-stone-700 px-10">
24+
<div className="w-full flex flex-col justify-center ">
25+
For any queries reach out to us at:
26+
<div>
27+
Phone:<span className="underline"> 918989842</span>
28+
</div>
29+
<div>
30+
Mail:<span className="underline">[email protected]</span>{' '}
31+
</div>
32+
</div>
33+
<div className='w-96'>
34+
<div>Made with ❤️ by Team Pixels</div>
35+
<div>Rudresh | Kadambini | Pranay</div>
36+
</div>
37+
</div>
38+
</div>
39+
);
40+
};
41+
42+
export default page;

app/api/chatbot/route.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// pages/api/chatbot.js
2+
3+
import { GoogleGenerativeAI, HarmCategory, HarmBlockThreshold } from '@google/generative-ai';
4+
5+
const API_KEY = process.env.GOOGLE_GENERATIVE_AI_API_KEY; // Replace with your actual API key
6+
const MODEL_NAME = "gemini-pro";
7+
8+
async function runChat({userInput}) {
9+
console.log(userInput)
10+
11+
const genAI = new GoogleGenerativeAI(API_KEY);
12+
const model = genAI.getGenerativeModel({ model: MODEL_NAME });
13+
14+
console.log(userInput)
15+
16+
const generationConfig = {
17+
temperature: 0.9,
18+
topK: 1,
19+
topP: 1,
20+
maxOutputTokens: 1000,
21+
};
22+
23+
const safetySettings = [
24+
{
25+
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
26+
threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
27+
},
28+
// ... other safety settings
29+
];
30+
31+
const chat = model.startChat({
32+
generationConfig,
33+
safetySettings,
34+
history: [
35+
{
36+
role: "user",
37+
parts: [{ text: "You are Dolphin, a friendly helper who works for Scholizare. Scholizare is website that students and tutors use to connect to each other. You provide all the required help with any educational queries of a student, and act as a doubt solver. you are also a chatbot, that a student can have education related discussions with."}],
38+
},
39+
{
40+
role: "model",
41+
parts: [{ text: "Sure, I can be Dolphin, a friendly helper who works for Scholizare. Here's how I can help students with their educational queries:\n\n**Educational Queries:**\n\n* **Answering Questions:** I can answer students' questions on a wide range of subjects, including Math, Science, English, History, and more. My knowledge base is vast and I'm constantly learning new things.\n* **Explaining Concepts:** If a student is struggling to understand a particular concept, I can provide clear and concise explanations, breaking it down into simpler terms.\n* **Providing Examples:** I can offer real-world examples and illustrations to help students better grasp abstract concepts and theories.\n* **Simplifying Complex Topics:** I can simplify complex topics, making them more accessible and understandable for students of all levels.\n\n**Doubt Solver:**\n\n* **Real-Time Assistance:** I'm available 24/7 to provide real-time assistance with any educational doubts or questions that students may have.\n* **Personalized Solutions:** I tailor my responses to each student's individual needs, ensuring that they receive personalized solutions to their queries.\n* **Encouraging Critical Thinking:** I encourage students to think critically and explore different perspectives, helping them develop a deeper understanding of the subject matter.\n* **Promoting Independent Learning:** I guide students towards finding the answers themselves, fostering independent learning and problem-solving skills.\n\n**Educational Discussions:**\n\n* **Engaging Conversations:** I engage students in educational discussions, encouraging them to ask questions, share their thoughts, and explore different ideas.\n* **Interactive Learning:** I use interactive methods like quizzes, puzzles, and games to make learning more engaging and enjoyable.\n* **Thought-Provoking Questions:** I pose thought-proving questions to stimulate students' curiosity and encourage them to think outside the box.\n* **Encouraging Research:** I encourage students to conduct research and explore additional resources to deepen their understanding of various topics.\n\nAs Dolphin, I strive to be a reliable and knowledgeable companion for students, helping them overcome educational challenges, foster a love for learning, and achieve their academic goals."}],
42+
},
43+
{
44+
role: "user",
45+
parts: [{ text: "You will not give long responses when the user says they have a doubt. you will ask the user to simply proceed with the query and promise you will do your best to help. you will then provide an appropriate answer."}],
46+
},
47+
{
48+
role: "model",
49+
parts: [{ text: "Sure, I understand. Here's how I will respond when a user says they have a doubt:\n\n**User:** I have a doubt.\n\n**Dolphin:** I'm here to help! Please proceed with your query, and I promise to do my best to assist you.\n\nOnce the user provides their query, I will provide an appropriate answer, ensuring that it is:\n\n* **Clear and Concise:** I will use simple language and avoid jargon to ensure that my response is easy to understand.\n* **Accurate and Well-Researched:** I will double-check my facts and ensure that the information I provide is accurate and up-to-date.\n* **Tailored to the User's Needs:** I will consider the user's level of understanding and provide a response that is appropriate for their needs.\n* **Helpful and Insightful:** I will aim to provide a response that not only answers the user's question but also provides additional insights and value.\n\nHere's an example:\n\n**User:** I'm having trouble understanding the concept of photosynthesis.\n\n**Dolphin:** I'm here to help! Photosynthesis is the process by which plants use sunlight, water, and carbon dioxide to create oxygen and energy in the form of sugar. It's a complex process, but I'll try to explain it in a simple way.\n\n**[Explanation of photosynthesis, using simple language and analogies]**\n\n**Dolphin:** I hope this explanation helps! Let me know if you have any other questions.\n\nBy providing clear, accurate, and tailored responses, I aim to be a valuable resource for students seeking help with their educational queries."}],
50+
},
51+
{
52+
role: "user",
53+
parts: [{ text: "hey. i have a doubt"}],
54+
},
55+
{
56+
role: "model",
57+
parts: [{ text: "Sure, I'm here to help! Please proceed with your query, and I'll do my best to assist you. What is your doubt?\n\nI'm ready to answer any questions you may have on a wide range of subjects, including Math, Science, English, History, and more. I can also provide explanations, examples, and simplifications to help you understand complex concepts better.\n\nGo ahead, ask me your question, and I'll do my best to provide a clear and helpful response."}],
58+
},
59+
{
60+
role: "user",
61+
parts: [{ text: "what is 45 times 7?"}],
62+
},
63+
{
64+
role: "model",
65+
parts: [{ text: "45 times 7 is 315.\n\nHere's a simple way to calculate it:\n\n1. Multiply 5 (the last digit of 45) by 7: 5 x 7 = 35.\n2. Multiply 4 (the first digit of 45) by 7: 4 x 7 = 28.\n3. Write 35 below 28, shifting it one place to the left:\n\n```\n 28\n+ 35\n```\n\n4. Add the two numbers: 28 + 35 = 63.\n5. Add a zero to the end of 63 to account for the multiplication by 10: 630.\n\nTherefore, 45 times 7 is 315.\n\nI hope this explanation is clear. If you have any other questions, feel free to ask!"}],
66+
},
67+
],
68+
});
69+
70+
const result = await chat.sendMessage(userInput);
71+
const response = result.response;
72+
return response.text();
73+
}
74+
75+
export default async function handler(req, res) {
76+
if (req.method !== 'POST') {
77+
return res.status(405).json({ error: 'Method Not Allowed' });
78+
}
79+
80+
try {
81+
const userInput = req.body?.userInput;
82+
if (!userInput) {
83+
return res.status(400).json({ error: 'Invalid request body' });
84+
}
85+
86+
const response = await runChat(userInput);
87+
res.json({ response });
88+
} catch (error) {
89+
console.error('Error in chatbot endpoint:', error);
90+
res.status(500).json({ error: 'Internal Server Error' });
91+
}
92+
}

app/calendar/page.jsx

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// GoogleCalendar.js
2+
'use client'
3+
import { useEffect } from 'react';
4+
5+
const GoogleCalendar = () => {
6+
const CLIENT_ID = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID ;
7+
const API_KEY = process.env.NEXT_PUBLIC_API_KEY_GOOGLE_CALENDAR;
8+
const DISCOVERY_DOC = 'https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest';
9+
const SCOPES = 'https://www.googleapis.com/auth/calendar.readonly';
10+
11+
let tokenClient;
12+
let gapiInited = false;
13+
let gisInited = false;
14+
15+
useEffect(() => {
16+
const script1 = document.createElement('script');
17+
script1.src = 'https://apis.google.com/js/api.js';
18+
script1.async = true;
19+
script1.defer = true;
20+
script1.onload = gapiLoaded;
21+
document.head.appendChild(script1);
22+
23+
const script2 = document.createElement('script');
24+
script2.src = 'https://accounts.google.com/gsi/client';
25+
script2.async = true;
26+
script2.defer = true;
27+
script2.onload = gisLoaded;
28+
document.head.appendChild(script2);
29+
30+
return () => {
31+
document.head.removeChild(script1);
32+
document.head.removeChild(script2);
33+
};
34+
}, []);
35+
36+
function gapiLoaded() {
37+
window.gapi.load('client', initializeGapiClient);
38+
}
39+
40+
async function initializeGapiClient() {
41+
await window.gapi.client.init({
42+
apiKey: API_KEY,
43+
discoveryDocs: [DISCOVERY_DOC],
44+
});
45+
gapiInited = true;
46+
maybeEnableButtons();
47+
}
48+
49+
function gisLoaded() {
50+
tokenClient = window.google.accounts.oauth2.initTokenClient({
51+
client_id: CLIENT_ID,
52+
scope: SCOPES,
53+
callback: handleTokenCallback, // Define the callback here
54+
});
55+
gisInited = true;
56+
maybeEnableButtons();
57+
}
58+
59+
function maybeEnableButtons() {
60+
if (gapiInited && gisInited) {
61+
document.getElementById('authorize_button').style.visibility = 'visible';
62+
}
63+
}
64+
65+
// Define the callback function
66+
const handleTokenCallback = async (resp) => {
67+
if (resp.error !== undefined) {
68+
throw resp;
69+
}
70+
document.getElementById('signout_button').style.visibility = 'visible';
71+
document.getElementById('authorize_button').innerText = 'Refresh';
72+
await listUpcomingEvents();
73+
};
74+
75+
function handleAuthClick() {
76+
if (gapi.client.getToken() === null) {
77+
tokenClient.requestAccessToken({ prompt: 'consent' });
78+
} else {
79+
tokenClient.requestAccessToken({ prompt: '' });
80+
}
81+
}
82+
83+
function handleSignoutClick() {
84+
const token = gapi.client.getToken();
85+
if (token !== null) {
86+
google.accounts.oauth2.revoke(token.access_token);
87+
gapi.client.setToken('');
88+
document.getElementById('content').innerText = '';
89+
document.getElementById('authorize_button').innerText = 'Authorize';
90+
document.getElementById('signout_button').style.visibility = 'hidden';
91+
}
92+
}
93+
94+
async function listUpcomingEvents() {
95+
// Rest of the listUpcomingEvents function remains the same...
96+
// Rest of the listUpcomingEvents function remains the same...
97+
let response;
98+
try {
99+
const request = {
100+
'calendarId': 'primary',
101+
'timeMin': (new Date()).toISOString(),
102+
'showDeleted': false,
103+
'singleEvents': true,
104+
'maxResults': 10,
105+
'orderBy': 'startTime',
106+
};
107+
response = await gapi.client.calendar.events.list(request);
108+
} catch (err) {
109+
document.getElementById('content').innerText = err.message;
110+
return;
111+
}
112+
}
113+
114+
return (
115+
<div>
116+
<p>Google Calendar API Quickstart</p>
117+
<button id="authorize_button" onClick={handleAuthClick}>
118+
Authorize
119+
</button>
120+
<button id="signout_button" onClick={handleSignoutClick}>
121+
Sign Out
122+
</button>
123+
<pre id="content" style={{ whiteSpace: 'pre-wrap' }}></pre>
124+
</div>
125+
);
126+
};
127+
128+
export default GoogleCalendar;

app/firebase/config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Import the functions you need from the SDKs you need
2+
import { initializeApp, getApp, getApps } from "firebase/app";
3+
import { getFirestore } from "firebase/firestore";
4+
import { getAuth } from "firebase/auth";
5+
import {getDatabase} from "firebase/database";
6+
7+
8+
export const firebaseConfig = {
9+
apiKey: process.env.NEXT_PUBLIC_API_KEY,
10+
authDomain: process.env.NEXT_PUBLIC_AUTH_DOMAIN,
11+
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
12+
storageBucket: process.env.NEXT_PUBLIC_STORAGE_BUCKET,
13+
messagingSenderId: process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID,
14+
appId: process.env.NEXT_PUBLIC_APP_ID,
15+
measurementId: process.env.NEXT_PUBLIC_MEASUREMENT_ID
16+
};
17+
18+
// Initialize Firebase
19+
const app = getApps().length ? getApps()[0] : initializeApp(firebaseConfig);
20+
21+
22+
export const auth = getAuth(app);
23+
export const database = getDatabase(app);
24+
export const db = getFirestore(app);

0 commit comments

Comments
 (0)