LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Fixed Enforce Type Issues for Boolean and JSON (#262)
Tahier Hussain9b14dae2f9b4
diff --git a/prompt-service/src/unstract/prompt_service/main.py b/prompt-service/src/unstract/prompt_service/main.pyindex 130a0b5f8..1d16155a3 100644--- a/prompt-service/src/unstract/prompt_service/main.py+++ b/prompt-service/src/unstract/prompt_service/main.py@@ -464,6 +464,15 @@ def prompt_processor() -> Any:if assertion_failed or answer.lower() == "na":structured_output[output[PSKeys.NAME]] = Noneelse:+ prompt = f'Extract yes/no from the following text:\n{answer}\n\n\+ Output in single word.\+ If the context is trying to convey that the answer is true, \+ then return "yes", else return "no".'+ answer, usage = run_completion(+ llm_helper,+ llm_li,+ prompt,+ )if answer.lower() == "yes":structured_output[output[PSKeys.NAME]] = Trueelse:@@ -472,6 +481,14 @@ def prompt_processor() -> Any:if assertion_failed or answer.lower() == "[]" or answer.lower() == "na":structured_output[output[PSKeys.NAME]] = Noneelse:+ prompt = (+ f"Convert the following text:\n{answer} into valid JSON format."+ )+ answer, usage = run_completion(+ llm_helper,+ llm_li,+ prompt,+ )# Remove any markdown code blockslines = answer.split("\n")answer = ""