dwani 0.1.20__tar.gz → 0.1.21__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dwani-0.1.20 → dwani-0.1.21}/PKG-INFO +1 -1
- {dwani-0.1.20 → dwani-0.1.21}/dwani/__init__.py +8 -2
- {dwani-0.1.20 → dwani-0.1.21}/dwani/client.py +8 -3
- {dwani-0.1.20 → dwani-0.1.21}/dwani/docs.py +72 -13
- {dwani-0.1.20 → dwani-0.1.21}/pyproject.toml +1 -1
- {dwani-0.1.20 → dwani-0.1.21}/LICENSE +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/MANIFEST.in +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/README.md +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/asr.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/audio.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/chat.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/exceptions.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/translate.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani/vision.py +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/dwani.egg-info/SOURCES.txt +0 -0
- {dwani-0.1.20 → dwani-0.1.21}/setup.cfg +0 -0
@@ -72,10 +72,16 @@ class document:
|
|
72
72
|
@staticmethod
|
73
73
|
def run_extract(file_path, page_number=1, tgt_lang="kan_Knda", model="gemma3"):
|
74
74
|
return _get_client().extract(file_path, page_number, tgt_lang, model)
|
75
|
+
|
76
|
+
|
77
|
+
@staticmethod
|
78
|
+
def query_page(file_path, page_number=1,prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
79
|
+
return _get_client().query_page(file_path, page_number, prompt, query_lang, tgt_lang, model)
|
75
80
|
|
81
|
+
|
76
82
|
@staticmethod
|
77
|
-
def
|
78
|
-
return _get_client().
|
83
|
+
def query_all(file_path, prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
84
|
+
return _get_client().query_all(file_path, prompt, query_lang, tgt_lang, model)
|
79
85
|
|
80
86
|
@staticmethod
|
81
87
|
def run_doc_query_kannada(file_path, page_number=1, prompt="list key points", src_lang="kan_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
@@ -59,9 +59,14 @@ class DwaniClient:
|
|
59
59
|
from .docs import extract
|
60
60
|
return extract(self, file_path=file_path, page_number=page_number, tgt_lang=tgt_lang, model=model)
|
61
61
|
|
62
|
-
def
|
63
|
-
from .docs import
|
64
|
-
return
|
62
|
+
def query_page(self, file_path, page_number=1, prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
63
|
+
from .docs import query_page
|
64
|
+
return query_page(self, file_path, page_number=page_number, prompt=prompt, query_lang=query_lang, tgt_lang=tgt_lang, model=model)
|
65
|
+
|
66
|
+
def query_all(self, file_path, prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
67
|
+
from .docs import query_all
|
68
|
+
return query_all(self, file_path, prompt=prompt, query_lang=query_lang, tgt_lang=tgt_lang, model=model)
|
69
|
+
|
65
70
|
|
66
71
|
def doc_query_kannada(self, file_path, page_number=1, prompt="list key points", src_lang="eng_Latn", language="kan_Knda", model="gemma3"):
|
67
72
|
from .docs import doc_query_kannada
|
@@ -211,13 +211,13 @@ def extract(client, file_path, page_number=1, tgt_lang="kan_Knda", model="gemma3
|
|
211
211
|
|
212
212
|
return resp.json()
|
213
213
|
|
214
|
-
def
|
214
|
+
def query_page(
|
215
215
|
client,
|
216
216
|
file_path,
|
217
217
|
page_number=1,
|
218
218
|
prompt="list the key points",
|
219
219
|
tgt_lang="kan_Knda",
|
220
|
-
|
220
|
+
query_lang="eng_Latn",
|
221
221
|
model="gemma3"
|
222
222
|
):
|
223
223
|
"""Query a document with a custom prompt and language options."""
|
@@ -233,7 +233,8 @@ def doc_query(
|
|
233
233
|
|
234
234
|
tgt_lang_code = normalize_language(tgt_lang)
|
235
235
|
|
236
|
-
|
236
|
+
query_lang_code = normalize_language(query_lang)
|
237
|
+
|
237
238
|
|
238
239
|
url = f"{client.api_base}/v1/indic-custom-prompt-pdf"
|
239
240
|
headers = client._headers()
|
@@ -243,7 +244,7 @@ def doc_query(
|
|
243
244
|
"page_number": str(page_number),
|
244
245
|
"prompt": prompt,
|
245
246
|
"tgt_lang": tgt_lang_code,
|
246
|
-
"
|
247
|
+
"query_lang": query_lang_code,
|
247
248
|
"model": model
|
248
249
|
}
|
249
250
|
|
@@ -253,6 +254,7 @@ def doc_query(
|
|
253
254
|
headers=headers,
|
254
255
|
files=files,
|
255
256
|
data=data,
|
257
|
+
#params=params,
|
256
258
|
timeout=90
|
257
259
|
)
|
258
260
|
resp.raise_for_status()
|
@@ -264,6 +266,56 @@ def doc_query(
|
|
264
266
|
|
265
267
|
return resp.json()
|
266
268
|
|
269
|
+
def query_all(
|
270
|
+
client,
|
271
|
+
file_path,
|
272
|
+
prompt="list the key points",
|
273
|
+
tgt_lang="kan_Knda",
|
274
|
+
query_lang="eng_Latn",
|
275
|
+
model="gemma3"
|
276
|
+
):
|
277
|
+
"""Query a document with a custom prompt and language options."""
|
278
|
+
logger.debug(f"Calling doc_query: file_path={file_path}, prompt={prompt}, tgt_lang={tgt_lang}, model={model}")
|
279
|
+
validate_model(model)
|
280
|
+
|
281
|
+
if not file_path.lower().endswith('.pdf'):
|
282
|
+
raise ValueError("File must be a PDF")
|
283
|
+
if not prompt.strip():
|
284
|
+
raise ValueError("Prompt cannot be empty")
|
285
|
+
|
286
|
+
tgt_lang_code = normalize_language(tgt_lang)
|
287
|
+
|
288
|
+
query_lang_code = normalize_language(query_lang)
|
289
|
+
|
290
|
+
url = f"{client.api_base}/v1/indic-custom-prompt-pdf-all"
|
291
|
+
headers = client._headers()
|
292
|
+
with open(file_path, "rb") as f:
|
293
|
+
files = {"file": (file_path, f, "application/pdf")}
|
294
|
+
data = {
|
295
|
+
"prompt": prompt,
|
296
|
+
"tgt_lang": tgt_lang_code,
|
297
|
+
"query_lang": query_lang_code,
|
298
|
+
"model": model
|
299
|
+
}
|
300
|
+
|
301
|
+
try:
|
302
|
+
resp = requests.post(
|
303
|
+
url,
|
304
|
+
headers=headers,
|
305
|
+
files=files,
|
306
|
+
data=data,
|
307
|
+
timeout=90
|
308
|
+
)
|
309
|
+
resp.raise_for_status()
|
310
|
+
except requests.RequestException as e:
|
311
|
+
logger.error(f"Doc query request failed: {str(e)}")
|
312
|
+
raise DwaniAPIError(resp) if 'resp' in locals() else DwaniAPIError.from_exception(e)
|
313
|
+
|
314
|
+
logger.debug(f"Doc query response: {resp.status_code}")
|
315
|
+
|
316
|
+
return resp.json()
|
317
|
+
|
318
|
+
|
267
319
|
def doc_query_kannada(
|
268
320
|
client,
|
269
321
|
file_path,
|
@@ -320,43 +372,50 @@ def doc_query_kannada(
|
|
320
372
|
|
321
373
|
class Documents:
|
322
374
|
@staticmethod
|
323
|
-
def run_ocr_number(file_path, page_number=
|
375
|
+
def run_ocr_number(file_path, page_number=1,model="gemma3"):
|
324
376
|
from .client import DwaniClient
|
325
377
|
client = DwaniClient()
|
326
|
-
return document_ocr_page(client, file_path, page_number, model)
|
378
|
+
return document_ocr_page(client, file_path=file_path, page_number=page_number, model=model)
|
327
379
|
@staticmethod
|
328
380
|
def run_ocr_all(file_path, model="gemma3"):
|
329
381
|
from .client import DwaniClient
|
330
382
|
client = DwaniClient()
|
331
|
-
return document_ocr_all(client, file_path, model)
|
383
|
+
return document_ocr_all(client, file_path=file_path, model=model)
|
332
384
|
|
333
385
|
@staticmethod
|
334
386
|
def summarize_page(file_path, page_number=1, tgt_lang="kan_Knda", model="gemma3"):
|
335
387
|
from .client import DwaniClient
|
336
388
|
client = DwaniClient()
|
337
|
-
return document_summarize_page(client, file_path, page_number, tgt_lang, model)
|
389
|
+
return document_summarize_page(client, file_path=file_path, page_number=page_number, tgt_lang=tgt_lang, model=model)
|
338
390
|
|
339
391
|
|
340
392
|
@staticmethod
|
341
393
|
def summarize_all(file_path, tgt_lang="kan_Knda", model="gemma3"):
|
342
394
|
from .client import DwaniClient
|
343
395
|
client = DwaniClient()
|
344
|
-
return document_summarize_all(client, file_path, tgt_lang, model)
|
396
|
+
return document_summarize_all(client, file_path=file_path, tgt_lang=tgt_lang, model=model)
|
345
397
|
|
346
398
|
@staticmethod
|
347
399
|
def run_extract(file_path, page_number=1, tgt_lang="kan_Knda", model="gemma3"):
|
348
400
|
from .client import DwaniClient
|
349
401
|
client = DwaniClient()
|
350
|
-
return extract(client, file_path, page_number, tgt_lang, model)
|
402
|
+
return extract(client, file_path=file_path, page_number=page_number, tgt_lang=tgt_lang, model=model)
|
403
|
+
|
404
|
+
@staticmethod
|
405
|
+
def query_page(file_path, page_number=1, prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
406
|
+
from .client import DwaniClient
|
407
|
+
client = DwaniClient()
|
408
|
+
return query_page(client, file_path=file_path, page_number=page_number, prompt=prompt, query_lang=query_lang, tgt_lang=tgt_lang, model=model)
|
351
409
|
|
352
410
|
@staticmethod
|
353
|
-
def
|
411
|
+
def query_all(file_path, prompt="list the key points", query_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
|
354
412
|
from .client import DwaniClient
|
355
413
|
client = DwaniClient()
|
356
|
-
return
|
414
|
+
return query_all(client, file_path=file_path, prompt=prompt, query_lang=query_lang, tgt_lang=tgt_lang, model=model)
|
357
415
|
|
416
|
+
|
358
417
|
@staticmethod
|
359
418
|
def run_doc_query_kannada(file_path, page_number=1, prompt="list key points", tgt_lang="kan_Knda", model="gemma3"):
|
360
419
|
from .client import DwaniClient
|
361
420
|
client = DwaniClient()
|
362
|
-
return doc_query_kannada(client, file_path, page_number, prompt, tgt_lang, model)
|
421
|
+
return doc_query_kannada(client, file_path=file_path, page_number=page_number, prompt=prompt, tgt_lang=tgt_lang, model=model)
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
5
5
|
[project]
|
6
6
|
name = "dwani"
|
7
7
|
|
8
|
-
version = "0.1.
|
8
|
+
version = "0.1.21"
|
9
9
|
description = "Multimodal API for Indian + European languages (Chat, Vision, TTS, ASR, Translate, Docs)"
|
10
10
|
authors = [
|
11
11
|
{ name="sachin", email="python@dwani.ai" }
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|