Skip to content

Commit

Permalink
fix translate images/pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjoyo committed May 5, 2024
1 parent ea79c84 commit 831c0de
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bpm-ai/bpm_ai/translate/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async def translate_llm(
else:
input_items = await ocr_documents(input_items, ocr)
input_items = await transcribe_audio(input_items, asr)
input_data = prepare_text_blobs(input_data)
assert_all_files_processed(input_data)
input_items = prepare_text_blobs(input_items)
assert_all_files_processed(input_items)

prompt = Prompt.from_file(
"translate",
Expand Down
2 changes: 1 addition & 1 deletion bpm-ai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bpm-ai"
version = "1.7.2"
version = "1.7.3"
description = "AI task automation for BPM engines."
authors = ["Bennet Krause <[email protected]>"]
repository = "https://github.com/holunda-io/bpm-ai"
Expand Down
24 changes: 24 additions & 0 deletions bpm-ai/tests/test_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ async def test_translate_none(llm):
assert result["subject"] is None


async def test_translate_image(llm):
input_data = {
"doc": "files/invoice.png",
}
llm = llm or FakeLLM(
name="openai",
supports_images=True,
responses=[
AssistantMessage(
content={"doc": "Rechnung\n\nVon:\nDEMO - Sliced Invoices\nSuite 5A-1204\n123 Somewhere Street\nYour City AZ 12345\n[email protected]\n\nRechnungsnummer: INV-3337"}
)
]
)
result = await translate_llm(
llm=llm,
input_data=input_data,
target_language="German",
)
#if isinstance(llm, FakeLLM):
# llm.assert_last_request_contains("[email protected]")

assert "Rechnung" in result["doc"]


async def test_translate_empty(llm):
input_data = {}
llm = llm or FakeLLM(name="openai")
Expand Down

0 comments on commit 831c0de

Please sign in to comment.