Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sing1ee committed Dec 27, 2024
1 parent 4e86d5a commit 92b645c
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 554 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

nginx.conf
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<a href="https://www.geminicoder.io">
<img alt="Gemini Coder" src="./public/logo.svg">
<h1 align="center">Gemini Coder</h1>
<a href="https://www.deepseek-coder.io">
<img alt="DeepSeek Coder" src="./public/favicon.svg">
<h1 align="center">DeepSeek Coder</h1>
</a>

<p align="center">
Generate small apps with one prompt. Powered by the Gemini API.
Generate small apps with one prompt. Powered by the DeepSeek API.
</p>

This project is fully based on [llamacoder](https://github.com/Nutlope/llamacoder). Please follow [Nutlope](https://github.com/Nutlope) and give them a star..
This project is fully based on [llamacoder](https://github.com/Nutlope/llamacoder). Please follow [Nutlope](https://github.com/Nutlope) and give them a star.

## Tech stack

- [Gemini API](https://ai.google.dev/gemini-api/docs) to use Gemini 1.5 Pro, Gemini 1.5 Flash, and Gemini 2.0 Flash Experimental
- [DeepSeek API](https://platform.deepseek.com/docs) for code generation using DeepSeek-Coder models
- [Sandpack](https://sandpack.codesandbox.io/) for the code sandbox
- Next.js app router with Tailwind

You can also experiment with Gemini in [Google AI Studio](https://aistudio.google.com/).
You can also experiment with DeepSeek models on the [DeepSeek Platform](https://platform.deepseek.com/).

## Cloning & running

1. Clone the repo: `git clone https://github.com/osanseviero/geminicoder`
2. Create a `.env` file and add your [Google AI Studio API key](https://aistudio.google.com/app/apikey): `GOOGLE_AI_API_KEY=`
1. Clone the repo: `git clone https://github.com/YOUR_USERNAME/deepseek-coder`
2. Create a `.env` file and add your [DeepSeek API key](https://platform.deepseek.com/api-keys): `DEEPSEEK_API_KEY=`
3. Run `npm install` and `npm run dev` to install dependencies and run locally

**This is a personal project and not a Google official project**
**This is a personal project and not affiliated with DeepSeek**
20 changes: 7 additions & 13 deletions app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@ export default function Home() {
let [prompt, setPrompt] = useState("");
let models = [
{
label: "gemini-2.0-flash-exp",
value: "gemini-2.0-flash-exp",
},
{
label: "gemini-1.5-pro",
value: "gemini-1.5-pro",
},
{
label: "gemini-1.5-flash",
value: "gemini-1.5-flash",
label: "deepseek-chat",
value: "deepseek-chat",
}
];
let [model, setModel] = useState(models[0].value);
Expand Down Expand Up @@ -87,7 +79,9 @@ export default function Home() {
if (done) {
break;
}
receivedData += new TextDecoder().decode(value);

let decodedText = new TextDecoder().decode(value);
receivedData += decodedText;
const cleanedData = removeCodeFormatting(receivedData);
setGeneratedCode(cleanedData);
}
Expand All @@ -109,11 +103,11 @@ export default function Home() {
<main className="mt-12 flex w-full flex-1 flex-col items-center px-4 text-center sm:mt-1">
<a
className="mb-4 inline-flex h-7 shrink-0 items-center gap-[9px] rounded-[50px] border-[0.5px] border-solid border-[#E6E6E6] bg-[rgba(234,238,255,0.65)] bg-gray-100 px-7 py-5 shadow-[0px_1px_1px_0px_rgba(0,0,0,0.25)]"
href="https://ai.google.dev/gemini-api/docs"
href="https://api-docs.deepseek.com/"
target="_blank"
>
<span className="text-center">
Powered by <span className="font-medium">Gemini API</span>
Powered by <span className="font-medium">Deepseek API</span>
</span>
</a>
<h1 className="my-6 max-w-3xl text-4xl font-bold text-gray-800 sm:text-6xl">
Expand Down
64 changes: 34 additions & 30 deletions app/api/generateCode/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import shadcnDocs from "@/utils/shadcn-docs";
import dedent from "dedent";
import { z } from "zod";
import { GoogleGenerativeAI } from "@google/generative-ai";
import { CoreMessage, streamText } from 'ai'
import shadcnDocs from "@/utils/shadcn-docs"
import dedent from "dedent"
import { z } from "zod"
import { createOpenAI as createDeepseek } from '@ai-sdk/openai';

const apiKey = process.env.GOOGLE_AI_API_KEY || "";
const genAI = new GoogleGenerativeAI(apiKey);
const deepseek = createDeepseek({
baseURL: 'https://api.deepseek.com',
apiKey: process.env.DEEPSEEK_API_KEY,
});

// Allow streaming responses up to 30 seconds
export const maxDuration = 300

export async function POST(req: Request) {
let json = await req.json();
// Validate request body
let json = await req.json()
let result = z
.object({
model: z.string(),
Expand All @@ -16,37 +23,34 @@ export async function POST(req: Request) {
z.object({
role: z.enum(["user", "assistant"]),
content: z.string(),
}),
})
),
})
.safeParse(json);
.safeParse(json)

if (result.error) {
return new Response(result.error.message, { status: 422 });
return new Response(result.error.message, { status: 422 })
}

let { model, messages, shadcn } = result.data;
let systemPrompt = getSystemPrompt(shadcn);

const geminiModel = genAI.getGenerativeModel({model: model});

const geminiStream = await geminiModel.generateContentStream(
messages[0].content + systemPrompt + "\nPlease ONLY return code, NO backticks or language names. Don't start with \`\`\`typescript or \`\`\`javascript or \`\`\`tsx or \`\`\`."
);
const { messages, shadcn } = result.data
const systemPrompt = getSystemPrompt(shadcn)

console.log(messages[0].content + systemPrompt + "\nPlease ONLY return code, NO backticks or language names. Don't start with \`\`\`typescript or \`\`\`javascript or \`\`\`tsx or \`\`\`.")

const readableStream = new ReadableStream({
async start(controller) {
for await (const chunk of geminiStream.stream) {
const chunkText = chunk.text();
controller.enqueue(new TextEncoder().encode(chunkText));
}
controller.close();
// Combine user message with system prompt
const augmentedMessages = [
{
role: 'system',
content: systemPrompt + "\n\nPlease ONLY return code, NO backticks or language names. Don't start with ```typescript or ```javascript or ```tsx or ```."
},
});
...messages
]

// Use Vercel AI SDK to stream the response
const ret = await streamText({
model: deepseek('deepseek-chat'),
messages: augmentedMessages as CoreMessage[],
})

return new Response(readableStream);
return ret.toTextStreamResponse()
}

function getSystemPrompt(shadcn: boolean) {
Expand Down Expand Up @@ -106,4 +110,4 @@ function getSystemPrompt(shadcn: boolean) {
return dedent(systemPrompt);
}

export const runtime = "edge";
export const runtime = "edge"
Binary file removed app/favicon.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions app/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import type { Metadata } from "next";
import "./globals.css";

let title = "Gemini Coder – AI Code Generator";
let description = "Generate your next app with Gemini";
let url = "https://llamacoder.io/";
let ogimage = "https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d4735304ff6292a690345.svg";
let sitename = "geminicoder.io";
let title = "Deepseek Coder – AI Code Generator";
let description = "Generate your next app with Deepseek";
let url = "https://www.deepseek.com/";
let ogimage = "/images/og-image.svg";
let sitename = "deepseek.com";

export const metadata: Metadata = {
metadataBase: new URL(url),
title,
description,
icons: {
icon: "/favicon.ico",
icon: [
{ url: '/favicon.svg', type: 'image/svg+xml' },
{ url: '/favicon.svg', type: 'image/svg+xml', sizes: '32x32' }
],
},
openGraph: {
images: [ogimage],
Expand Down
8 changes: 4 additions & 4 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export default function Footer() {
<div className="font-medium">
Built with{" "}
<a
href="https://ai.google.dev/gemini-api/docs"
href="https://api-docs.deepseek.com/"
className="font-semibold text-blue-600 underline-offset-4 transition hover:text-gray-700 hover:underline"
target="_blank"
>
Gemini API
Deepseek API
</a>{" "}
and{" "}
<a
Expand All @@ -26,7 +26,7 @@ export default function Footer() {
</div>
<div className="flex space-x-4 pb-4 sm:pb-0">
<Link
href="https://twitter.com/osanseviero"
href="https://x.com/chmilo"
className="group"
aria-label=""
target="_blank"
Expand All @@ -39,7 +39,7 @@ export default function Footer() {
</svg>
</Link>
<Link
href="https://github.com/osanseviero/geminicoder"
href="https://github.com/sing1ee/deepseekCoder"
className="group"
aria-label="TaxPal on GitHub"
target="_blank"
Expand Down
8 changes: 4 additions & 4 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Image from "next/image";
import Link from "next/link";
import logo from "../public/logo.svg";
import logo from "../public/favicon.svg";
import GithubIcon from "./github-icon";

export default function Header() {
return (
<header className="relative mx-auto mt-5 flex w-full items-center justify-center px-2 pb-7 sm:px-4">
<Link href="/" className="absolute flex items-center gap-2">
<Image alt="header text" src={logo} className="h-5 w-5" />
<Image alt="DeepseekCoder Logo" src={logo} className="h-5 w-5" />
<h1 className="text-xl tracking-tight">
<span className="text-blue-600">Gemini</span>Coder
<span className="text-blue-600">Deepseek</span>Coder
</h1>
</Link>
<a
href="https://github.com/osanseviero/geminicoder"
href="https://github.com/sing1ee/deepseekCoder"
target="_blank"
className="ml-auto hidden items-center gap-3 rounded-2xl bg-white px-6 py-2 sm:flex"
>
Expand Down
Loading

0 comments on commit 92b645c

Please sign in to comment.