Skip to content

Commit 133b1f7

Browse files
committed
Minor C API changes
1 parent 68332db commit 133b1f7

File tree

3 files changed

+43
-33
lines changed

3 files changed

+43
-33
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
+ Added support for `aac`, `flac`, `opus`, `wav` response formats in `muna.beta.openai.audio.speech.create` function.
44
+ Fixed `TypeError` when creating a prediction with read-only `bytes` input value.
55
+ Fixed `AttributeError` when creating a prediction that outputs a binary output value.
6+
+ Removed `Dtype.audio` enumeration member.
7+
+ Removed `Dtype.video` enumeration member.
8+
+ Removed `Dtype.model` enumeration member.
69

710
## 0.0.74
811
+ Fixed `MunaAPIError` exception class raising exception when being unpickled.

muna/c/map.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ def __init__(
2222
if map is None:
2323
map = c_void_p()
2424
owner = True
25-
status = get_fxnc().FXNValueCreateValueMap(byref(map))
25+
status = get_fxnc().FXNValueMapCreate(byref(map))
2626
if status != FXNStatus.OK:
27-
raise RuntimeError(f"Failed to create value map with error: {status_to_error(status)}")
27+
raise RuntimeError(
28+
f"Failed to create value map "
29+
f"with error: {status_to_error(status)}"
30+
)
2831
self.__map = map
2932
self.__owner = owner
3033

@@ -39,7 +42,10 @@ def key(self, index: int) -> str:
3942
if status == FXNStatus.OK:
4043
return buffer.value.decode("utf-8")
4144
else:
42-
raise RuntimeError(f"Failed to get value map key at index {index} with error: {status_to_error(status)}")
45+
raise RuntimeError(
46+
f"Failed to get value map key at index {index} "
47+
f"with error: {status_to_error(status)}"
48+
)
4349

4450
def __getitem__(self, key: str) -> Value | None:
4551
value = c_void_p()
@@ -48,10 +54,12 @@ def __getitem__(self, key: str) -> Value | None:
4854
key.encode(),
4955
byref(value)
5056
)
51-
if status == FXNStatus.OK:
52-
return Value(value, owner=False)
53-
else:
54-
raise RuntimeError(f"Failed to get value map value for key '{key}' with error: {status_to_error(status)}")
57+
if status != FXNStatus.OK:
58+
raise RuntimeError(
59+
f"Failed to get value map value for key '{key}' "
60+
f"with error: {status_to_error(status)}"
61+
)
62+
return Value(value, owner=False)
5563

5664
def __setitem__(
5765
self,
@@ -64,7 +72,10 @@ def __setitem__(
6472
value._Value__value
6573
)
6674
if status != FXNStatus.OK:
67-
raise RuntimeError(f"Failed to set value map value for key '{key}' with error: {status_to_error(status)}")
75+
raise RuntimeError(
76+
f"Failed to set value map value for key '{key}' "
77+
f"with error: {status_to_error(status)}"
78+
)
6879

6980
def __len__(self) -> int:
7081
count = c_int32()
@@ -82,7 +93,7 @@ def __exit__(self, exc_type, exc_value, traceback):
8293

8394
def __release(self):
8495
if self.__map and self.__owner:
85-
get_fxnc().FXNValueRelease(self.__map)
96+
get_fxnc().FXNValueMapRelease(self.__map)
8697
self.__map = None
8798

8899
@classmethod

muna/types/value.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,26 @@ class Dtype(StrEnum):
1212
"""
1313
Value type.
1414
"""
15-
null = "null"
16-
bfloat16 = "bfloat16"
17-
float16 = "float16"
18-
float32 = "float32"
19-
float64 = "float64"
20-
int8 = "int8"
21-
int16 = "int16"
22-
int32 = "int32"
23-
int64 = "int64"
24-
uint8 = "uint8"
25-
uint16 = "uint16"
26-
uint32 = "uint32"
27-
uint64 = "uint64"
28-
bool = "bool"
29-
string = "string"
30-
list = "list"
31-
dict = "dict"
32-
image = "image"
33-
video = "video"
34-
audio = "audio"
35-
model = "model"
36-
binary = "binary"
37-
value_list = "value_list"
38-
value_map = "value_map"
15+
null = "null"
16+
bfloat16 = "bfloat16"
17+
float16 = "float16"
18+
float32 = "float32"
19+
float64 = "float64"
20+
int8 = "int8"
21+
int16 = "int16"
22+
int32 = "int32"
23+
int64 = "int64"
24+
uint8 = "uint8"
25+
uint16 = "uint16"
26+
uint32 = "uint32"
27+
uint64 = "uint64"
28+
bool = "bool"
29+
string = "string"
30+
list = "list"
31+
dict = "dict"
32+
image = "image"
33+
image_sequence = "image_sequence"
34+
binary = "binary"
3935

4036
Value = (
4137
None |

0 commit comments

Comments
 (0)