-
Notifications
You must be signed in to change notification settings - Fork 46
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
16 changed files
with
612 additions
and
819 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
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,13 +1,9 @@ | ||
from concurrent.futures import ProcessPoolExecutor | ||
from fastapi import Header, Query | ||
from fastapi.security import APIKeyHeader | ||
from multiprocessing import Manager | ||
|
||
|
||
def api_service_dependency(secret: str = Header(...), key: str = Query(...), timestamp: str = Query(...)): | ||
... # do some validation or processing with the headers | ||
|
||
|
||
process_pool_executor = ProcessPoolExecutor() | ||
process_manager = Manager() | ||
user_dependency = APIKeyHeader(name="Authorization", auto_error=False) | ||
USER_DEPENDENCY = APIKeyHeader(name="Authorization", auto_error=False) |
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 concurrent.futures import ProcessPoolExecutor | ||
from dataclasses import dataclass, field | ||
from multiprocessing import Manager | ||
from multiprocessing.managers import SyncManager | ||
|
||
import openai | ||
from app.common.config import OPENAI_API_KEY, SingletonMetaClass | ||
from langchain.embeddings import OpenAIEmbeddings | ||
|
||
|
||
@dataclass | ||
class Shared(metaclass=SingletonMetaClass): | ||
process_manager: SyncManager = field(default_factory=Manager) | ||
process_pool_executor: ProcessPoolExecutor = field(default_factory=ProcessPoolExecutor) | ||
openai_embeddings: OpenAIEmbeddings = field( | ||
default_factory=lambda: OpenAIEmbeddings(client=openai.Embedding, openai_api_key=OPENAI_API_KEY) | ||
) |
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
Oops, something went wrong.