inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Phát triển ứng dụng LLM sử dụng RAG (feat. LangChain)

3.2 Xây dựng RAG sử dụng LangChain và Chroma

🚨 python3.14 를 쓰고 계시면 chroma 에서 ConfigError 가 발생합니다.

200

nrudev

16 câu hỏi đã được viết

1

---------------------------------------------------------------------------
ConfigError                               Traceback (most recent call last)
Cell In[13], line 1
----> 1 from langchain_chroma import Chroma
      3 database = Chroma.from_documents(documents=document_list, embedding=embedding)

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/langchain_chroma/__init__.py:3
      1 """LangChain integration for Chroma vector database."""
----> 3 from langchain_chroma.vectorstores import Chroma
      5 __all__ = [
      6     "Chroma",
      7 ]

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/langchain_chroma/vectorstores.py:18
     12 from pathlib import Path
     13 from typing import (
     14     TYPE_CHECKING,
     15     Any,
     16 )
---> 18 import chromadb
     19 import chromadb.config
     20 import numpy as np

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/chromadb/__init__.py:3
      1 from typing import Dict, Optional, Union
      2 import logging
----> 3 from chromadb.api.client import Client as ClientCreator
      4 from chromadb.api.client import (
      5     AdminClient as AdminClientCreator,
      6 )
      7 from chromadb.api.async_client import AsyncClient as AsyncClientCreator

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/chromadb/api/__init__.py:51
     46 from overrides import override
     47 from chromadb.api.collection_configuration import (
     48     CreateCollectionConfiguration,
     49     UpdateCollectionConfiguration,
     50 )
---> 51 from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT
     52 from chromadb.api.types import (
     53     CollectionMetadata,
     54     Documents,
   (...)     73     DefaultEmbeddingFunction,
     74 )
     76 from chromadb.auth import UserIdentity

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/chromadb/config.py:120
    116     NODE = "node"
    117     ID = "id"
--> 120 class Settings(BaseSettings):  # type: ignore
    121     # ==============
    122     # Generic config
    123     # ==============
    125     environment: str = ""
    127     # Can be "chromadb.api.segment.SegmentAPI" or "chromadb.api.fastapi.FastAPI" or "chromadb.api.rust.RustBindingsAPI"

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/pydantic/v1/main.py:221, in ModelMetaclass.__new__(mcs, name, bases, namespace, **kwargs)
    219 elif is_valid_field(var_name) and var_name not in annotations and can_be_changed:
    220     validate_field_name(bases, var_name)
--> 221     inferred = ModelField.infer(
    222         name=var_name,
    223         value=value,
    224         annotation=annotations.get(var_name, Undefined),
    225         class_validators=vg.get_validators(var_name),
    226         config=config,
    227     )
    228     if var_name in fields:
    229         if lenient_issubclass(inferred.type_, fields[var_name].type_):

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/pydantic/v1/fields.py:504, in ModelField.infer(cls, name, value, annotation, class_validators, config)
    501     required = False
    502 annotation = get_annotation_from_field_info(annotation, field_info, name, config.validate_assignment)
--> 504 return cls(
    505     name=name,
    506     type_=annotation,
    507     alias=field_info.alias,
    508     class_validators=class_validators,
    509     default=value,
    510     default_factory=field_info.default_factory,
    511     required=required,
    512     model_config=config,
    513     field_info=field_info,
    514 )

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/pydantic/v1/fields.py:434, in ModelField.__init__(self, name, type_, class_validators, model_config, default, default_factory, required, final, alias, field_info)
    432 self.shape: int = SHAPE_SINGLETON
    433 self.model_config.prepare_field(self)
--> 434 self.prepare()

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/pydantic/v1/fields.py:544, in ModelField.prepare(self)
    537 def prepare(self) -> None:
    538     """
    539     Prepare the field but inspecting self.default, self.type_ etc.
    540 
    541     Note: this method is **not** idempotent (because _type_analysis is not idempotent),
    542     e.g. calling it it multiple times may modify the field and configure it incorrectly.
    543     """
--> 544     self._set_default_and_type()
    545     if self.type_.__class__ is ForwardRef or self.type_.__class__ is DeferredType:
    546         # self.type_ is currently a ForwardRef and there's nothing we can do now,
    547         # user will need to call model.update_forward_refs()
    548         return

File ~/workspace/ai/rag-practice/lib/python3.14/site-packages/pydantic/v1/fields.py:576, in ModelField._set_default_and_type(self)
    573     self.annotation = self.type_
    575 if self.type_ is Undefined:
--> 576     raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
    578 if self.required is False and default_value is None:
    579     self.allow_none = True

ConfigError: unable to infer type for attribute "chroma_server_nofile"

저는 Python 3.14 버전으로 venv 를 사용중이었는데요.
위와 같은 에러가 발생하였습니다.
구글에 ConfigError 문구를 검색해도 잘 나오지 않아서 ChatGPT의 도움을 좀 받았는데 이렇게 답하더라구요.

- Python 3.14 환경에서 chromadb가 (pydantic v2에서 BaseSettings가 빠진 걸 처리하려다) pydantic.v1 호환 레이어로 떨어지고

- 그런데 Pydantic v1 코어는 Python 3.14+에서 제대로 동작하지 않아서, Settings 모델 필드(chroma_server_nofile) 타입 추론이 깨지면서 ConfigError가 납니다.

파이썬 버전을 3.12로 낮추어서 venv 를 다시 설정했더니 같은 코드임에도 정상적으로 실행되었습니다.
혹시나 저와 같은 이슈를 겪으신 분들은 python 버전을 낮추어보시길 바라요.

vector-database llm langchain rag openai-api 지금-베스트

Câu trả lời 1

0

jasonkang

좋은 내용 공유해주셔서 감사합니다! 자주 묻는 질문에 등록해두었습니다

소득세법 docx 파일 공유 요청건

0

65

1

EXAONE 모델 불러오기 안되는 문제

0

89

2

[5.1 강의] LLM Evaluator에 Upstage를 사용하는 방법 + 변경된 Langsmith Docs를 참고하여 구현하는 방법 공유

0

106

2

강의 9에 QA관련된 import가 되지 않네요

0

111

2

강의와 책 관련 질문

0

87

1

문서 전처리 고민

0

111

1

RAG 배포 질문드립니다

0

95

1

강의 내용과는 별개로 궁금한 점이 있습니다

0

89

2

폐쇄망 챗봇 모델

0

94

1

AI agent 쿠폰

0

95

2

저는 왜 그대로 했는데 답변이 틀리게 나오는지 모르겠네요

0

102

2

langchain howto/sequence는 지금 doc 공식 사이트 어디서 확인할 수 있나요?

1

95

1

new_question에 대한 답 출력

0

75

2

랭체인 라이브러리

0

148

2

[LangGraph를 활용한 AI Agent 개발] 쿠폰 유효기간

0

107

1

postgresql의 pgvector 벡터는 어떤가요?

0

345

2

doc관련

0

128

2

load_dotenv() 실행 False

0

96

1

RAG 답변 개선을 위한 정답지 활용 구조 검토 요청

0

119

2

3.2 from langchain.chains ~ 에서 모듈을 찾지 못할 때.

1

406

2

강의 완료 오류

0

89

1

hub.pull 이슈

0

131

2

[3.3 강의] Upstage를 사용한 RAG 구현 성공기 공유

1

150

1

RAG 문서 관리 방법

0

108

2