Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3cf05d7
Install @vercel/og and created route for OG image responce
Rohittomar01 Apr 13, 2024
02a3708
in layout page mata data content url changed and lint fixed
Rohittomar01 Apr 13, 2024
f4d71f0
content="https://echoes-git-og-image-tcr.vercel.app/api/og"
Rohittomar01 Apr 13, 2024
eb3fb00
For check use external image
Rohittomar01 Apr 13, 2024
744a5ad
https://www.echoes.team/api/og changed and lint fix
Rohittomar01 Apr 13, 2024
b0ab4fb
create metadata in chat page
Rohittomar01 Apr 14, 2024
08dd9a4
use metadata tag in layout or page
Rohittomar01 Apr 14, 2024
44606fb
used generatemetadata function
Rohittomar01 Apr 14, 2024
9ab6523
changed the url of image
Rohittomar01 Apr 14, 2024
fb30a73
I tried to generate dynamic title
Rohittomar01 Apr 14, 2024
39dd6a2
created image same like mockup
Rohittomar01 Apr 15, 2024
320595f
made route public
Rohittomar01 Apr 15, 2024
39f6d78
chnaged the layout og image url
Rohittomar01 Apr 15, 2024
f5def55
removed this https//www.echoes.team from page and layout.tsx
Rohittomar01 Apr 15, 2024
25190d9
tried to make route title dynamically
Rohittomar01 Apr 15, 2024
4fa2331
tried to check chat is and chat slug page meta data
Rohittomar01 Apr 15, 2024
18a9dee
uncomment data in layout.tsx
Rohittomar01 Apr 15, 2024
4980b34
I fetched title with some logic
Rohittomar01 Apr 15, 2024
669de3f
commented layout metadata
Rohittomar01 Apr 15, 2024
079bafc
uncommented layout metadata
Rohittomar01 Apr 15, 2024
e7c25b0
changed something in image metadata
Rohittomar01 Apr 16, 2024
ffeeada
changed this publicRoutes: ["/"],
Rohittomar01 Apr 16, 2024
d4445b3
again rechanged
Rohittomar01 Apr 16, 2024
ee3026b
commentted layout metadata
Rohittomar01 Apr 16, 2024
218a02a
uncomment the layout metadata
Rohittomar01 Apr 16, 2024
d1db993
gave static title in layout tsx
Rohittomar01 Apr 16, 2024
fb30fd6
made public this /dashboard/user
Rohittomar01 Apr 16, 2024
6c21f7c
applied org logo
Rohittomar01 Apr 16, 2024
e120345
add this line in middleware publicRoutes: ["/api/og", "/*"],
Rohittomar01 Apr 16, 2024
8f9e6e8
rechanged publicRoutes: ["/api/og", "/"],
Rohittomar01 Apr 16, 2024
a25a021
used tailwind css instead style element
Rohittomar01 Apr 16, 2024
5c76334
just for title check
Rohittomar01 Apr 16, 2024
dc72067
created robots.txt file
Rohittomar01 Apr 17, 2024
22d82c5
changes in robots.txt User-agent: * Allow: /
Rohittomar01 Apr 17, 2024
61ceff2
created robots.ts
Rohittomar01 Apr 17, 2024
62f4197
changed the allow path in robots allow: "/dashboard/[slug]/chat…
Rohittomar01 Apr 17, 2024
64fa141
changed path again allow: "/dashboard/[slug]/chat/[chatid]",
Rohittomar01 Apr 17, 2024
c09c76c
chnaged in robost.ts allow:"*", // Allow crawling by any bot
Rohittomar01 Apr 17, 2024
935802d
add more url to allow
Rohittomar01 Apr 17, 2024
ee9af15
again replace
Rohittomar01 Apr 17, 2024
01af17c
lint fixed
Rohittomar01 Apr 17, 2024
a512247
added canonical in page.tsx
Rohittomar01 Apr 18, 2024
83d5dac
lint fixed
Rohittomar01 Apr 22, 2024
f82820c
implemented assistant api file routes (delete,create,list)
Rohittomar01 Apr 22, 2024
2569562
developed routes for assistant (create,delete,list)
Rohittomar01 Apr 23, 2024
45e32b1
fixed lint
Rohittomar01 Apr 23, 2024
4215d48
created message list route and connect , run route
Rohittomar01 Apr 25, 2024
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@uidotdev/usehooks": "^2.4.1",
"@uploadthing/react": "5.2.0",
"@upstash/redis": "^1.24.3",
"@vercel/og": "^0.6.2",
"ably": "^1.2.48",
"ai": "2.2.20",
"algoliasearch": "^4.20.0",
Expand Down
28 changes: 28 additions & 0 deletions src/app/api/assistantApi/createAssistant/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { env } from "@/app/env.mjs";

export async function GET() {
const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const assistant = await openai.beta.assistants.create({
instructions: `
You are a professional stock analyst.
I will ask you questions about the stock market and you will answer them.
You can use the documents I provide to you to help you answer the questions.
If you're not 100% sure of the answer, you can say "I don't know".
`,
name: "Mini Stock Analyst",
tools: [{ type: "retrieval" }],
model: "gpt-4-1106-preview",
});

console.log("assiatnt:", assistant);

return NextResponse.json({ assistant: assistant });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
25 changes: 25 additions & 0 deletions src/app/api/assistantApi/deleteAssistant/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { env } from "@/app/env.mjs";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const assistantId = searchParams.get("assistantId");

if (!assistantId) {
return NextResponse.json({ error: "No id provided" }, { status: 400 });
}

const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const response = await openai.beta.assistants.del(assistantId);
console.log(response);

return NextResponse.json(response);
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
23 changes: 23 additions & 0 deletions src/app/api/assistantApi/listAssistant/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import OpenAI from "openai";
import { env } from "@/app/env.mjs";
import { NextResponse } from "next/server";

export async function GET() {
const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const response = await openai.beta.assistants.list({
order: "desc",
limit: 10,
});

const assistants = response.data;

console.log(assistants);

return NextResponse.json({ assistants: assistants });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
34 changes: 34 additions & 0 deletions src/app/api/assistantFile/deleteFile/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const assistantId = searchParams.get("assistantId");
const fileId = searchParams.get("fileId");

if (!assistantId)
return NextResponse.json(
{ error: "No assistant id provided" },
{ status: 400 },
);

if (!fileId)
return NextResponse.json({ error: "No file id provided" }, { status: 400 });

const openai = new OpenAI();

try {
const deletedFile = await openai.beta.assistants.files.del(
assistantId,
fileId,
);

console.log(deletedFile);

return NextResponse.json(deletedFile);
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
24 changes: 24 additions & 0 deletions src/app/api/assistantFile/listFile/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const assistantId = searchParams.get("assistantId");

if (!assistantId)
return NextResponse.json({ error: "No id provided" }, { status: 400 });

const openai = new OpenAI();

try {
const assistantFiles = await openai.beta.assistants.files.list(assistantId);

console.log(assistantFiles);

return NextResponse.json({ assistantFiles });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
36 changes: 36 additions & 0 deletions src/app/api/assistantFile/uploadFile/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const assistantId = searchParams.get("assistantId");
const fileId = searchParams.get("fileId");

if (!assistantId)
return NextResponse.json(
{ error: "No assistant id provided" },
{ status: 400 },
);

if (!fileId)
return NextResponse.json({ error: "No file id provided" }, { status: 400 });

const openai = new OpenAI();

try {
const assistantFile = await openai.beta.assistants.files.create(
assistantId,
{
file_id: fileId,
},
);

console.log(assistantFile);

return NextResponse.json({ assistantFile: assistantFile });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
36 changes: 36 additions & 0 deletions src/app/api/assistantRun/createRun/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { env } from "@/app/env.mjs";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const threadId = searchParams.get("threadId");
const assistantId = searchParams.get("assistantId");

if (!threadId)
return NextResponse.json(
{ error: "No thread id provided" },
{ status: 400 },
);
if (!assistantId)
return NextResponse.json(
{ error: "No assistant id provided" },
{ status: 400 },
);

const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const run = await openai.beta.threads.runs.create(threadId, {
assistant_id: assistantId,
});

console.log({ run: run });

return NextResponse.json({ run: run });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
17 changes: 17 additions & 0 deletions src/app/api/assistantThread/createThread/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { env } from "@/app/env.mjs";

export async function GET() {
const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const thread = await openai.beta.threads.create();
console.log(thread);

return NextResponse.json({ thread: thread });
} catch (e) {
console.log(e);
return NextResponse.json({ error: e });
}
}
27 changes: 27 additions & 0 deletions src/app/api/messagesThread/createMessages/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { NextRequest } from "next/server";
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { env } from "@/app/env.mjs";

export async function POST(req: NextRequest) {
const { message, threadId } = await req.json();

if (!threadId || !message)
return NextResponse.json({ error: "Invalid message" }, { status: 400 });

const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

try {
const threadMessage = await openai.beta.threads.messages.create(threadId, {
role: "user",
content: message,
});

console.log("threadMessage", threadMessage);

return NextResponse.json({ status: 200, message: threadMessage });
} catch (e) {
console.log(e);
return NextResponse.json({ status: 500, error: e });
}
}
22 changes: 22 additions & 0 deletions src/app/api/messagesThread/messagesList/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import OpenAI from "openai";
import { NextResponse } from "next/server";
import { NextRequest } from "next/server";
import { env } from "@/app/env.mjs";

const openai = new OpenAI({ apiKey: env.OPEN_AI_API_KEY });

export async function POST(req: NextRequest) {
try {
const { threadId } = await req.json(); // Ensure threadId is being sent in the request body
const threadMessages = await openai.beta.threads.messages.list(threadId);

console.log("Thread Messages:", threadMessages.data);
return NextResponse.json({
status: 200,
threadMessages: threadMessages.data,
});
} catch (e) {
console.log("Error:", e);
return NextResponse.json({ status: 500, error: e });
}
}
103 changes: 103 additions & 0 deletions src/app/api/og/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { ImageResponse } from "next/og";
import logo from "@/assets/logo.png";
// App router includes @vercel/og.
// No need to install it.

export const runtime = "edge";

// Gradient Square Component
function GradientSquare() {
return (
<div
style={{
width: "60px",
height: "60px",
background:
"linear-gradient(180deg, rgba(0,128,0,1) 0%, rgba(0,255,0,1) 100%)",
marginBottom: "20px",
}}
></div>
);
}

function Circle() {
return (
<div
style={{
width: "85px",
height: "85px",
backgroundColor: "green",
borderRadius: "50%",
color: "white",
display: "flex",
alignItems: "center",
justifyContent: "center",
marginBottom: "20px",
}}
>
IK
</div>
);
}

export async function GET(request: Request) {
try {
let title: string | null = "";
try {
const urlParams = new URLSearchParams(request.url.split("?")[1]);
title = urlParams.get("title");
console.log("title", title);
} catch (error) {
console.error("Error parsing URL:", error);
}
// const urlParams = new URLSearchParams(request.url.split("?")[1]); // Splitting URL to get query params
// const title = urlParams.get("title");
// console.log("title", title);

// const { searchParams } = new URL(request.url);
// console.log("searchParams", searchParams);
// const hasTitle = searchParams.has("title");
// const title01 = hasTitle
// ? searchParams.get("title")?.slice(0, 100)
// : "My default title";

return new ImageResponse(
(
<div tw="bg-black bg-cover h-screen w-full flex flex-col justify-center p-20">
<div tw="flex flex-col gap-8">
<h1 tw="text-white mb-2 text-3xl font-serif font-extrabold w-[42vw]">
{title
? title
: " The Dual Role of Tween 80 in Biofilm Formation"}
</h1>
<h2 tw="text-gray-500 font-normal font-sans text-2xl">
Inhibition and Enhancement
</h2>
</div>
<div tw="flex justify-between mt-[100px]">
<span>
<Circle />
</span>
<span>
<img
width="85"
height="85"
src={`https://www.echoes.team${logo.src}`}
/>
{/* <GradientSquare /> */}
</span>
</div>
</div>
),
{
width: 1200,
height: 630,
},
);
} catch (e: any) {
console.log(`${e.message}`);
return new Response(`Failed to generate the image`, {
status: 500,
});
}
}
Loading