Spaces:
Runtime error
Runtime error
File size: 992 Bytes
c8fa3bd ae9d4c8 c8fa3bd 43843dc c8fa3bd 6505613 c8fa3bd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from typing import List
# Adjust the import path as needed
from backend.app.database.supabase_client import supabase
def get_questions_by_similarity_range(query_embedding):
vector_str = "[" + ",".join(map(str, query_embedding)) + "]"
query = f"""
SELECT
id,
title,
url,
content,
original_content,
paid_only,
difficulty,
topictags,
LEAST(
GREATEST(
ROUND(
((1 - (embedding <=> '{vector_str}')) * 100)::numeric,
2
),
0
),
100
) AS match_percentage
FROM problems_bge
ORDER BY embedding <=> '{vector_str}'
"""
result = supabase.rpc('exec_sql', {"sql": query}).execute()
if result.data:
return result.data
else:
raise Exception(f"Query failed: {result}")
|