dwani 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl

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/client.py CHANGED
@@ -23,7 +23,6 @@ class DwaniClient:
23
23
  from .chat import chat_create
24
24
  return chat_create(self, prompt=prompt, src_lang=src_lang, tgt_lang=tgt_lang, model=model)
25
25
 
26
-
27
26
  def chat_direct(self, prompt, model="gemma3", system_prompt=""):
28
27
  from .chat import chat_direct
29
28
  return chat_direct(self, prompt=prompt, model=model, system_prompt=system_prompt)
dwani/translate.py CHANGED
@@ -25,21 +25,27 @@ lang_code_to_code = {code: code for _, code in language_options}
25
25
  def normalize_language(lang):
26
26
  """Convert language input (name or code) to language code."""
27
27
  lang = lang.strip()
28
- # Check if input is a language name (case-insensitive)
29
28
  lang_lower = lang.lower()
30
29
  if lang_lower in lang_name_to_code:
31
30
  return lang_name_to_code[lang_lower]
32
- # Check if input is a language code
33
31
  if lang in lang_code_to_code:
34
32
  return lang_code_to_code[lang]
35
- # Raise error if language is not supported
36
33
  supported_langs = list(lang_name_to_code.keys()) + list(lang_code_to_code.keys())
37
34
  raise ValueError(f"Unsupported language: {lang}. Supported languages: {supported_langs}")
38
35
 
36
+ def split_into_sentences(text):
37
+ """Split a string into sentences based on full stops."""
38
+ if not text.strip():
39
+ return []
40
+ # Split on full stops, preserving non-empty sentences
41
+ sentences = [s.strip() for s in text.split('.') if s.strip()]
42
+ return sentences
43
+
39
44
  def run_translate(client, sentences, src_lang, tgt_lang):
40
- # Convert single string to list if necessary
45
+ """Translate sentences in a single API call."""
46
+ # Convert single string to list of sentences if necessary
41
47
  if isinstance(sentences, str):
42
- sentences = [sentences]
48
+ sentences = split_into_sentences(sentences)
43
49
  elif not isinstance(sentences, list):
44
50
  raise ValueError("sentences must be a string or a list of strings")
45
51
 
@@ -70,4 +76,4 @@ class Translate:
70
76
  @staticmethod
71
77
  def run_translate(sentences, src_lang, tgt_lang):
72
78
  from . import _get_client
73
- return _get_client().translate(sentences, src_lang, tgt_lang)
79
+ return run_translate(_get_client(), sentences, src_lang, tgt_lang)
dwani/vision.py CHANGED
@@ -58,7 +58,6 @@ def vision_direct(client, file_path, query="describe this image", model="gemma3"
58
58
  raise DwaniAPIError(resp)
59
59
  return resp.json()
60
60
 
61
-
62
61
  def vision_caption(client, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda", model="gemma3"):
63
62
  # Validate model
64
63
  valid_models = ["gemma3", "qwen2.5vl", "moondream", "smolvla"]
@@ -99,4 +98,4 @@ class Vision:
99
98
  @staticmethod
100
99
  def caption_direct(file_path, query="describe the image", model="gemma3", system_prompt=""):
101
100
  from . import _get_client
102
- return _get_client().caption_direct(file_path, query, model, system_prompt)
101
+ return _get_client().caption_direct(file_path, query, model, system_prompt)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dwani
3
- Version: 0.1.11
3
+ Version: 0.1.13
4
4
  Summary: Multimodal API for Indian languages (Chat, Vision, TTS, ASR, Translate, Docs)
5
5
  Author-email: sachin <python@dwani.ai>
6
6
  License: MIT License
@@ -0,0 +1,14 @@
1
+ dwani/__init__.py,sha256=8Q1qdF0g6xWEy1_PK6qxG-EeZUp_QOwYBqNv_y6EyHI,3010
2
+ dwani/asr.py,sha256=BAdqivQd57NJZX1dSY-J6EFi8TDdyuhf_AyCPcQ0M7w,1719
3
+ dwani/audio.py,sha256=MWsIZazL91c2wa5AE1YY78l9RKaJwNFFHIajuwl43Jg,886
4
+ dwani/chat.py,sha256=Tui52XBhUyDyN2rOFoLme4oB0Q8fkD9_0tFDAnRzoaU,2979
5
+ dwani/client.py,sha256=Xqpc5tCOLpNWSPanY2eru2ywL6DytNCQjUDxv8hqXmw,3355
6
+ dwani/docs.py,sha256=Cp0Gtudug79GH25toB-Npl35ZFA0TM32oZF2xH1VmNY,10598
7
+ dwani/exceptions.py,sha256=n06dPmR20rS4T3sJBWHQhGxzg4SJKzird9Hx0YTwwo0,226
8
+ dwani/translate.py,sha256=c03N8-tN49IBcTA6GMOkrJ3MaVzZ12RnYdLQwRbEeoQ,2794
9
+ dwani/vision.py,sha256=FviGewoV936CSv_K-latw0t3ZhSSCOF5LaGaq1oE4uA,3607
10
+ dwani-0.1.13.dist-info/licenses/LICENSE,sha256=IAD8tbwWZbPWHXgYjabHoMv0aaUzZUYzYiEbfhTCisY,1070
11
+ dwani-0.1.13.dist-info/METADATA,sha256=PZSXwWoH6UzDF17X8_CfQIvzHC-Z1LjC3s3GwWeOUfc,5791
12
+ dwani-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ dwani-0.1.13.dist-info/top_level.txt,sha256=AM5EhkyuO_EXQFR9JIxEV6tAYMCCyc-a1dLifpCGBUk,6
14
+ dwani-0.1.13.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- dwani/__init__.py,sha256=8Q1qdF0g6xWEy1_PK6qxG-EeZUp_QOwYBqNv_y6EyHI,3010
2
- dwani/asr.py,sha256=BAdqivQd57NJZX1dSY-J6EFi8TDdyuhf_AyCPcQ0M7w,1719
3
- dwani/audio.py,sha256=MWsIZazL91c2wa5AE1YY78l9RKaJwNFFHIajuwl43Jg,886
4
- dwani/chat.py,sha256=Tui52XBhUyDyN2rOFoLme4oB0Q8fkD9_0tFDAnRzoaU,2979
5
- dwani/client.py,sha256=VG7MFCF4yLAWyD037YcI3QTUMxRfJZrWTDK-JAurTnY,3356
6
- dwani/docs.py,sha256=Cp0Gtudug79GH25toB-Npl35ZFA0TM32oZF2xH1VmNY,10598
7
- dwani/exceptions.py,sha256=n06dPmR20rS4T3sJBWHQhGxzg4SJKzird9Hx0YTwwo0,226
8
- dwani/translate.py,sha256=-6UHV5hu1oBxuDlGlGYp13bFDayKWwo1rBkJhE-LRMs,2568
9
- dwani/vision.py,sha256=sjkudW2Jb_PEbRcoZy_S1Wno6K5icZz42pHcpD1FMGs,3607
10
- dwani-0.1.11.dist-info/licenses/LICENSE,sha256=IAD8tbwWZbPWHXgYjabHoMv0aaUzZUYzYiEbfhTCisY,1070
11
- dwani-0.1.11.dist-info/METADATA,sha256=6dhzLxq9g_unE9uqNFYwMGBXAB3WvjAMyDnvhYjkDqo,5791
12
- dwani-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- dwani-0.1.11.dist-info/top_level.txt,sha256=AM5EhkyuO_EXQFR9JIxEV6tAYMCCyc-a1dLifpCGBUk,6
14
- dwani-0.1.11.dist-info/RECORD,,
File without changes