Skip to content
Merged
Prev Previous commit
Next Next commit
fix: Parse json if query is json encoded
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jul 29, 2024
commit d0a1ba0227433eee349de19d209c627b5b79b12a
7 changes: 7 additions & 0 deletions context_chat_backend/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import os
import threading
from contextlib import asynccontextmanager
from json import JSONDecodeError
from logging import error as log_error
from typing import Annotated, Any

Expand Down Expand Up @@ -309,6 +311,11 @@ def _(query: Query) -> LLMOutput:
# todo: migrate to Depends during db schema change
llm: LLM = llm_loader.load()

try:
query.query = json.loads(query.query).get("prompt", query.query)
except JSONDecodeError:
pass

template = app.extra.get('LLM_TEMPLATE')
no_ctx_template = app.extra['LLM_NO_CTX_TEMPLATE']
# todo: array
Expand Down