Compare commits
3 Commits
66a2d647bb
...
feat/backe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37c07e468d | ||
|
|
3539a5f3eb | ||
|
|
26d879c82e |
6
.env.example
Normal file
6
.env.example
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comparaison
|
||||||
|
BETTER_AUTH_SECRET=change-me-to-random-string
|
||||||
|
OPENAI_API_KEY=
|
||||||
|
PERPLEXITY_API_KEY=
|
||||||
|
TAVILY_API_KEY=
|
||||||
|
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,6 +32,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files (can opt-in for committing if needed)
|
||||||
.env*
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ import type {
|
|||||||
ItemResearch,
|
ItemResearch,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
|
|
||||||
const client = new OpenAI({
|
let _client: OpenAI | null = null;
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
|
||||||
});
|
function getClient(): OpenAI {
|
||||||
|
if (!_client) {
|
||||||
|
_client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
||||||
|
}
|
||||||
|
return _client;
|
||||||
|
}
|
||||||
|
|
||||||
const SYSTEM_PROMPT = `You are an expert research analyst. Your job is to compare items across multiple dimensions and produce structured, insightful comparison data.
|
const SYSTEM_PROMPT = `You are an expert research analyst. Your job is to compare items across multiple dimensions and produce structured, insightful comparison data.
|
||||||
|
|
||||||
@@ -105,7 +110,7 @@ Provide a comprehensive comparison with scores, pros/cons, and a recommendation.
|
|||||||
|
|
||||||
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
||||||
try {
|
try {
|
||||||
const response = await client.chat.completions.create({
|
const response = await getClient().chat.completions.create({
|
||||||
model: "gpt-4o-mini",
|
model: "gpt-4o-mini",
|
||||||
messages: [
|
messages: [
|
||||||
{ role: "system", content: SYSTEM_PROMPT },
|
{ role: "system", content: SYSTEM_PROMPT },
|
||||||
|
|||||||
Reference in New Issue
Block a user