dwani 0.1.17__tar.gz → 0.1.19__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.17 → dwani-0.1.19}/PKG-INFO +1 -1
- {dwani-0.1.17 → dwani-0.1.19}/dwani/asr.py +2 -1
- {dwani-0.1.17 → dwani-0.1.19}/dwani/audio.py +2 -1
- {dwani-0.1.17 → dwani-0.1.19}/dwani/chat.py +4 -2
- {dwani-0.1.17 → dwani-0.1.19}/dwani/docs.py +13 -12
- {dwani-0.1.17 → dwani-0.1.19}/dwani/translate.py +2 -1
- {dwani-0.1.17 → dwani-0.1.19}/dwani/vision.py +4 -2
- {dwani-0.1.17 → dwani-0.1.19}/pyproject.toml +1 -1
- {dwani-0.1.17 → dwani-0.1.19}/LICENSE +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/MANIFEST.in +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/README.md +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/dwani/__init__.py +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/dwani/client.py +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/dwani/exceptions.py +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/dwani.egg-info/SOURCES.txt +0 -0
- {dwani-0.1.17 → dwani-0.1.19}/setup.cfg +0 -0
@@ -42,7 +42,8 @@ def asr_transcribe(client, file_path, language):
|
|
42
42
|
resp = requests.post(
|
43
43
|
f"{client.api_base}/v1/transcribe/?language={api_language}",
|
44
44
|
headers=client._headers(),
|
45
|
-
files=files
|
45
|
+
files=files,
|
46
|
+
timeout=90
|
46
47
|
)
|
47
48
|
if resp.status_code != 200:
|
48
49
|
raise DwaniAPIError(resp)
|
@@ -12,7 +12,8 @@ def audio_speech(client, input, response_format="mp3", output_file=None, languag
|
|
12
12
|
headers={**client._headers(), "accept": "application/json"},
|
13
13
|
params=params,
|
14
14
|
data='', # Empty body, as in the curl example
|
15
|
-
stream=True
|
15
|
+
stream=True,
|
16
|
+
timeout=90
|
16
17
|
)
|
17
18
|
if resp.status_code != 200:
|
18
19
|
raise DwaniAPIError(resp)
|
@@ -46,7 +46,8 @@ def chat_direct(client, prompt, model="gemma3", system_prompt=""):
|
|
46
46
|
resp = requests.post(
|
47
47
|
url,
|
48
48
|
headers={**client._headers(), "Content-Type": "application/json"},
|
49
|
-
json=payload
|
49
|
+
json=payload,
|
50
|
+
timeout=90
|
50
51
|
)
|
51
52
|
if resp.status_code != 200:
|
52
53
|
raise DwaniAPIError(resp)
|
@@ -72,7 +73,8 @@ def chat_create(client, prompt, src_lang, tgt_lang, model="gemma3"):
|
|
72
73
|
resp = requests.post(
|
73
74
|
url,
|
74
75
|
headers={**client._headers(), "Content-Type": "application/json"},
|
75
|
-
json=payload
|
76
|
+
json=payload,
|
77
|
+
timeout=90
|
76
78
|
)
|
77
79
|
if resp.status_code != 200:
|
78
80
|
raise DwaniAPIError(resp)
|
@@ -56,7 +56,7 @@ def document_ocr_all(client, file_path, model="gemma3"):
|
|
56
56
|
headers=client._headers(),
|
57
57
|
files=files,
|
58
58
|
data=data,
|
59
|
-
timeout=
|
59
|
+
timeout=90
|
60
60
|
)
|
61
61
|
resp.raise_for_status()
|
62
62
|
except requests.RequestException as e:
|
@@ -67,14 +67,15 @@ def document_ocr_all(client, file_path, model="gemma3"):
|
|
67
67
|
return resp.json()
|
68
68
|
|
69
69
|
|
70
|
-
def document_ocr_number(client, file_path, page_number
|
70
|
+
def document_ocr_number(client, file_path, page_number, model="gemma3"):
|
71
71
|
"""OCR a document (image/PDF) and return extracted text."""
|
72
72
|
logger.debug(f"Calling document_ocr: file_path={file_path}, model={model}")
|
73
73
|
validate_model(model)
|
74
74
|
|
75
75
|
data = {"model": model,
|
76
|
-
"page_number":
|
77
|
-
|
76
|
+
"page_number": page_number}
|
77
|
+
|
78
|
+
params = {"model": data["model"], "page_number": data["page_number"]}
|
78
79
|
with open(file_path, "rb") as f:
|
79
80
|
mime_type = "application/pdf" if file_path.lower().endswith('.pdf') else "image/png"
|
80
81
|
files = {"file": (file_path, f, mime_type)}
|
@@ -83,8 +84,8 @@ def document_ocr_number(client, file_path, page_number=1, model="gemma3"):
|
|
83
84
|
f"{client.api_base}/v1/extract-text",
|
84
85
|
headers=client._headers(),
|
85
86
|
files=files,
|
86
|
-
|
87
|
-
timeout=
|
87
|
+
params=params,
|
88
|
+
timeout=90
|
88
89
|
)
|
89
90
|
resp.raise_for_status()
|
90
91
|
except requests.RequestException as e:
|
@@ -123,7 +124,7 @@ def document_summarize(client, file_path, page_number=1, src_lang="eng_Latn", tg
|
|
123
124
|
headers=headers,
|
124
125
|
files=files,
|
125
126
|
data=data,
|
126
|
-
timeout=
|
127
|
+
timeout=90
|
127
128
|
)
|
128
129
|
resp.raise_for_status()
|
129
130
|
except requests.RequestException as e:
|
@@ -164,7 +165,7 @@ def extract(client, file_path, page_number=1, src_lang="eng_Latn", tgt_lang="kan
|
|
164
165
|
headers=headers,
|
165
166
|
files=files,
|
166
167
|
data=data,
|
167
|
-
timeout=
|
168
|
+
timeout=90
|
168
169
|
)
|
169
170
|
resp.raise_for_status()
|
170
171
|
except requests.RequestException as e:
|
@@ -216,7 +217,7 @@ def doc_query(
|
|
216
217
|
headers=headers,
|
217
218
|
files=files,
|
218
219
|
data=data,
|
219
|
-
timeout=
|
220
|
+
timeout=90
|
220
221
|
)
|
221
222
|
resp.raise_for_status()
|
222
223
|
except requests.RequestException as e:
|
@@ -268,7 +269,7 @@ def doc_query_kannada(
|
|
268
269
|
headers=headers,
|
269
270
|
files=files,
|
270
271
|
data=data,
|
271
|
-
timeout=
|
272
|
+
timeout=90
|
272
273
|
)
|
273
274
|
resp.raise_for_status()
|
274
275
|
except requests.RequestException as e:
|
@@ -281,10 +282,10 @@ def doc_query_kannada(
|
|
281
282
|
|
282
283
|
class Documents:
|
283
284
|
@staticmethod
|
284
|
-
def run_ocr_number(file_path, page_number=
|
285
|
+
def run_ocr_number(file_path, page_number=2,model="gemma3"):
|
285
286
|
from .client import DwaniClient
|
286
287
|
client = DwaniClient()
|
287
|
-
return document_ocr_number(client, file_path, page_number
|
288
|
+
return document_ocr_number(client, file_path, page_number, model)
|
288
289
|
@staticmethod
|
289
290
|
def run_ocr_all(file_path, model="gemma3"):
|
290
291
|
from .client import DwaniClient
|
@@ -66,7 +66,8 @@ def run_translate(client, sentences, src_lang, tgt_lang):
|
|
66
66
|
resp = requests.post(
|
67
67
|
url,
|
68
68
|
headers={**client._headers(), "Content-Type": "application/json", "accept": "application/json"},
|
69
|
-
json=payload
|
69
|
+
json=payload,
|
70
|
+
timeout=90
|
70
71
|
)
|
71
72
|
if resp.status_code != 200:
|
72
73
|
raise DwaniAPIError(resp)
|
@@ -52,7 +52,8 @@ def vision_direct(client, file_path, query="describe this image", model="gemma3"
|
|
52
52
|
url,
|
53
53
|
headers=headers,
|
54
54
|
files=files,
|
55
|
-
data=data
|
55
|
+
data=data,
|
56
|
+
timeout=90
|
56
57
|
)
|
57
58
|
if resp.status_code != 200:
|
58
59
|
raise DwaniAPIError(resp)
|
@@ -84,7 +85,8 @@ def vision_caption(client, file_path, query="describe the image", src_lang="eng_
|
|
84
85
|
url,
|
85
86
|
headers=headers,
|
86
87
|
files=files,
|
87
|
-
data=data
|
88
|
+
data=data,
|
89
|
+
timeout=90
|
88
90
|
)
|
89
91
|
if resp.status_code != 200:
|
90
92
|
raise DwaniAPIError(resp)
|
@@ -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.19"
|
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
|