MCPcopy Create free account
hub / github.com/CopilotKit/aimock / classifyVectorRequest

Function classifyVectorRequest

src/vector-mock.ts:237–281  ·  view source on GitHub ↗

* Classify a vector request by operation and provider based on HTTP method and pathname.

(
  method: string,
  pathname: string,
)

Source from the content-addressed store, hash-verified

235 * Classify a vector request by operation and provider based on HTTP method and pathname.
236 */
237function classifyVectorRequest(
238 method: string,
239 pathname: string,
240): { operation: string; provider: string } {
241 // Pinecone paths
242 if (pathname === "/query" && method === "POST") {
243 return { operation: "query", provider: "pinecone" };
244 }
245 if (pathname === "/vectors/upsert" && method === "POST") {
246 return { operation: "upsert", provider: "pinecone" };
247 }
248 if (pathname === "/vectors/delete" && method === "POST") {
249 return { operation: "delete", provider: "pinecone" };
250 }
251 if (pathname === "/describe-index-stats" && method === "GET") {
252 return { operation: "describe", provider: "pinecone" };
253 }
254
255 // Qdrant paths
256 if (/^\/collections\/[^/]+\/points\/search$/.test(pathname) && method === "POST") {
257 return { operation: "query", provider: "qdrant" };
258 }
259 if (/^\/collections\/[^/]+\/points$/.test(pathname) && method === "PUT") {
260 return { operation: "upsert", provider: "qdrant" };
261 }
262 if (/^\/collections\/[^/]+\/points\/delete$/.test(pathname) && method === "POST") {
263 return { operation: "delete", provider: "qdrant" };
264 }
265
266 // ChromaDB paths
267 if (/^\/api\/v1\/collections\/[^/]+\/query$/.test(pathname) && method === "POST") {
268 return { operation: "query", provider: "chromadb" };
269 }
270 if (/^\/api\/v1\/collections\/[^/]+\/add$/.test(pathname) && method === "POST") {
271 return { operation: "upsert", provider: "chromadb" };
272 }
273 if (pathname === "/api/v1/collections" && method === "GET") {
274 return { operation: "list", provider: "chromadb" };
275 }
276 if (/^\/api\/v1\/collections\/[^/]+$/.test(pathname) && method === "DELETE") {
277 return { operation: "delete", provider: "chromadb" };
278 }
279
280 return { operation: "unknown", provider: "unknown" };
281}

Callers 1

handleRequestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…