
마지막 과제 부분 기본코드 넣고 실행해 보았는데
TypeError: argument of type 'bool' is not iterable
ERROR: Exception in ASGI application
위 오류나면서 무한루프가 걸립니다.
작성한 코드 및 에러 메세지
!pip install gradio==4.44.0 pdfplumber==0.11.4 sentence-transformers==3.0.1 openai==1.57.2 pdf2image==1.17.0 azure-cognitiveservices-vision-computervision==0.9.0 opencv-contrib-python==4.10.0.84 -q
!apt-get install -y poppler-utils
# 기본 뼈대 코드
# 필요한 라이브러리 불러오기
from sentence_transformers import SentenceTransformer
import gradio as gr
import openai
import torch
import pickle
import pdfplumber
from pdf2image import convert_from_path
from azure.cognitiveservices.vision.computervision import ComputerVisionClient
from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes
from msrest.authentication import CognitiveServicesCredentials
import cv2
import io
import time
import os
# Azure API 인증 정보 설정
SUBSCRIPTION_KEY = ""
ENDPOINT_URL = ""
computervision_client = ComputerVisionClient(ENDPOINT_URL, CognitiveServicesCredentials(SUBSCRIPTION_KEY))
# OpenAI 인증 정보 설정
API_KEY = ""
openai_client = openai.Client(api_key=API_KEY)
# Sentence-Transformers를 활용한 텍스트 임베딩 과정
embedder = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
def create_embeddings(chunks):
embeddings = embedder.encode(chunks, convert_to_tensor=True) # 청크들을 임베딩하여 텐서로 변환합니다.
return embeddings # 임베딩된 벡터들을 반환합니다.
# 청크와 임베딩 데이터를 파일로 저장하는 함수
STATE_PATH = "./state/"
# 디렉터리가 없으면 생성
if not os.path.exists(STATE_PATH):
os.makedirs(STATE_PATH)
def save_state(chunks, embeddings):
with open(os.path.join(STATE_PATH, "state.pkl"), "wb") as f: # 'state.pkl' 파일을 쓰기 모드로 엽니다.
pickle.dump({"chunks": chunks, "embeddings": embeddings}, f) # 청크와 임베딩을 파일에 저장합니다.
# 이미지에서 텍스트 추출 (OCR) 함수
def detect_text_from_image(image_path):
image_data = open(image_path, "rb").read()
sbuf = io.BytesIO(image_data)
# API 호출하여 이미지를 처리
response = computervision_client.read_in_stream(sbuf, raw=True)
operation_location = response.headers["Operation-Location"]
operation_id = operation_location.split("/")[-1]
# 대기 시간 추가
time.sleep(1)
# API 작업 완료까지 대기 (폴링 방식으로 상태 확인)
while True:
read_result = computervision_client.get_read_result(operation_id)
if read_result.status not in ['notStarted', 'running']:
break
time.sleep(1)
raw_text = ""
if read_result.status == OperationStatusCodes.succeeded:
for result in read_result.analyze_result.read_results:
for line in result.lines:
raw_text += line.text + "\n"
return raw_text
# -- PDF 파일에서 텍스트 추출하는 함수를 작성해주세요. -- #
def extract_text_from_pdf(file_path):
text = ""
return text
# 오버래핑 청킹 함수
def chunk_text(text, chunk_size=128, overlap=64):
words = text.split() # 입력된 텍스트를 단어 단위로 나눕니다.
chunks = [] # 결과로 저장할 청크 리스트를 초기화합니다.
for i in range(0, len(words), chunk_size - overlap): # 청크의 시작 지점을 반복합니다. 각 청크는 겹침(overlap)을 고려해 설정합니다.
chunk = ' '.join(words[i:i + chunk_size]) # 해당 위치에서 청크 크기만큼 단어를 결합하여 하나의 청크를 만듭니다.
chunks.append(chunk) # 생성한 청크를 리스트에 추가합니다.
return chunks # 모든 청크를 담은 리스트를 반환합니다.
# 코사인 유사도를 사용해 검색하는 함수
def retrieve_relevant_chunks(query, chunks, embeddings, top_k=5):
query_embedding = embedder.encode(query, convert_to_tensor=True) # 입력된 질문을 임베딩합니다.
query_embedding = query_embedding / torch.norm(query_embedding) # 쿼리 임베딩을 정규화합니다.
embeddings = embeddings / torch.norm(embeddings, dim=1, keepdim=True) # 모든 청크 임베딩을 정규화합니다.
similarities = torch.matmul(embeddings, query_embedding.T).squeeze() # 각 청크 임베딩과 쿼리 임베딩 간의 유사도를 계산합니다.
top_k_indices = torch.topk(similarities, top_k).indices.tolist() # 가장 유사한 청크 N개의 인덱스를 추출합니다.
relevant_chunks = [chunks[i] for i in top_k_indices] # 해당 인덱스에 해당하는 청크들을 반환합니다.
return '\n\n'.join(relevant_chunks) # 청크들을 하나의 텍스트로 합쳐서 반환합니다.
# pdf 파일 처리 및 데이터 저장 함수
def process_pdf(pdf_file):
# 디렉터리가 없으면 생성
if not os.path.exists(STATE_PATH):
os.makedirs(STATE_PATH)
# PDF 파일에서 텍스트를 추출하고, 청크와 임베딩을 생성하여 저장
text = extract_text_from_pdf(pdf_file)
chunks = chunk_text(text) # 텍스트를 청크로 나눔
embeddings = create_embeddings(chunks) # 청크를 임베딩으로 변환
# 청크와 임베딩을 저장
with open(os.path.join(STATE_PATH, "state.pkl"), "wb") as f:
pickle.dump({"chunks": chunks, "embeddings": embeddings}, f)
return "PDF processed and embeddings saved."
# openAI api 를 통한 답변 생성 함수
def generate_answer(relevant_text, history_openai_format, query):
system_prompt = """Your main task is to generate answer of a given question, based on the given base knowledge text.
Avoid using knowledge outside of given text.
"""
history_openai_format.append({'role':'system', 'content':system_prompt})
history_openai_format.append({'role':'user', 'content': f"Based on the following text:\n\n{relevant_text}\n\nAnswer the question: {query}"})
response = openai_client.chat.completions.create(
model="gpt-4o",
messages=history_openai_format,
max_tokens=1024
)
return response.choices[0].message.content
# 저장된 데이터에서 관련 텍스트를 검색하고 답변을 생성하는 함수
def answer_question(query, history):
# Load chunks and embeddings from file
with open(os.path.join(STATE_PATH, "state.pkl"), "rb") as f:
data = pickle.load(f)
chunks = data["chunks"]
embeddings = data["embeddings"]
relevant_text = retrieve_relevant_chunks(query, chunks, embeddings)
history_openai_format = []
for human, assistant in history:
history_openai_format.append({'role':'user', 'content':human})
history_openai_format.append({'role':'assistant', 'content':assistant})
answer = generate_answer()
return answer
# Gradio UI 구성 부분
pdf_input = gr.File(label="Upload your PDF", type="filepath")
with gr.Blocks() as demo:
gr.Markdown("## 제품 문의 챗봇")
with gr.Tab('step 1: upload '):
pdf_interface = gr.Interface(
fn = process_pdf,
inputs = pdf_input,
outputs = 'text'
)
with gr.Tab('step 2: Ask Question'):
question_interface = gr.ChatInterface(
fn = answer_question,
textbox = gr.Textbox(placeholder = '질문이 있으신가요?',
container = False,
scale = 7)
).queue()
demo.launch(share = True, debug = True)
에러 부분
/usr/local/lib/python3.11/dist-packages/sentence_transformers/cross_encoder/CrossEncoder.py:11: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
from tqdm.autonotebook import tqdm, trange
/usr/local/lib/python3.11/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning:
The secret `HF_TOKEN` does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
warnings.warn(
modules.json: 100%
349/349 [00:00<00:00, 20.8kB/s]
config_sentence_transformers.json: 100%
116/116 [00:00<00:00, 10.8kB/s]
README.md: 100%
10.5k/10.5k [00:00<00:00, 1.04MB/s]
sentence_bert_config.json: 100%
53.0/53.0 [00:00<00:00, 5.31kB/s]
config.json: 100%
612/612 [00:00<00:00, 64.9kB/s]
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
WARNING:huggingface_hub.file_download:Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
model.safetensors: 100%
90.9M/90.9M [00:00<00:00, 226MB/s]
tokenizer_config.json: 100%
350/350 [00:00<00:00, 27.8kB/s]
vocab.txt: 100%
232k/232k [00:00<00:00, 12.4MB/s]
tokenizer.json: 100%
466k/466k [00:00<00:00, 7.60MB/s]
special_tokens_map.json: 100%
112/112 [00:00<00:00, 11.5kB/s]
config.json: 100%
190/190 [00:00<00:00, 13.2kB/s]
/usr/local/lib/python3.11/dist-packages/gradio/analytics.py:106: UserWarning: IMPORTANT: You are using gradio version 4.44.0, however version 4.44.1 is available, please upgrade.
--------
warnings.warn(
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.11/dist-packages/gradio/route_utils.py", line 761, in __call__
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/starlette/concurrency.py", line 37, in run_in_threadpool
return await anyio.to_thread.run_sync(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 967, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 431, in main
gradio_api_info = api_info(False)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 460, in api_info
app.api_info = app.get_blocks().get_api_info()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/blocks.py", line 2786, in get_api_info
python_type = client_utils.json_schema_to_python_type(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 893, in json_schema_to_python_type
type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 947, in _json_schema_to_python_type
des = [
^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 948, in <listcomp>
f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 955, in _json_schema_to_python_type
f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 901, in _json_schema_to_python_type
type_ = get_type(schema)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 863, in get_type
if "const" in schema:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'bool' is not iterable
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.11/dist-packages/gradio/route_utils.py", line 761, in __call__
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/starlette/concurrency.py", line 37, in run_in_threadpool
return await anyio.to_thread.run_sync(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 967, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 431, in main
gradio_api_info = api_info(False)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 460, in api_info
app.api_info = app.get_blocks().get_api_info()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/blocks.py", line 2786, in get_api_info
python_type = client_utils.json_schema_to_python_type(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 893, in json_schema_to_python_type
type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 947, in _json_schema_to_python_type
des = [
^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 948, in <listcomp>
f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 955, in _json_schema_to_python_type
f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 901, in _json_schema_to_python_type
type_ = get_type(schema)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 863, in get_type
if "const" in schema:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'bool' is not iterable
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.11/dist-packages/gradio/route_utils.py", line 761, in __call__
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/dist-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/fastapi/routing.py", line 214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/starlette/concurrency.py", line 37, in run_in_threadpool
return await anyio.to_thread.run_sync(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/anyio/_backends/_asyncio.py", line 967, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 431, in main
gradio_api_info = api_info(False)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/routes.py", line 460, in api_info
app.api_info = app.get_blocks().get_api_info()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio/blocks.py", line 2786, in get_api_info
python_type = client_utils.json_schema_to_python_type(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 893, in json_schema_to_python_type
type_ = _json_schema_to_python_type(schema, schema.get("$defs"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 947, in _json_schema_to_python_type
des = [
^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 948, in <listcomp>
f"{n}: {_json_schema_to_python_type(v, defs)}{get_desc(v)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 955, in _json_schema_to_python_type
f"str, {_json_schema_to_python_type(schema['additionalProperties'], defs)}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 901, in _json_schema_to_python_type
type_ = get_type(schema)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gradio_client/utils.py", line 863, in get_type
if "const" in schema:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'bool' is not iterable
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-2-28684e9b9336> in <cell line: 0>()
194
195
--> 196 demo.launch(share = True, debug = True)
1 frames
/usr/local/lib/python3.11/dist-packages/gradio/networking.py in url_ok(url)
62 if r.status_code in (200, 401, 302): # 401 or 302 if auth is set
63 return True
---> 64 time.sleep(0.500)
65 except (ConnectionError, httpx.ConnectError, httpx.TimeoutException):
66 return False
KeyboardInterrupt:
