chore: import upstream snapshot with attribution
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { VercelRequest, VercelResponse } from "@vercel/node";
|
||||
|
||||
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
||||
if (req.method !== "POST") {
|
||||
res.setHeader("Allow", "POST");
|
||||
return res.status(405).end("Method Not Allowed");
|
||||
}
|
||||
|
||||
const { query, filter } = req.body;
|
||||
|
||||
if (!query) {
|
||||
return res.status(400).json({ error: "Query is required" });
|
||||
}
|
||||
|
||||
const { SEARCH_API_WORKSPACE, SEARCH_API_PIPELINE, SEARCH_API_TOKEN } =
|
||||
process.env;
|
||||
|
||||
if (!SEARCH_API_WORKSPACE || !SEARCH_API_PIPELINE || !SEARCH_API_TOKEN) {
|
||||
console.error(
|
||||
"Search API environment variables are not configured on the server."
|
||||
);
|
||||
return res.status(500).json({ error: "Search service is not configured." });
|
||||
}
|
||||
|
||||
try {
|
||||
// Build the request body with optional filters
|
||||
const requestBody: any = {
|
||||
queries: [query],
|
||||
};
|
||||
|
||||
// Add filters if provided (for future backend filtering support)
|
||||
if (filter && filter !== "all") {
|
||||
requestBody.debug = true;
|
||||
requestBody.filters = {
|
||||
operator: "AND",
|
||||
conditions: [
|
||||
{
|
||||
field: "meta.type",
|
||||
operator: "==",
|
||||
value: filter,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const apiResponse = await fetch(
|
||||
`https://api.cloud.deepset.ai/api/v1/workspaces/${SEARCH_API_WORKSPACE}/pipelines/${SEARCH_API_PIPELINE}/search`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Client-Source": "haystack-docs",
|
||||
Authorization: `Bearer ${SEARCH_API_TOKEN}`,
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
}
|
||||
);
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
const errorData = await apiResponse.text();
|
||||
console.error("Haystack API error:", errorData);
|
||||
return res
|
||||
.status(apiResponse.status)
|
||||
.json({ error: `API error: ${apiResponse.statusText}` });
|
||||
}
|
||||
|
||||
const data = await apiResponse.json();
|
||||
return res.status(200).json(data);
|
||||
} catch (error) {
|
||||
console.error("Internal server error:", error);
|
||||
return res.status(500).json({ error: "Failed to fetch search results." });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user