-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
93 additions
and
44 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
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,17 @@ | ||
from . import LocalBackend | ||
|
||
|
||
def main(): | ||
import os | ||
import sys | ||
|
||
## if len(sys.argv) < 2: | ||
## print(f"Usage: {os.path.basename(__file__)} <filepath>") | ||
## sys.exit(1) | ||
|
||
backend = LocalBackend() | ||
print(backend.embedding_text("gpt2", "Hello, world!")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
from .postgres import db, async_engine, async_session, init_db, init_schemas | ||
from .postgres import db, async_engine, async_session, init_db | ||
from . import schemas |
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,3 @@ | ||
from .file import File | ||
from .task import Task | ||
from .user import User |
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
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 |
---|---|---|
@@ -1,5 +1,2 @@ | ||
from .file import File | ||
from .task import Task | ||
from .user import User | ||
from .fileinfo import FileInfo | ||
|
||
__all__ = ["File", "Task", "User"] |
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,22 @@ | ||
class FileInfo: | ||
def __init__( | ||
self, | ||
fileId: str, | ||
name: str, | ||
path: str, | ||
originName: str, | ||
size: int, | ||
type: str, | ||
mimetype: str, | ||
): | ||
self.name = name | ||
self.path = path | ||
self.originName = originName | ||
self.size = size | ||
self.type = type | ||
self.mimetype = mimetype | ||
|
||
def __repr__(self): | ||
return f"<FileInfo {self.name} ({self.type})>" | ||
|
||
|
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,42 @@ | ||
import os | ||
|
||
from .fileparser.mimetype import detect | ||
from .schemas.fileinfo import FileInfo | ||
|
||
def load_file_info(filepath: str): | ||
if not os.path.exists(filepath): | ||
raise FileNotFoundError(f"File '{filepath}' does not exist") | ||
|
||
# Get file information | ||
name = os.path.basename(filepath) | ||
path = os.path.abspath(filepath) | ||
originName = name | ||
size = os.path.getsize(filepath) | ||
file_type = os.path.splitext(filepath)[1][1:] # File extension as type | ||
mimetype = detect(filepath) | ||
|
||
return FileInfo( | ||
fileId=str(os.path.getctime(filepath)), # Using creation time as fileId (or customize) | ||
name=name, | ||
path=path, | ||
originName=originName, | ||
size=size, | ||
type=file_type, | ||
mimetype=mimetype or "unknown" | ||
) | ||
|
||
def main(): | ||
import os | ||
import sys | ||
|
||
if len(sys.argv) < 2: | ||
print(f"Usage: {os.path.basename(__file__)} <filepath>") | ||
sys.exit(1) | ||
|
||
filepath = sys.argv[1] | ||
file_info = load_file_info(filepath) | ||
print(file_info) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |