diff --git a/.env.example b/.env.example index ebfe2ec..8028231 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,6 @@ GITHUB_TOKEN=YOUR_GITHUB_TOKEN # 2. Permissions: repo, user # 3. Generate token # 4. Copy token -# 5. Paste token in .env.local \ No newline at end of file +# 5. Paste token in .env.local + +API="api key" # your gemini api key \ No newline at end of file diff --git a/ai/generateTagline.js b/ai/generateTagline.js index 5b6083e..b825b83 100644 --- a/ai/generateTagline.js +++ b/ai/generateTagline.js @@ -1,6 +1,6 @@ const { GoogleGenerativeAI } = require("@google/generative-ai"); -const genAI = new GoogleGenerativeAI(process.env.API_enter_here); +const genAI = new GoogleGenerativeAI(process.env.API); const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" }); export async function generateUserTagline(username, contributions) { @@ -8,15 +8,19 @@ export async function generateUserTagline(username, contributions) { Generate a custom tagline for the GitHub user "${username}" based on the following activity and contribution patterns: - Total Contributions: ${contributions.totalCommitContributions} - Active Coding Days: ${contributions.contributionCalendar.totalContributions} - - Most Used Programming Languages: ${topLanguages} - The tagline should be consistent, meaningful, and provide an at-a-glance summary of the user's work. + The tagline should be consistent, meaningful, and provide an at-a-glance summary of the user's work.. + Only generate one tagline, only one. `; try { const result = await model.generateContent(prompt); + console.log("AI"); + + console.log(result.response.text()); + if (result.response) { - return result.response.text; + return result.response.text(); } else { throw new Error("Tagline not found in the response"); } diff --git a/components/Home.jsx b/components/Home.jsx index 6a7664d..7a82d21 100644 --- a/components/Home.jsx +++ b/components/Home.jsx @@ -19,6 +19,8 @@ function Home() { body: JSON.stringify({ username: username.trim() }), }); + console.log(response) + if (response.ok) { const data = await response.json(); console.log(data); diff --git a/package-lock.json b/package-lock.json index a3b6e42..13f694a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5057,4 +5057,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 3afbafb..76a0e7d 100644 --- a/package.json +++ b/package.json @@ -25,4 +25,4 @@ "postcss": "^8", "tailwindcss": "^3.4.1" } -} +} \ No newline at end of file diff --git a/src/app/[username]/page.jsx b/src/app/[username]/page.jsx index 50b23ac..f5fd7ad 100644 --- a/src/app/[username]/page.jsx +++ b/src/app/[username]/page.jsx @@ -1,8 +1,7 @@ 'use client'; -import { generateUserTagline } from "../../../ai/generateTagline"; import { useSearchParams, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; -import {contributions} from '../api/ai/route' +import axios from "axios"; function UserPage({ params }) { const { username } = params; @@ -19,6 +18,19 @@ function UserPage({ params }) { if (colorParam) setTextColor(decodeURIComponent(colorParam)); }, [searchParams]); + const [tagline, setTagline] = useState(""); + + const fetchTagline = async()=>{ + const res = await axios.post(`http://localhost:3000/api/ai`, { + username + }) + + setTagline(res.data.tagline); + } + useEffect(()=>{ + fetchTagline() + },[]) + const handleThemeChange = (e) => { const newTheme = e.target.value; setTheme(newTheme); @@ -36,8 +48,6 @@ function UserPage({ params }) { router.push(`/${username}${queryString}`); }; - const tagline=generateUserTagline(username,contributions); - return (