-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for google drive input (#61)
- Loading branch information
Showing
8 changed files
with
660 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class GoogleDrive(BaseModel): | ||
service_account_key: dict = Field( | ||
..., description="The service account key for Google Drive API" | ||
) | ||
drive_id: str = Field(..., description="The ID of a File or Folder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import List | ||
|
||
from models.file import File | ||
from models.google_drive import GoogleDrive | ||
from service.embedding import EmbeddingService | ||
|
||
|
||
async def handle_urls( | ||
embedding_service: EmbeddingService, | ||
files: List[File], | ||
): | ||
embedding_service.files = files | ||
chunks = await embedding_service.generate_chunks() | ||
summary_documents = await embedding_service.generate_summary_documents( | ||
documents=chunks | ||
) | ||
return chunks, summary_documents | ||
|
||
|
||
async def handle_google_drive( | ||
_embedding_service: EmbeddingService, _google_drive: GoogleDrive | ||
): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from urllib.parse import urlparse | ||
import os | ||
|
||
|
||
def get_file_extension_from_url(url: str) -> str: | ||
""" | ||
Extracts the file extension from a given URL. | ||
""" | ||
path = urlparse(url).path | ||
ext = os.path.splitext(path)[1] | ||
return ext |