Skip to content

Commit 2dc7dad

Browse files
UN-2566 [FIX] Changed JSON selection marker (#191)
* UN-2566 Changed JSON selection marker Signed-off-by: Deepak <[email protected]> * Version bump --------- Signed-off-by: Deepak <[email protected]>
1 parent 091a37a commit 2dc7dad

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/unstract/sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "v0.73.1"
1+
__version__ = "v0.73.2"
22

33

44
def get_sdk_version() -> str:

src/unstract/sdk/llm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import re
34
from collections.abc import Callable
45
from typing import Any
@@ -31,6 +32,7 @@ class LLM:
3132
llm_adapters = adapters
3233
MAX_TOKENS = 1024 * 4
3334
RESPONSE = "response"
35+
JSON_SELECTION_MARKER = os.environ.get("JSON_SELECTION_MARKER", "§§§")
3436

3537
def __init__(
3638
self,
@@ -101,10 +103,12 @@ def complete(
101103
process_text_output = {}
102104
if extract_json:
103105
response_text = response.text
104-
start = response_text.find("###")
106+
start = response_text.find(self.JSON_SELECTION_MARKER)
105107
if start != -1:
106-
response_text = response_text[start + 3:].lstrip()
107-
end = response_text.rfind("###")
108+
response_text = response_text[
109+
start + len(self.JSON_SELECTION_MARKER) :
110+
].lstrip()
111+
end = response_text.rfind(self.JSON_SELECTION_MARKER)
108112
if end != -1:
109113
response_text = response_text[:end].rstrip()
110114
match = LLM.json_regex.search(response_text)

0 commit comments

Comments
 (0)