cloudflare / cloudflare/workerd

🐛 BUG: Python module cloudflare using workers ai fails with @cf/lykon/dreamshaper-8-lcm

Open
#3,681 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

### Which Cloudflare product(s) does this pertain to?

Workers AI

### What versions are you using?

python cloudflare 4.0.0

### What operating system and version are you using?

Windows 11

### Please provide a link to a minimal reproduction

_No response_

### Describe the Bug

When calling:

```
from cloudflare import Cloudflare


cf_client = Cloudflare(api_token="")
resp_image = cf_client.ai.run(
model_name="@cf/lykon/dreamshaper-8-lcm",
account_id="",
prompt="cyberpunk cat",
)
```
Code fails at "_wrappers.py":

```
class ResultWrapper(GenericModel, Generic[_T]):
result: _T

@staticmethod
def _unwrapper(obj: "ResultWrapper[_T]") -> _T:
return obj.result
```

because returned obj has no result, it is just a string.

### Please provide any relevant error logs

File "~\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...

File "~\site-packages\cloudflare\_response.py", line 313, in parse
parsed = self._options.post_parser(parsed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\site-packages\cloudflare\_wrappers.py", line 17, in _unwrapper
return obj.result
^^^^^^^^^^
AttributeError: 'str' object has no attribute 'result'

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.