dwani 0.1.3__tar.gz → 0.1.4__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dwani
3
- Version: 0.1.3
4
- Summary: Multimodal AI server for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
3
+ Version: 0.1.4
4
+ Summary: Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
5
5
  Author-email: sachin <python@dwani.ai>
6
6
  License: MIT License
7
7
 
@@ -28,7 +28,7 @@ License: MIT License
28
28
  Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
29
  Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
30
  Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
- Requires-Python: >=3.10
31
+ Requires-Python: >=3.8
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: requests>=2.25.0
@@ -49,7 +49,7 @@ import os
49
49
 
50
50
  dwani.api_key = os.getenv("DWANI_API_KEY")
51
51
 
52
- dwani.api_base = os.getenv("DWANI_API_BASE")
52
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
53
 
54
54
  resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
55
55
  print(resp)
@@ -13,7 +13,7 @@ import os
13
13
 
14
14
  dwani.api_key = os.getenv("DWANI_API_KEY")
15
15
 
16
- dwani.api_base = os.getenv("DWANI_API_BASE")
16
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
17
17
 
18
18
  resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
19
19
  print(resp)
@@ -1,21 +1,20 @@
1
1
  from .exceptions import DhwaniAPIError
2
2
  import requests
3
- def vision_caption(client, file_path, length="short"):
3
+ def asr_transcribe(client, file_path, language):
4
4
  with open(file_path, "rb") as f:
5
5
  files = {"file": f}
6
- data = {"length": length}
7
6
  resp = requests.post(
8
- f"{client.api_base}/caption/",
7
+ f"{client.api_base}/v1/transcribe/?language={language}",
9
8
  headers=client._headers(),
10
- files=files,
11
- data=data
9
+ files=files
12
10
  )
13
11
  if resp.status_code != 200:
14
12
  raise DhwaniAPIError(resp)
15
13
  return resp.json()
16
14
 
17
- class Vision:
15
+ class ASR:
18
16
  @staticmethod
19
- def caption(*args, **kwargs):
17
+ def transcribe(*args, **kwargs):
20
18
  from . import _get_client
21
- return _get_client().caption(*args, **kwargs)
19
+ return _get_client().transcribe(*args, **kwargs)
20
+
@@ -1,16 +1,16 @@
1
1
  from .exceptions import DhwaniAPIError
2
2
  import requests
3
- def audio_speech(client, input, voice, model, response_format="mp3", output_file=None):
4
- data = {
3
+
4
+ def audio_speech(client, input, response_format="mp3", output_file=None):
5
+ params = {
5
6
  "input": input,
6
- "voice": voice,
7
- "model": model,
8
7
  "response_format": response_format
9
8
  }
10
9
  resp = requests.post(
11
10
  f"{client.api_base}/v1/audio/speech",
12
- headers={**client._headers(), "Content-Type": "application/json"},
13
- json=data,
11
+ headers={**client._headers(), "accept": "application/json"},
12
+ params=params,
13
+ data='', # Empty body, as in the curl example
14
14
  stream=True
15
15
  )
16
16
  if resp.status_code != 200:
@@ -5,7 +5,7 @@ from .exceptions import DhwaniAPIError
5
5
  class DhwaniClient:
6
6
  def __init__(self, api_key=None, api_base=None):
7
7
  self.api_key = api_key or os.getenv("DWANI_API_KEY")
8
- self.api_base = api_base or os.getenv("DWANI_API_BASE", "http://localhost:7860")
8
+ self.api_base = api_base or os.getenv("DWANI_API_BASE_URL", "http://localhost:7860")
9
9
  if not self.api_key:
10
10
  raise ValueError("DHWANI_API_KEY not set")
11
11
 
@@ -16,14 +16,13 @@ class DhwaniClient:
16
16
  from .chat import chat_create
17
17
  return chat_create(self, prompt, src_lang, tgt_lang, **kwargs)
18
18
 
19
-
20
19
  def speech(self, *args, **kwargs):
21
20
  from .audio import audio_speech
22
21
  return audio_speech(self, *args, **kwargs)
23
22
 
24
- def caption(self, *args, **kwargs):
23
+ def caption(self, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
25
24
  from .vision import vision_caption
26
- return vision_caption(self, *args, **kwargs)
25
+ return vision_caption(self, file_path, query, src_lang, tgt_lang)
27
26
 
28
27
  def transcribe(self, *args, **kwargs):
29
28
  from .asr import asr_transcribe
@@ -0,0 +1,31 @@
1
+ from .exceptions import DhwaniAPIError
2
+ import requests
3
+ def vision_caption(client, file_path, query="describe the image", src_lang="eng_Latn", tgt_lang="kan_Knda"):
4
+ # Build the endpoint using the client's api_base
5
+ url = (
6
+ f"{client.api_base}/v1/indic_visual_query"
7
+ f"?src_lang={src_lang}&tgt_lang={tgt_lang}"
8
+ )
9
+ headers = {
10
+ **client._headers(),
11
+ "accept": "application/json"
12
+ # Note: 'Content-Type' will be set automatically by requests when using 'files'
13
+ }
14
+ with open(file_path, "rb") as f:
15
+ files = {"file": (file_path, f, "image/png")}
16
+ data = {"query": query}
17
+ resp = requests.post(
18
+ url,
19
+ headers=headers,
20
+ files=files,
21
+ data=data
22
+ )
23
+ if resp.status_code != 200:
24
+ raise DhwaniAPIError(resp)
25
+ return resp.json()
26
+
27
+ class Vision:
28
+ @staticmethod
29
+ def caption(*args, **kwargs):
30
+ from . import _get_client
31
+ return _get_client().caption(*args, **kwargs)
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dwani
3
- Version: 0.1.3
4
- Summary: Multimodal AI server for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
3
+ Version: 0.1.4
4
+ Summary: Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)
5
5
  Author-email: sachin <python@dwani.ai>
6
6
  License: MIT License
7
7
 
@@ -28,7 +28,7 @@ License: MIT License
28
28
  Project-URL: Homepage, https://github.com/dwani-ai/dwani-python
29
29
  Project-URL: Source, https://github.com/dwani-ai/dwani-python
30
30
  Project-URL: Issues, https://github.com/dwani-ai/dwani-python/issues
31
- Requires-Python: >=3.10
31
+ Requires-Python: >=3.8
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: requests>=2.25.0
@@ -49,7 +49,7 @@ import os
49
49
 
50
50
  dwani.api_key = os.getenv("DWANI_API_KEY")
51
51
 
52
- dwani.api_base = os.getenv("DWANI_API_BASE")
52
+ dwani.api_base = os.getenv("DWANI_API_BASE_URL")
53
53
 
54
54
  resp = dwani.Chat.create("Hello!", "eng_Latn", "kan_Knda")
55
55
  print(resp)
@@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dwani"
7
- version = "0.1.3"
8
- description = "Multimodal AI server for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)"
7
+ version = "0.1.4"
8
+ description = "Multimodal API for Indian languages (speech, vision, LLMs, TTS, ASR, etc.)"
9
9
  authors = [
10
10
  { name="sachin", email="python@dwani.ai" }
11
11
  ]
12
12
  readme = "README.md"
13
13
  license = { file = "LICENSE" }
14
- requires-python = ">=3.10"
14
+ requires-python = ">=3.8"
15
15
 
16
16
  dependencies = [
17
17
  "requests>=2.25.0",
dwani-0.1.3/dwani/asr.py DELETED
@@ -1,37 +0,0 @@
1
- from .exceptions import DhwaniAPIError
2
- import requests
3
- def asr_transcribe(client, file_path, language):
4
- with open(file_path, "rb") as f:
5
- files = {"file": f}
6
- resp = requests.post(
7
- f"{client.api_base}/transcribe/?language={language}",
8
- headers=client._headers(),
9
- files=files
10
- )
11
- if resp.status_code != 200:
12
- raise DhwaniAPIError(resp)
13
- return resp.json()
14
-
15
- class ASR:
16
- @staticmethod
17
- def transcribe(*args, **kwargs):
18
- from . import _get_client
19
- return _get_client().transcribe(*args, **kwargs)
20
-
21
-
22
- '''
23
- from .docs import Documents
24
-
25
- class documents:
26
- @staticmethod
27
- def ocr(file_path, language=None):
28
- return _get_client().document_ocr(file_path, language)
29
-
30
- @staticmethod
31
- def translate(file_path, src_lang, tgt_lang):
32
- return _get_client().document_translate(file_path, src_lang, tgt_lang)
33
-
34
- @staticmethod
35
- def summarize(file_path, language=None):
36
- return _get_client().document_summarize(file_path, language)
37
- '''
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes