Revert "clean up"

This reverts commit bc4ac2ceb4.
This commit is contained in:
Xi Yan 2024-09-21 12:42:08 -07:00
parent cbd4fa6044
commit ee77431b64
4 changed files with 36 additions and 28 deletions

View file

@ -389,7 +389,12 @@ def main(yaml_config: str, port: int = 5000, disable_ipv6: bool = False):
cprint(f"StackRunConfig: {config}", "blue")
app = FastAPI()
# check if routing table exists
if config.provider_routing_table is not None:
impls, specs = asyncio.run(resolve_impls_with_routing(config))
else:
# keeping this for backwards compatibility
impls, specs = asyncio.run(resolve_impls(config.provider_map))
if Api.telemetry in impls:
setup_logger(impls[Api.telemetry])

View file

@ -33,6 +33,7 @@ async def instantiate_provider(
assert isinstance(provider_config, GenericProviderConfig)
config_type = instantiate_class_type(provider_spec.config_class)
print("!!!", provider_config)
config = config_type(**provider_config.config)
args = [config, deps]
elif isinstance(provider_spec, RouterProviderSpec):

View file

@ -128,35 +128,36 @@ class PGVectorMemoryAdapter(Memory):
self.cache = {}
async def initialize(self) -> None:
try:
self.conn = psycopg2.connect(
host=self.config.host,
port=self.config.port,
database=self.config.db,
user=self.config.user,
password=self.config.password,
)
self.cursor = self.conn.cursor()
print("Init PGVector!")
# try:
# self.conn = psycopg2.connect(
# host=self.config.host,
# port=self.config.port,
# database=self.config.db,
# user=self.config.user,
# password=self.config.password,
# )
# self.cursor = self.conn.cursor()
version = check_extension_version(self.cursor)
if version:
print(f"Vector extension version: {version}")
else:
raise RuntimeError("Vector extension is not installed.")
# version = check_extension_version(self.cursor)
# if version:
# print(f"Vector extension version: {version}")
# else:
# raise RuntimeError("Vector extension is not installed.")
self.cursor.execute(
"""
CREATE TABLE IF NOT EXISTS metadata_store (
key TEXT PRIMARY KEY,
data JSONB
)
"""
)
except Exception as e:
import traceback
# self.cursor.execute(
# """
# CREATE TABLE IF NOT EXISTS metadata_store (
# key TEXT PRIMARY KEY,
# data JSONB
# )
# """
# )
# except Exception as e:
# import traceback
traceback.print_exc()
raise RuntimeError("Could not connect to PGVector database server") from e
# traceback.print_exc()
# raise RuntimeError("Could not connect to PGVector database server") from e
async def shutdown(self) -> None:
pass

View file

@ -68,7 +68,8 @@ class FaissMemoryImpl(Memory):
self.config = config
self.cache = {}
async def initialize(self) -> None: ...
async def initialize(self) -> None:
print("INIT meta-reference")
async def shutdown(self) -> None: ...