-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial asset collection implementation from selim call
- Loading branch information
Showing
8 changed files
with
222 additions
and
18 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,13 @@ | ||
from typing import Any | ||
from abc import ABC, abstractmethod | ||
|
||
class BaseProcessor(ABC): | ||
@abstractmethod | ||
def is_available(self) -> bool: | ||
"""Check if the processor is available (dependencies installed).""" | ||
pass | ||
|
||
@abstractmethod | ||
async def process(self, content: str) -> Any: | ||
"""Process the content.""" | ||
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,10 @@ | ||
import random | ||
from typing import List | ||
from backend.processors.BaseProcessor import BaseProcessor | ||
|
||
class SimpleEmbedder(BaseProcessor): | ||
def is_available(self) -> bool: | ||
return True | ||
|
||
async def process(self, chunks: List[str]) -> List[List[float]]: | ||
return [[random.random() for _ in range(100)] for _ in chunks] |
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,10 @@ | ||
from typing import List | ||
from backend.processors.BaseProcessor import BaseProcessor | ||
|
||
class SimpleTextSplitter(BaseProcessor): | ||
def is_available(self) -> bool: | ||
return True | ||
|
||
async def process(self, content: str) -> List[str]: | ||
return [content[i:i+1000] for i in range(0, len(content), 1000)] | ||
|
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,12 @@ | ||
from typing import List | ||
from backend.processors.BaseProcessor import BaseProcessor | ||
|
||
class SimpleVectorStore(BaseProcessor): | ||
def __init__(self): | ||
self.store = {} | ||
|
||
def is_available(self) -> bool: | ||
return True | ||
|
||
async def process(self, asset_id: str, chunks: List[str], embeddings: List[List[float]]): | ||
self.store[asset_id] = list(zip(chunks, embeddings)) |
Empty file.
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