Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK no-code app error suggesting my app does not exist #150

Open
CakeCrusher opened this issue Jan 7, 2025 · 2 comments
Open

SDK no-code app error suggesting my app does not exist #150

CakeCrusher opened this issue Jan 7, 2025 · 2 comments

Comments

@CakeCrusher
Copy link

Running this:

print(WRITER_APP_ID)
app_res = client.applications.generate_content(
    application_id=WRITER_APP_ID,
    inputs=[
        {
            "id": "name1",
            "value": ["Input1"]
        }
    ]
)

print(app_res.model_dump_json(indent=2))

Results in this:

d1ffa...

---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
Cell In[16], [line 2](vscode-notebook-cell:?execution_count=16&line=2)
      [1](vscode-notebook-cell:?execution_count=16&line=1) print(WRITER_APP_ID)
----> [2](vscode-notebook-cell:?execution_count=16&line=2) app_res = client.applications.generate_content(
      [3](vscode-notebook-cell:?execution_count=16&line=3)     application_id=WRITER_APP_ID,
      [4](vscode-notebook-cell:?execution_count=16&line=4)     inputs=[
      [5](vscode-notebook-cell:?execution_count=16&line=5)         {
      [6](vscode-notebook-cell:?execution_count=16&line=6)             "id": "name1",
      [7](vscode-notebook-cell:?execution_count=16&line=7)             "value": ["Input1"]
      [8](vscode-notebook-cell:?execution_count=16&line=8)         }
      [9](vscode-notebook-cell:?execution_count=16&line=9)     ]
     [10](vscode-notebook-cell:?execution_count=16&line=10) )
     [12](vscode-notebook-cell:?execution_count=16&line=12) print(app_res.model_dump_json(indent=2))

File c:\Notes\writer\.venv\lib\site-packages\writerai\_utils\_utils.py:275, in required_args.<locals>.inner.<locals>.wrapper(*args, **kwargs)
    [273](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_utils/_utils.py:273)             msg = f"Missing required argument: {quote(missing[0])}"
    [274](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_utils/_utils.py:274)     raise TypeError(msg)
--> [275](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_utils/_utils.py:275) return func(*args, **kwargs)

File c:\Notes\writer\.venv\lib\site-packages\writerai\resources\applications.py:162, in ApplicationsResource.generate_content(self, application_id, inputs, stream, extra_headers, extra_query, extra_body, timeout)
    [160](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:160) if not application_id:
    [161](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:161)     raise ValueError(f"Expected a non-empty value for `application_id` but received {application_id!r}")
--> [162](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:162) return self._post(
    [163](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:163)     f"/v1/applications/{application_id}",
    [164](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:164)     body=maybe_transform(
    [165](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:165)         {
    [166](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:166)             "inputs": inputs,
    [167](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:167)             "stream": stream,
    [168](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:168)         },
    [169](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:169)         application_generate_content_params.ApplicationGenerateContentParams,
    [170](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:170)     ),
    [171](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:171)     options=make_request_options(
    [172](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:172)         extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
    [173](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/applications.py:173)     ),
...
   (...)
   [1069](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1069)     retries_taken=retries_taken,
   [1070](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1070) )

NotFoundError: Error code: 404 - {'tpe': 'fail.resource.generic', 'errors': [{'description': "Application d1ff... doesn't exist", 'key': 'fail.resource.generic', 'extras': None}], 'extras': None}
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?b0c42a2e-7cbc-4fb9-bf6d-1ffaaa4160a1) or open in a [text editor](command:workbench.action.openLargeOutput?b0c42a2e-7cbc-4fb9-bf6d-1ffaaa4160a1). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

I know my application exists as I have been using its API key for chat completion.

@samjulien
Copy link

Hey @CakeCrusher great to see you -- what type of no-code application is this? And is it deployed (whether to Writer Cloud or as an embedded application)?

@CakeCrusher
Copy link
Author

CakeCrusher commented Jan 9, 2025

@samjulien
(if you think this is solvable through the SDK alone (doubt it), happy to submit a PR, in that instance any guidance would be awesome)
Hi,
I created a Developer tools -> API app and used the API key and APP id from there.
This guide https://dev.writer.com/api-guides/quickstart leaves the app selection ambiguous, I imagine the intention in this case is to select the API app.
image

Also here is reproducible code:

from writerai import Writer
from dotenv import load_dotenv
import os

load_dotenv()

WRITER_API_KEY = os.getenv("WRITER_API_KEY")
WRITER_APP_ID = os.getenv("WRITER_APP_ID")
if not WRITER_API_KEY or not WRITER_APP_ID:
    raise ValueError("missing env vars")

client = Writer(api_key=WRITER_API_KEY)

app_res = client.applications.generate_content(
    application_id=WRITER_APP_ID,
    inputs=[
        {
            "id": "name1",
            "value": ["Input1"]
        }
    ]
)

print(app_res.model_dump_json(indent=2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants