Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ dependencies = [
'uvicorn[standard] == 0.30.6',
'dataclasses_json == 0.6.7',
'websockets == 13.1',
'langchain-community',
'langchain-openai',
'markdown',
'chromadb',
'langchain-chroma',
]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion src/hackingBuddyGPT/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .configurable import Configurable, configurable
from .configurable import Configurable, configurable, parameter
from .console import *
from .db_storage import *
from .llm_util import *
Expand Down
52 changes: 40 additions & 12 deletions src/hackingBuddyGPT/utils/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,64 @@
import dataclasses
import inspect
import os
from dataclasses import dataclass
from dataclasses import dataclass, Field, MISSING, _MISSING_TYPE
from types import NoneType
from typing import Any, Dict, Type, TypeVar, Set, Union
from typing import Any, Dict, Type, TypeVar, Set, Union, Optional, overload

from dotenv import load_dotenv

load_dotenv()


T = TypeVar("T")


@overload
def parameter(
*,
desc: str,
default: T = ...,
init: bool = True,
repr: bool = True,
hash: Optional[bool] = None,
compare: bool = True,
metadata: Optional[Dict[str, Any]] = ...,
kw_only: Union[bool, _MISSING_TYPE] = MISSING,
) -> T:
...

@overload
def parameter(
*,
desc: str,
default=dataclasses.MISSING,
default: T = ...,
init: bool = True,
repr: bool = True,
hash=None,
hash: Optional[bool] = None,
compare: bool = True,
metadata: Dict = None,
kw_only: bool = dataclasses.MISSING,
):
metadata: Optional[Dict[str, Any]] = ...,
kw_only: Union[bool, _MISSING_TYPE] = MISSING,
) -> Field[T]:
...

def parameter(
*,
desc: str,
default: T = MISSING,
init: bool = True,
repr: bool = True,
hash: Optional[bool] = None,
compare: bool = True,
metadata: Optional[Dict[str, Any]] = None,
kw_only: Union[bool, _MISSING_TYPE] = MISSING,
) -> Field[T]:
if metadata is None:
metadata = dict()
metadata["desc"] = desc

return dataclasses.field(
default=default,
default_factory=dataclasses.MISSING,
default_factory=MISSING,
init=init,
repr=repr,
hash=hash,
Expand Down Expand Up @@ -109,7 +140,7 @@ def create():
instance = self.type(**args)
if hasattr(instance, "init") and not getattr(self.type, "__transparent__", False):
instance.init()
setattr(instance, "configurable_recreate", create)
setattr(instance, "configurable_recreate", create) # noqa: B010
return instance

return create()
Expand Down Expand Up @@ -228,9 +259,6 @@ def inner(cls) -> Configurable:
return inner


T = TypeVar("T")


def Global(subclass: T, global_name: str = None) -> T:
class Cloned(subclass):
__global__ = True
Expand Down