Skip to content

Commit cd1c3b8

Browse files
committed
fix: added proxy api for suggested questions
Signed-off-by: Kannav02 <[email protected]>
1 parent 4970d52 commit cd1c3b8

File tree

1 file changed

+86
-0
lines changed
  • frontend/nextjs-frontend/app/api/suggestedQuestions

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { NextResponse } from "next/server";
2+
3+
export async function POST(request: Request) {
4+
const { latestQuestion, assistantAnswer } = await request.json();
5+
const prompt = `If the assistant answer has sufficient knowledge, use it to predict the next 3 suggested questions. Otherwise, strictly restrict to these topics: Given the list of topics related to OpenROAD, suggest 3 relevant questions strictly focused on any of the given topics.
6+
Getting Started with OpenROAD
7+
Building OpenROAD
8+
Getting Started with the OpenROAD Flow - OpenROAD-flow-scripts
9+
Tutorials
10+
Git Quickstart
11+
Man pages
12+
OpenROAD User Guide
13+
Database
14+
GUI
15+
Partition Management
16+
Restructure
17+
Floorplan Initialization
18+
Pin Placement
19+
Chip-level Connections
20+
Macro Placement
21+
Hierarchical Macro Placement
22+
Tapcell Insertion
23+
PDN Generation
24+
Global Placement
25+
Gate Resizing
26+
Detailed Placement
27+
Clock Tree Synthesis
28+
Global Routing
29+
Antenna Checker
30+
Detailed Routing
31+
Metal Fill
32+
Parasitics Extraction
33+
Messages Glossary
34+
Getting Involved
35+
Developer's Guide
36+
Coding Practices
37+
Logger
38+
CI
39+
README Format
40+
Tcl Format
41+
Man pages Test Framework
42+
Code of Conduct
43+
FAQs
44+
45+
Your response must be in this exact JSON format:
46+
{
47+
"questions": [
48+
"",
49+
"",
50+
""
51+
]
52+
}
53+
The first character should be '{' and the last character should be '}'. Do not include any additional text or formatting.`;
54+
55+
try {
56+
const response = await fetch(
57+
`https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=${process.env.GEMINI_API_KEY}`,
58+
{
59+
method: 'POST',
60+
headers: {
61+
'Content-Type': 'application/json',
62+
},
63+
body: JSON.stringify({
64+
contents: [
65+
{
66+
parts: [
67+
{
68+
text: `${prompt}\n\nUser Question: ${latestQuestion}\n\nAssistant Answer: ${assistantAnswer}`,
69+
},
70+
],
71+
},
72+
],
73+
}),
74+
}
75+
);
76+
77+
const data = await response.json();
78+
return NextResponse.json(data);
79+
} catch (error) {
80+
console.error('Error in API route:', error);
81+
return NextResponse.json(
82+
{ error: 'An error occurred while processing your request' },
83+
{ status: 500 }
84+
);
85+
}
86+
}

0 commit comments

Comments
 (0)