inflearn logo
강의

Course

Instructor

RAG Master: From Basics to Advanced Techniques (feat. LangChain)

Gradio Chatbot Interface Implementation

Gradio 실행 시 Jinja2 / ASGI TypeError: unhashable type: 'dict' 에러 문의

3

jmg2443

2 asked

0

안녕하세요, 강의 내용대로 Gradio를 이용하여 인터페이스를 실행하려는데 아래와 같이 ASGI application 에러가 발생하며 서버가 정상 동작하지 않습니다. 어떡해야할까요?

ERROR: Exception in ASGI application Traceback (most recent call last): File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 422, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 63, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/fastapi/applications.py", line 1163, in call await super().__call__(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/applications.py", line 90, in call await self.middleware_stack(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, send) File "/opt/anaconda3/envs/langchainenv/lib/python3.11/site-packages/gradio/route_utils.py", line 761, in call await self.app(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 63, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call

...

File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/jinja2/utils.py", line 515, in getitem rv = self._mapping[key] ~~~~~~~~~~~~~^^^^^ TypeError: unhashable type: 'dict'

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Running on local URL: http://127.0.0.1:****

ERROR: Exception in ASGI application Traceback (most recent call last): File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 422, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 63, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/fastapi/applications.py", line 1163, in call await super().__call__(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/applications.py", line 90, in call await self.middleware_stack(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, send) File "/opt/anaconda3/envs/langchainenv/lib/python3.11/site-packages/gradio/route_utils.py", line 761, in call await self.app(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 63, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call

...

File "/opt/anaconda3/envs/langchain_env/lib/python3.11/site-packages/jinja2/utils.py", line 515, in getitem rv = self._mapping[key] ~~~~~~~~~~~~~^^^^^ TypeError: unhashable type: 'dict'

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

python 챗봇 llm langchain rag

Answer 1

0

communityai8509

안녕하세요, 인프런 AI 인턴입니다. jmg2443님.

Gradio 실행 시 발생하는 TypeError: unhashable type: 'dict' 에러와 관련하여 몇 가지 점검할 수 있는 사항을 안내 드리겠습니다. 이 오류는 보통 파이썬의 딕셔너리가 해시 가능한 타입으로 사용될 때 발생합니다. Gradio와 관련된 특정 설정이나 인자에서 문제가 발생하는 경우가 많습니다.

  1. Gradio 및 관련 패키지 업데이트: 사용하고 있는 Gradio 및 관련 패키지들이 최신 버전인지 확인하고, 필요 시 업데이트해 주세요. 최신 버전으로 업데이트된 패키지는 종종 기존의 버그를 수정합니다.

  2. 코드 검토: 코드 내에서 dict를 함수의 인자로 넘길 경우, 그 인자가 인식되어야 할 부분이 있는지 확인해보세요. Gradio 함수에서 dict가 쓰일 경우, structure가 올바른지 검토합니다.

  3. 호환성 문제: 특정 패키지 버전 호환성 이슈가 있을 수 있습니다. Gradio의 버전과 함께 사용하고 있는 FastAPI 또는 다른 프레임워크 및 라이브러리의 호환성을 체크해보세요.

관련하여 아래의 유사한 문제 해결 링크도 참고하면 문제 해결에 도움이 될 수 있습니다:

문제가 계속 해결되지 않는다면, 추가적인 에러 로그와 함께 구체적인 에러의 위치를 제공해주시면 더 상세한 지원이 가능할 수 있습니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

Gradio 실행 시 에러 발생 문의

0

2

1

벡터저장소 코드 실행시 경고메시지가 나타납니다.

0

40

1

예제를 좀 다양하게 해주세요. 너무 간단한 예제만 있어서 ... 좀 그렇습니다.

0

46

2

RateLimitError

0

36

2

dotenv, langchain_community 로드가 되지 않습니다.

0

37

1

테스트데이터셋 평가지표 값 문제

0

69

1

언어 감지 및 검색 라우팅

0

77

2

동영상이 검은 화면으로 나옵니다.

0

106

2

강의가 진행되지 않습니다.

0

89

2

'팀 단위 AI 업무 혁신' 자문 관련하여 문의드리고자 합니다. (연락처 요청)

0

82

1

Rerank에 대해 질문드립니다.

0

93

2

Cross Encoder Reranker 임포트 에러 관련 내용입니다.

0

138

2

HuggingFaceCrossEncoder 임포트 에러

0

121

2

아나콘다랑 pytry없이. 단순 파이참에서 venv 설정해서 설치하는건 불가능하나요?

0

101

1

2.7 전체 RAG파이프라인 구성에서 4번째 줄 오류

0

102

1

rag 와 랭체인

0

157

2

score 기반 서치

0

71

2

KR.txt파일이 없습니다.

0

98

2

krag를 이용한 검색기법 평가관련 질문

0

104

2

MMR 관련 질문입니다.

0

96

1

Text_splitter관련 질문입니다.

0

86

2

오픈api key는 따로 구매해야되는 걸까요?

0

409

2

과거 채팅이력을 LLM에 줄때 포멧

0

93

1

OpenAIEmbeddings모델이 사용하는 토크나이저는 뭘까요?

0

188

2