Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
a75901c
1
Parent(s):
c97aadf
refactor: adjust database setup call
Browse files
main.py
CHANGED
|
@@ -355,8 +355,7 @@ def setup_database():
|
|
| 355 |
logger.error(f"Setup error: {e}")
|
| 356 |
|
| 357 |
|
| 358 |
-
#
|
| 359 |
-
setup_database()
|
| 360 |
|
| 361 |
|
| 362 |
class QueryResult(BaseModel):
|
|
@@ -406,9 +405,10 @@ async def search_datasets(
|
|
| 406 |
collection = client.get_collection(
|
| 407 |
name="dataset_cards", embedding_function=get_embedding_function()
|
| 408 |
)
|
| 409 |
-
|
|
|
|
| 410 |
results = collection.query(
|
| 411 |
-
query_texts=[
|
| 412 |
n_results=k * 4 if sort_by != "similarity" else k,
|
| 413 |
where={
|
| 414 |
"$and": [
|
|
|
|
| 355 |
logger.error(f"Setup error: {e}")
|
| 356 |
|
| 357 |
|
| 358 |
+
# Setup database is called in lifespan, not here
|
|
|
|
| 359 |
|
| 360 |
|
| 361 |
class QueryResult(BaseModel):
|
|
|
|
| 405 |
collection = client.get_collection(
|
| 406 |
name="dataset_cards", embedding_function=get_embedding_function()
|
| 407 |
)
|
| 408 |
+
task_description = "Given a search query, retrieve relevant model and dataset summaries that match the query. "
|
| 409 |
+
query = f"Instruct: {task_description}\nQuery:{query}"
|
| 410 |
results = collection.query(
|
| 411 |
+
query_texts=[query],
|
| 412 |
n_results=k * 4 if sort_by != "similarity" else k,
|
| 413 |
where={
|
| 414 |
"$and": [
|