From 8a4951c506f287df2d1677bd27a0568ca8f04c39 Mon Sep 17 00:00:00 2001 From: Deepak K <89829542+Deepak-Kesavan@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:47:13 +0530 Subject: [PATCH] FIX: Changes for new highlight (#124) * Changes for new highlight * SDK version bump --- src/unstract/sdk/__init__.py | 2 +- src/unstract/sdk/llm.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unstract/sdk/__init__.py b/src/unstract/sdk/__init__.py index 15be65ae..6abdd427 100644 --- a/src/unstract/sdk/__init__.py +++ b/src/unstract/sdk/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.53.1" +__version__ = "0.53.2" def get_sdk_version(): diff --git a/src/unstract/sdk/llm.py b/src/unstract/sdk/llm.py index c7eedbc5..14ae9ca4 100644 --- a/src/unstract/sdk/llm.py +++ b/src/unstract/sdk/llm.py @@ -95,18 +95,18 @@ def complete( try: response: CompletionResponse = self._llm_instance.complete(prompt, **kwargs) process_text_output = {} + if extract_json: + match = LLM.json_regex.search(response.text) + if match: + response.text = match.group(0) if process_text: try: - process_text_output = process_text(response, LLM.json_regex) + process_text_output = process_text(response, extract_json) if not isinstance(process_text_output, dict): process_text_output = {} except Exception as e: logger.error(f"Error occured inside function 'process_text': {e}") process_text_output = {} - if extract_json: - match = LLM.json_regex.search(response.text) - if match: - response.text = match.group(0) return {LLM.RESPONSE: response, **process_text_output} except Exception as e: raise parse_llm_err(e) from e