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

When using the demo for testing, an error occurred: "columns_and_tables_needed = orjson.loads orjson.JSONDecodeError: unexpected character: line 1 column 1". #1426

Open
wxp2023 opened this issue Mar 19, 2025 · 1 comment

Comments

@wxp2023
Copy link

wxp2023 commented Mar 19, 2025

My question is '‌Information of the three individuals with the highest salaries'
The log content is as follows:

I0319 06:15:48.781 8 wren-ai-service:298] db_schemas token count is greater than 100,000, so we will prune columns
INFO:     172.25.0.3:57886 - "GET /v1/asks/21ad676d-2688-4764-a9c2-f11255ddab8d/result HTTP/1.1" 200 OK
********************************************************************************
> construct_retrieval_results [src.pipelines.retrieval.retrieval.construct_retrieval_results()] encountered an error<
> Node inputs:
{'check_using_db_schemas_without_pruning': "<Task finished name='Task-581' "
                                           'coro=<AsyncGraphAda...',
 'construct_db_schemas': "<Task finished name='Task-580' "
                         'coro=<AsyncGraphAda...',
 'dbschema_retrieval': "<Task finished name='Task-579' coro=<AsyncGraphAda...",
 'filter_columns_in_tables': "<Task finished name='Task-583' "
                             'coro=<AsyncGraphAda...'}
********************************************************************************
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 122, in new_fn
    await fn(**fn_kwargs) if asyncio.iscoroutinefunction(fn) else fn(**fn_kwargs)
                                                                  ^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 256, in sync_wrapper
    self._handle_exception(observation, e)
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 520, in _handle_exception
    raise e
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 254, in sync_wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/src/pipelines/retrieval/retrieval.py", line 334, in construct_retrieval_results
    columns_and_tables_needed = orjson.loads(
                                ^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)
-------------------------------------------------------------------
Oh no an error! Need help with Hamilton?
Join our slack and ask for help! https://join.slack.com/t/hamilton-opensource/shared_invite/zt-2niepkra8-DGKGf_tTYhXuJWBTXtIs4g
-------------------------------------------------------------------
E0319 06:15:50.792 8 wren-ai-service:529] ask pipeline - OTHERS: unexpected character: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/src/web/v1/services/ask.py", line 318, in ask
    retrieval_result = await self._pipelines["retrieval"].run(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 219, in async_wrapper
    self._handle_exception(observation, e)
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 520, in _handle_exception
    raise e
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 217, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/src/pipelines/retrieval/retrieval.py", line 485, in run
    return await self._pipe.execute(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 375, in execute
    raise e
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 366, in execute
    outputs = await self.raw_execute(_final_vars, overrides, display_graph, inputs=inputs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 326, in raw_execute
    raise e
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 321, in raw_execute
    results = await await_dict_of_tasks(task_dict)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 23, in await_dict_of_tasks
    coroutines_gathered = await asyncio.gather(*coroutines)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 36, in process_value
    return await val
           ^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/hamilton/async_driver.py", line 122, in new_fn
    await fn(**fn_kwargs) if asyncio.iscoroutinefunction(fn) else fn(**fn_kwargs)
                                                                  ^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 256, in sync_wrapper
    self._handle_exception(observation, e)
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 520, in _handle_exception
    raise e
  File "/app/.venv/lib/python3.12/site-packages/langfuse/decorators/langfuse_decorator.py", line 254, in sync_wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/src/pipelines/retrieval/retrieval.py", line 334, in construct_retrieval_results
    columns_and_tables_needed = orjson.loads(
                                ^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)

The.env configuration is as follows:

COMPOSE_PROJECT_NAME=wrenai
PLATFORM=linux/amd64

PROJECT_DIR=.

# service port
WREN_ENGINE_PORT=8080
WREN_ENGINE_SQL_PORT=7432
WREN_AI_SERVICE_PORT=5555
WREN_UI_PORT=3000
IBIS_SERVER_PORT=8000
WREN_UI_ENDPOINT=http://wren-ui:${WREN_UI_PORT}

# ai service settings
QDRANT_HOST=qdrant
SHOULD_FORCE_DEPLOY=1

# vendor keys
LLM_OPENAI_API_KEY=
EMBEDDER_OPENAI_API_KEY=
LLM_AZURE_OPENAI_API_KEY=
EMBEDDER_AZURE_OPENAI_API_KEY=
QDRANT_API_KEY=

# version
# CHANGE THIS TO THE LATEST VERSION
WREN_PRODUCT_VERSION=0.16.0
WREN_ENGINE_VERSION=0.14.5
WREN_AI_SERVICE_VERSION=0.16.2
IBIS_SERVER_VERSION=0.14.5
WREN_UI_VERSION=0.21.0
WREN_BOOTSTRAP_VERSION=0.1.5

# user id (uuid v4)
USER_UUID=

# for other services
POSTHOG_API_KEY=phc_nhF32aj4xHXOZb0oqr2cn4Oy9uiWzz6CCP4KZmRq9aE
POSTHOG_HOST=https://app.posthog.com
TELEMETRY_ENABLED=true
# this is for telemetry to know the model, i think ai-service might be able to provide a endpoint to get the information
GENERATION_MODEL=gpt-4o-mini
LANGFUSE_SECRET_KEY=
LANGFUSE_PUBLIC_KEY=

# the port exposes to the host
# OPTIONAL: change the port if you have a conflict
HOST_PORT=3000
AI_SERVICE_FORWARD_PORT=5555

# Wren UI
EXPERIMENTAL_ENGINE_RUST_VERSION=false

LLM_OLLAMA_API_KEY=random
EMBEDDER_OLLAMA_API_KEY=random
EMBEDDER_OLLAMA_URL=http://132.120.139.194:11434
LLM_OLLAMA_URL=http://132.120.132.44:11434
OPENAI_API_KEY=dummy-key

The config configuration is as follows:

type: llm
provider: litellm_llm
timeout: 120
models:
- model: openai/qwen2.5:7b
  api_base: http://132.120.132.44:11434/v1
  api_key_name: LLM_OLLAMA_API_KEY
  kwargs:
    temperature: 0
    n: 1
    # for better consistency of llm response, refer: https://platform.openai.com/docs/api-reference/chat/create#chat-create-seed
#    seed: 0
#    max_tokens: 4096
- model: gpt-4o-2024-08-06
  api_base: https://api.openai.com/v1
  api_key_name: LLM_OPENAI_API_KEY
  kwargs:
    temperature: 0
    n: 1
    # for better consistency of llm response, refer: https://platform.openai.com/docs/api-reference/chat/create#chat-create-seed
    seed: 0
    max_tokens: 4096
- model: o3-mini-2025-01-31
  api_base: https://api.openai.com/v1
  api_key_name: LLM_OPENAI_API_KEY
  kwargs:
    n: 1
    seed: 0
    max_completion_tokens: 4096
    reasoning_effort: low

---
type: embedder
provider: litellm_embedder
models:
- model: openai/bge-m3:567m-fp16
  api_base: http://132.120.139.194:11434/v1
  api_key_name: EMBEDDER_OLLAMA_API_KEY
  timeout: 120

---
type: engine
provider: wren_ui
endpoint: http://wren-ui:3000

---
type: document_store
provider: qdrant
location: http://qdrant:6333
embedding_model_dim: 1024
timeout: 120
recreate_index: true

---
type: pipeline
pipes:
  - name: db_schema_indexing
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: historical_question_indexing
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: table_description_indexing
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: db_schema_retrieval
    llm: litellm_llm.openai/qwen2.5:7b
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: historical_question_retrieval
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: sql_generation
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: sql_correction
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: followup_sql_generation
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: sql_summary
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_answer
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_breakdown
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: sql_expansion
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: semantics_description
    llm: litellm_llm.openai/qwen2.5:7b
  - name: relationship_recommendation
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: question_recommendation
    llm: litellm_llm.openai/qwen2.5:7b
  - name: question_recommendation_db_schema_retrieval
    llm: litellm_llm.openai/qwen2.5:7b
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: question_recommendation_sql_generation
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui
  - name: intent_classification
    llm: litellm_llm.openai/qwen2.5:7b
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    document_store: qdrant
  - name: data_assistance
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_pairs_indexing
    document_store: qdrant
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
  - name: sql_pairs_retrieval
    document_store: qdrant
    embedder: litellm_embedder.openai/bge-m3:567m-fp16
    llm: litellm_llm.openai/qwen2.5:7b
  - name: preprocess_sql_data
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_executor
    engine: wren_ui
  - name: chart_generation
    llm: litellm_llm.openai/qwen2.5:7b
  - name: chart_adjustment
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_question_generation
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_generation_reasoning
    llm: litellm_llm.openai/qwen2.5:7b
  - name: sql_regeneration
    llm: litellm_llm.openai/qwen2.5:7b
    engine: wren_ui

---
settings:
  engine_timeout: 30
  column_indexing_batch_size: 50
  table_retrieval_size: 10
  table_column_retrieval_size: 100
  allow_using_db_schemas_without_pruning: false
  query_cache_maxsize: 1000
  query_cache_ttl: 3600
  langfuse_host: https://cloud.langfuse.com
  langfuse_enable: true
  logging_level: DEBUG
  development: false
@cyyeh
Copy link
Member

cyyeh commented Mar 19, 2025

@wxp2023 you could setup langfuse through this doc first: https://docs.getwren.ai/oss/ai_service/guide/langfuse_setup
in simple words, the error message means that your llm generates malformed json output. After you setup langfuse, you could check the error details yourself.

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

2 participants