Spaces:
Sleeping
Sleeping
bertugmirasyedi
commited on
Overhaul
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
3 |
|
4 |
# Define the FastAPI app
|
5 |
app = FastAPI(docs_url="/")
|
@@ -191,6 +192,8 @@ def search(
|
|
191 |
descriptions = []
|
192 |
images = []
|
193 |
|
|
|
|
|
194 |
# Set the OpenAI API key
|
195 |
openai.api_key = "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"
|
196 |
|
@@ -455,30 +458,26 @@ def search(
|
|
455 |
runtime = f"{end_time - start_time:.2f} seconds"
|
456 |
|
457 |
# Create a list of dictionaries to store the results
|
458 |
-
results = [
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
"
|
473 |
-
"
|
474 |
-
"
|
475 |
-
"
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
"total_runtime": runtime,
|
480 |
-
}
|
481 |
-
for i in range(len(combined_data))
|
482 |
-
]
|
483 |
|
484 |
return results
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
4 |
|
5 |
# Define the FastAPI app
|
6 |
app = FastAPI(docs_url="/")
|
|
|
192 |
descriptions = []
|
193 |
images = []
|
194 |
|
195 |
+
# Set the OpenAI API key
|
196 |
+
openai.api_key = "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"
|
197 |
# Set the OpenAI API key
|
198 |
openai.api_key = "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"
|
199 |
|
|
|
458 |
runtime = f"{end_time - start_time:.2f} seconds"
|
459 |
|
460 |
# Create a list of dictionaries to store the results
|
461 |
+
results = []
|
462 |
+
for i in range(len(titles)):
|
463 |
+
results.append(
|
464 |
+
{
|
465 |
+
"id": i,
|
466 |
+
"title": titles[i],
|
467 |
+
"author": authors[i],
|
468 |
+
"publisher": publishers[i],
|
469 |
+
"image_link": images[i],
|
470 |
+
"labels": classes[i]["labels"][0:2],
|
471 |
+
"label_confidences": classes[i]["scores"][0:2],
|
472 |
+
"summary": summaries[i][0]["summary_text"],
|
473 |
+
"similar_books": similar_books[i]["sorted_by_similarity"],
|
474 |
+
"runtime": {
|
475 |
+
"total": runtime,
|
476 |
+
"classification": classification_time,
|
477 |
+
"summarization": summarization_time,
|
478 |
+
"similarity": similarity_time,
|
479 |
+
},
|
480 |
+
}
|
481 |
+
)
|
|
|
|
|
|
|
|
|
482 |
|
483 |
return results
|