Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
-
from llama_index import
|
| 5 |
from llama_index import CallbackManager
|
| 6 |
import openai
|
| 7 |
import whisper
|
|
@@ -20,7 +20,8 @@ model = whisper.load_model("large-v3")
|
|
| 20 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 21 |
|
| 22 |
# Load data
|
| 23 |
-
|
|
|
|
| 24 |
documents = reader.load_data()
|
| 25 |
|
| 26 |
# Removed Ollama and Mistral initialization
|
|
@@ -72,7 +73,9 @@ async def upload_pdf(files: List[UploadFile] = File(...)):
|
|
| 72 |
file_path = f"./{file.filename}"
|
| 73 |
with open(file_path, "wb") as f:
|
| 74 |
f.write(await file.read())
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
return {"status": "PDFs indexed successfully"}
|
| 77 |
|
| 78 |
# Chat with the LLM for summarized lecture content
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
+
from llama_index import Document, ServiceContext, download_loader
|
| 5 |
from llama_index import CallbackManager
|
| 6 |
import openai
|
| 7 |
import whisper
|
|
|
|
| 20 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 21 |
|
| 22 |
# Load data
|
| 23 |
+
SimpleDirectoryReader = download_loader('SimpleDirectoryReader')
|
| 24 |
+
reader = SimpleDirectoryReader('./data')
|
| 25 |
documents = reader.load_data()
|
| 26 |
|
| 27 |
# Removed Ollama and Mistral initialization
|
|
|
|
| 73 |
file_path = f"./{file.filename}"
|
| 74 |
with open(file_path, "wb") as f:
|
| 75 |
f.write(await file.read())
|
| 76 |
+
SimpleDirectoryReader = download_loader('SimpleDirectoryReader')
|
| 77 |
+
reader = SimpleDirectoryReader('.')
|
| 78 |
+
documents = reader.load_data()
|
| 79 |
return {"status": "PDFs indexed successfully"}
|
| 80 |
|
| 81 |
# Chat with the LLM for summarized lecture content
|