Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# you can get your gemini api key from https://aistudio.google.com/app/apikey
API_KEY=your_gemini_api_key_here

VERCEL_URL="localhost:3000"
84 changes: 84 additions & 0 deletions .github/workflows/chacks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: ✨ Next.js checks

on:
push:
branches:
- "*"
pull_request:
branches: ["*"]

jobs:
lint:
runs-on: ubuntu-latest
name: pnpm lint

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2.2.4
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- run: pnpm run lint

build:
runs-on: ubuntu-latest
name: pnpm build
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2.2.4
name: Install pnpm
id: pnpm-install
with:
version: 8.6.1
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- run: pnpm run build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

.vercel
.env*.local
18 changes: 14 additions & 4 deletions utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { GoogleGenerativeAI } from "@google/generative-ai";
import { promises as fs } from "fs";

// Get your API key from https://makersuite.google.com/app/apikey
if (!process.env.API_KEY) {
throw new Error("API_KEY environment variable is required");
console.log("API_KEY environment variable is required", process.env.NODE_ENV);
console.log("node env:- ", process.env.NODE_ENV);
}

const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const genAI = new GoogleGenerativeAI(process.env.API_KEY!);

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

export const systemHistory = async () => {
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";

const systemdata = await fetch("http://localhost:3000/system.txt");
console.log("protocol", protocol);
console.log("VERCEL_URL", process.env.VERCEL_URL)

const systemdata = await fetch(
`${protocol}://${process.env.VERCEL_URL}/system.txt`
);
const systemText = await systemdata.text();

if (systemText) {
console.log("is systemText", true);
}

return [
{
role: "user",
Expand Down