2cab53bc94
Docker Publish / Build and Push Docker Images (map[description:Skill Seekers CLI - Convert documentation to AI skills dockerfile:Dockerfile name:skill-seekers]) (push) Waiting to run
Docker Publish / Build and Push Docker Images (map[description:Skill Seekers MCP Server - 25 tools for AI assistants dockerfile:Dockerfile.mcp name:skill-seekers-mcp]) (push) Waiting to run
Docker Publish / Test Docker Images (push) Blocked by required conditions
Test Vector Database Adaptors / Test chroma Adaptor (push) Waiting to run
Test Vector Database Adaptors / Test faiss Adaptor (push) Waiting to run
Test Vector Database Adaptors / Test qdrant Adaptor (push) Waiting to run
Test Vector Database Adaptors / Test weaviate Adaptor (push) Waiting to run
Test Vector Database Adaptors / Test MCP Vector DB Tools (push) Waiting to run
Tests / Code Quality (Ruff & Mypy) (push) Waiting to run
Tests / Fast Unit Tests (parallel) (macos-latest, 3.11) (push) Waiting to run
Tests / Fast Unit Tests (parallel) (macos-latest, 3.12) (push) Waiting to run
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.10) (push) Waiting to run
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.11) (push) Waiting to run
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.12) (push) Waiting to run
Tests / Tests (push) Blocked by required conditions
Tests / Serial / Integration / E2E Tests (push) Blocked by required conditions
Tests / MCP Server Tests (push) Blocked by required conditions
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Query FAISS index"""
|
|
import json, sys, os
|
|
import numpy as np
|
|
|
|
try:
|
|
import faiss
|
|
from openai import OpenAI
|
|
from rich.console import Console
|
|
from rich.table import Table
|
|
except ImportError:
|
|
print("❌ Run: pip install -r requirements.txt")
|
|
sys.exit(1)
|
|
|
|
console = Console()
|
|
|
|
# Load index and metadata
|
|
console.print("📥 Loading FAISS index...")
|
|
index = faiss.read_index("flask.index")
|
|
|
|
with open("flask_metadata.json") as f:
|
|
data = json.load(f)
|
|
|
|
console.print(f"✅ Loaded {index.ntotal} vectors")
|
|
|
|
# Initialize OpenAI
|
|
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
|
|
def search(query_text: str, k: int = 5):
|
|
"""Search FAISS index"""
|
|
console.print(f"\n[yellow]Query:[/yellow] {query_text}")
|
|
|
|
# Generate query embedding
|
|
response = client.embeddings.create(
|
|
model="text-embedding-ada-002",
|
|
input=query_text
|
|
)
|
|
query_vector = np.array([response.data[0].embedding]).astype('float32')
|
|
|
|
# Search
|
|
distances, indices = index.search(query_vector, k)
|
|
|
|
# Display results
|
|
table = Table(show_header=True, header_style="bold magenta")
|
|
table.add_column("#", width=3)
|
|
table.add_column("Distance", width=10)
|
|
table.add_column("Category", width=12)
|
|
table.add_column("Content Preview")
|
|
|
|
for i, (dist, idx) in enumerate(zip(distances[0], indices[0]), 1):
|
|
doc = data["documents"][idx]
|
|
meta = data["metadatas"][idx]
|
|
preview = doc[:80] + "..." if len(doc) > 80 else doc
|
|
|
|
table.add_row(
|
|
str(i),
|
|
f"{dist:.2f}",
|
|
meta.get("category", "N/A"),
|
|
preview
|
|
)
|
|
|
|
console.print(table)
|
|
console.print("[dim]💡 Distance: Lower = more similar[/dim]")
|
|
|
|
# Example queries
|
|
console.print("[bold green]FAISS Query Examples[/bold green]\n")
|
|
|
|
search("How do I create a Flask route?", k=3)
|
|
search("database models and ORM", k=3)
|
|
search("authentication and security", k=3)
|
|
|
|
console.print("\n✅ All examples completed!")
|