Skip to content

Commit

Permalink
fix: parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelint committed Jul 1, 2024
1 parent b087b50 commit 488f78a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import Callable
from typing import Callable, Optional, Union
from langchain_openai_api_bridge.core.agent_factory import AgentFactory
from langchain_openai_api_bridge.core.utils import TinyDIContainer


class LangchainOpenaiApiBridge:
def __init__(
self,
agent_factory_provider: Callable[[], AgentFactory],
tiny_di_container: TinyDIContainer = TinyDIContainer(),
agent_factory_provider: Union[Callable[[], AgentFactory], AgentFactory],
tiny_di_container: Optional[TinyDIContainer] = None,
) -> None:
self.tiny_di_container = tiny_di_container
self.tiny_di_container = tiny_di_container or TinyDIContainer()

self.tiny_di_container.register(AgentFactory, to=agent_factory_provider)
3 changes: 2 additions & 1 deletion langchain_openai_api_bridge/core/utils/tiny_di_container.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Type, TypeVar, Dict, Any, Union, Callable
import inspect


T = TypeVar("T")


Expand All @@ -25,6 +24,8 @@ def register(
else:
self.services[cls] = service if service else implementation

self.implementations[cls] = implementation

def resolve(self, cls: Type[T]) -> T:
if cls in self.singletons:
if isinstance(self.singletons[cls], type):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from typing import Callable, Union
from fastapi import FastAPI

from langchain_openai_api_bridge.assistant.adapter.container import (
Expand Down Expand Up @@ -36,16 +36,18 @@

class LangchainOpenaiApiBridgeFastAPI(LangchainOpenaiApiBridge):
def __init__(
self, app: FastAPI, agent_factory_provider: Callable[[], AgentFactory]
self,
app: FastAPI,
agent_factory_provider: Union[Callable[[], AgentFactory], AgentFactory],
) -> None:
super().__init__(agent_factory_provider=agent_factory_provider)
self.app = app

def bind_openai_assistant_api(
self,
thread_repository_provider: Callable[[], ThreadRepository],
message_repository_provider: Callable[[], MessageRepository],
run_repository_provider: Callable[[], RunRepository],
thread_repository_provider: Union[Callable[[], ThreadRepository]],
message_repository_provider: Union[Callable[[], MessageRepository]],
run_repository_provider: Union[Callable[[], RunRepository]],
prefix: str = "",
) -> None:

Expand Down

0 comments on commit 488f78a

Please sign in to comment.