Skip to content

holidaynate/Ai-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Hub

Multi-AI Aggregator with tabs, E2EE, and biometrics.

Credits

All open-source under MIT license for app store compliance.

Pinecone integration (added)

This project includes optional Pinecone vector store integration for embeddings search (cosine similarity, 1536 dimensions). The branch add/pinecone-support adds:

  • .env.example
  • src/lib/pinecone.ts (server-side helper)
  • src/pages/api/pinecone.ts (Next.js server-side proxy)

Environment variables

Add these env vars to your local .env and to Vercel (Production/Preview as appropriate). Do NOT store the API key in client-side code.

PINECONE_API_KEY=your-pinecone-api-key-here
PINECONE_BASE_URL=https://ai-hub-12ilmwx.svc.aped-4627-b74a.pinecone.io
PINECONE_INDEX=ai-hub-index
PINECONE_DIMENSIONS=1536
PINECONE_METRIC=cosine

Creating the Pinecone index

You must create an index in the Pinecone console or via the controller API with:

  • dimension: 1536
  • metric: cosine
  • name: ai-hub-index (or set PINECONE_INDEX to your name)

Example controller curl (replace API key and desired index name):

export PINECONE_API_KEY="your-key"
curl -X POST "https://controller.us-east-1.pinecone.io/databases" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ai-hub-index",
    "dimension": 1536,
    "metric": "cosine"
  }'

Notes:

  • If your Pinecone project is serverless, prefer creating the index in the Pinecone console.
  • Ensure the index status is READY before upserting/querying.

How to upsert vectors (server-side)

Use the helper in src/lib/pinecone.ts or the API proxy at /api/pinecone.

Example using the API proxy (client -> server):

  • Client POST /api/pinecone with JSON:
{
  "path": "/vectors/upsert",
  "body": {
    "vectors": [
      { "id": "example-1", "values": [0.0, 0.0, ... 1536 numbers ...], "metadata": {"source":"doc"} }
    ]
  }
}
  • Server will forward to Pinecone using the Api-Key in server env.

Direct curl to index host (server-side only, requires Api-Key):

curl -X POST "https://ai-hub-12ilmwx.svc.aped-4627-b74a.pinecone.io/vectors/upsert" \
  -H "Content-Type: application/json" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -d '{
    "vectors": [
      { "id": "example-1", "values": [0.0, 0.0, ... 1536 numbers ...], "metadata": {"source":"doc"} }
    ]
  }'

How to query vectors

Query via the helper or the API proxy.

Client -> server example: POST /api/pinecone body:

{
  "path": "/query",
  "body": {
    "topK": 5,
    "vector": [0.0, 0.0, ...1536 numbers...],
    "includeMetadata": true,
    "includeValues": false
  }
}

Server-side curl (for debugging):

curl -X POST "https://ai-hub-12ilmwx.svc.aped-4627-b74a.pinecone.io/query" \
  -H "Content-Type: application/json" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -d '{
    "topK": 5,
    "vector": [0.0, 0.0, ...1536 numbers...],
    "includeMetadata": true,
    "includeValues": false
  }'

Vercel troubleshooting checklist

If you see errors on Vercel deployments (like the deployments you referenced), check the following:

  1. Environment variables:
    • Ensure PINECONE_API_KEY, PINECONE_BASE_URL, PINECONE_INDEX, PINECONE_DIMENSIONS are set for the deployment type (Production/Preview).
    • After changing env vars, re-deploy.
  2. Server vs client:
    • Do not call the Pinecone host directly from client-side code. Use /api/pinecone to keep the key secret.
  3. Common errors and fixes:
    • 401 Unauthorized or 403 Forbidden: API key missing or invalid.
    • 404 Not Found calling /vectors/upsert or /query: wrong BASE_URL or path.
    • 400 / 422 mentioning vector length: your vector length does not equal 1536.
    • CORS errors in browser console: client calling Pinecone directly (move to server).
  4. Inspect Vercel logs:
    • Vercel Dashboard -> Projects -> Select project -> Deployments -> select deployment -> Logs/Functions.
    • Look for server errors and full stack traces; paste them here and I’ll analyze line-by-line.

Quick local test (curl)

Use curl from a machine to confirm authentication and host connectivity:

# small auth/network test (vector must be 1536 length for a full request)
curl -s -X POST "https://ai-hub-12ilmwx.svc.aped-4627-b74a.pinecone.io/query" \
  -H "Content-Type: application/json" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -d '{
    "topK": 1,
    "vector": [0.0, 0.0, ...1536 numbers...],
    "includeMetadata": false,
    "includeValues": false
  }'

Security & best practices

  • Never put PINECONE_API_KEY in browser code or public repo.
  • Use Vercel Secrets or Environment variables for Production keys.
  • Use namespaces in Pinecone if you need logical separation.
  • Confirm embedding model outputs 1536 dims; otherwise recreate index with correct dimension.

Next steps I can take for you

  • Push these files to branch add/pinecone-support and open a PR (done by this commit).
  • Inspect Vercel logs if you paste the full stack trace(s) from the deployments you referenced and I’ll diagnose errors line-by-line.

About

Ai and cloud aggregator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published