Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Chroma clientsettings is not dict #589

Open
yousenwang opened this issue Dec 20, 2023 · 0 comments
Open

[Bug]: Chroma clientsettings is not dict #589

yousenwang opened this issue Dec 20, 2023 · 0 comments

Comments

@yousenwang
Copy link

Current Behavior

(env) ➜  GPTCacheAPI npc gptcache_server -s 0.0.0.0 -p 8009 -f config.yaml
start to install package: ruamel-yaml

[notice] A new release of pip available: 22.2.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
successfully installed package: ruamel-yaml
Traceback (most recent call last):
  File "/data/python/ethan/app/GPTCacheAPI/env/bin/gptcache_server", line 8, in <module>
    sys.exit(main())
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache_server/server.py", line 178, in main
    init_conf = init_similar_cache_from_config(config_dir=args.cache_config_file)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache/adapter/api.py", line 221, in init_similar_cache_from_config
    data_manager = manager_factory(**storage_config)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache/manager/factory.py", line 98, in manager_factory
    v = VectorBase(name=vector, **vector_params)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache/manager/vector_data/__init__.py", line 13, in VectorBase
    return vector_manager.VectorBase.get(name, **kwargs)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache/manager/vector_data/manager.py", line 157, in get
    vector_base = Chromadb(
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/gptcache/manager/vector_data/chroma.py", line 45, in __init__
    self._client = chromadb.Client(self._client_settings)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/chromadb/__init__.py", line 30, in Client
    telemetry_client = system.instance(Telemetry)
  File "/data/python/ethan/app/GPTCacheAPI/env/lib/python3.10/site-packages/chromadb/config.py", line 156, in instance
    fqn = self.settings.require(key)
AttributeError: 'dict' object has no attribute 'require'

Expected Behavior

(env) ➜  GPTCacheAPI npc gptcache_server -s 0.0.0.0 -p 8009 -f config.yaml
start to install package: ruamel-yaml

[notice] A new release of pip available: 22.2.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
successfully installed package: ruamel-yaml
INFO:     Started server process [39587]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8009 (Press CTRL+C to quit)

Steps To Reproduce

No response

Environment

No response

Anything else?

embedding:
    huggingface
embedding_config:
    # Set embedding model params here
    model: BAAI/bge-large-zh-v1.5
storage_config:
    data_dir:
        gptcache_data
    manager:
        mariadb,chromadb
    scalar_params:
      sql_url: mariadb+pymysql://usr:password@host:port/name
    vector_params:
      dimension: 1024
      client_settings:
        chroma_server_host: 10.67.74.xxx
        chroma_server_http_port: 8000
        anonymized_telemetry: False
evaluation: 
    distance
evaluation_config:
    # Set evaluation metric kws here
    max_distance: 4.0
    positive: False
pre_function:
    get_prompt
post_function:
    first
config:
    similarity_threshold: 0.8
    # Set other config here
    

Here is the chatGPT answer
It looks like there is an issue with the system.instance(Telemetry) call in your code. The error message indicates that the settings object passed to the instance method is a dictionary ('dict' object has no attribute 'require'). This suggests that the settings object is not an instance of the Settings class as expected.

In your YAML file, the vector_params section includes client_settings, which seems to be a dictionary. It appears that this dictionary is being passed as settings to the Client function, causing the error.

To resolve this issue, you should construct an instance of the Settings class using the values from your YAML file before passing it to the Client function. Here's an example of how you can modify your code:

import yaml
from pydantic import BaseSettings
from typing import Optional, List, Any, Literal

# Your existing Settings class definition

def load_settings_from_yaml(yaml_path: str) -> Settings:
    with open(yaml_path, 'r') as file:
        config_data = yaml.safe_load(file)
    return Settings(**config_data)

# Usage in your main code
yaml_file_path = "path/to/your/config.yaml"
settings = load_settings_from_yaml(yaml_file_path)
api_instance = Client(settings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant