Undo the unnecessary revert for the client code path

This commit is contained in:
Ashwin Bharambe 2024-12-11 15:44:55 -08:00
parent f0e045d1c8
commit 210e291c57

View file

@ -7,6 +7,7 @@ import asyncio
import json import json
import logging import logging
from typing import List from typing import List
from urllib.parse import urlparse
import chromadb import chromadb
from numpy.typing import NDArray from numpy.typing import NDArray
@ -96,7 +97,15 @@ class ChromaMemoryAdapter(Memory, MemoryBanksProtocolPrivate):
async def initialize(self) -> None: async def initialize(self) -> None:
if isinstance(self.config, ChromaRemoteImplConfig): if isinstance(self.config, ChromaRemoteImplConfig):
log.info(f"Connecting to Chroma server at: {self.config.url}") log.info(f"Connecting to Chroma server at: {self.config.url}")
self.client = await chromadb.AsyncHttpClient(url=self.config.url) url = self.config.url.rstrip("/")
parsed = urlparse(url)
if parsed.path and parsed.path != "/":
raise ValueError("URL should not contain a path")
self.client = await chromadb.AsyncHttpClient(
host=parsed.hostname, port=parsed.port
)
else: else:
log.info(f"Connecting to Chroma local db at: {self.config.db_path}") log.info(f"Connecting to Chroma local db at: {self.config.db_path}")
self.client = chromadb.PersistentClient(path=self.config.db_path) self.client = chromadb.PersistentClient(path=self.config.db_path)