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