db87e014f2c53cdcf4c4e10c2d3cd41393ba3cb6
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fd5c631cbe |
image mcp: generate_image and generate_video take the model to use (XYenon)
XYenon on Discord asked whether an agent can pick the model magpie's image/video MCP draws with. Both tools now take an optional `model`, as provider/model: - The schema lists the models that may be asked (the Settings default first, then each on provider's OfferedDrawers or Videomakers), only those the calling gateway key may use. Up to 40 of them form an enum; past that, the description names three. - Left out, the Settings default is used, as before. - A bare id only one provider has, a ChatGPT account's other GPT Image name (ListedDrawer), or a newer family model (drawsFamily, grokVideoFamily) is accepted. Anything else is a tool error naming the models the key may use, and nothing is drawn. It never falls back. - The chosen model goes into the images/videos request's `model`, so the APIs' own key check (keyHolds, keyModelError, #882) refuses one the key may not use: the same check /v1/images makes. - The stdio Magpie Image server copies the gateway's `model` property from its tools/list, and asks the hidden JSON-RPC method magpie/media_model which model a call means. An older gateway (-32601) passes the model through as named. - `magpie tool generate_image --model ...` works through the schema; the usage text says so. Docs: gateway-routing.md (image MCP section), reference.md. Run (mote, via mote-run, at this tree): - gofmt -l: clean. - go vet ./... for darwin, GOOS=linux -tags nogui, GOOS=windows: ok. - go test -count=1 -timeout 45m ./internal/gateway/ ./internal/imagemcp/ ./internal/cli/: ok. Broken by hand: with `req["model"] = ref` dropped in imageMCPDraw and imageMCPFilm, TestImageMCPDrawsWithTheModelAsked, TestImageMCPModelHeldToTheKey and TestImageMCPVideoModelAsked go red (the default was drawn instead); restored, they pass. Not tried: a real vendor account. The fakes are easeled's art provider and the fake Grok. GUI files not run: no GUI file changed. |
||
|
|
ea1f9492bc |
cli: magpie tools lists, and magpie tool calls, the tools magpie's MCP servers give agents (iwinux)
iwinux on Discord (#feedback) wanted magpie's image generation, image recognition and web search without going through an agent's MCP, and had written a Python script for generate_image. magpie now has it: magpie tools [<name>] magpie tool <name> [--<param> <value>…] [<words>…] [-o <file|folder>] [--json] Both ask the running gateway's own MCP servers (gateway.OwnMCPServers: image, vision, web-search, plugin tools) over HTTP, with the local token and the magpie-tool/1 User-Agent, so the tools, schemas, models from Settings and usage counting are the ones an agent gets. Nothing is started besides (#3318: the cases sit before startUp, beside mcp). - Parameters are read against the tool's inputSchema: types (integer, number, boolean, array given once per item, object as JSON), enum, - and _ alike, --p v or --p=v. The words left over are the tool's one required text, else its prompt. An unknown flag or parameter, a missing required one, a bad value, a value given twice or both words and the same --param are refused with "nothing was called"; no request is sent. - A file path a parameter takes (its description says file and path) is made absolute, since the gateway doesn't know the current folder. - --help prints toolUsage (static): help is handled before anything runs. - A still-being-made answer is waited on with generation_result (1s between asks, 30 min at most). The gateway's image server now says so in _meta too: usemagpie.ai/pending is the id, usemagpie.ai/files the files made ({url, inline}); an older gateway is read from its text. - Images and videos are saved through imagemcp.Target (now exported): -o file or folder, else the current folder named from the prompt, numbered when more than one, never over a file that is there; a file not inline is downloaded by its path from the gateway asked (the token goes nowhere else). --json prints the raw answer and saves nothing. - No magpie at the address: "magpie isn't running at <url>: open the app or run magpie serve". MAGPIE_GATEWAY=<url> points at another. Docs: usage lines in magpie help, docs/reference.md (Use), the gateway routing subsystem page (_meta and the CLI), README en/zh, site docs start page en/zh/ja. Tests (internal/cli/tool_cli_test.go, never the network; every test sets MAGPIE_GATEWAY to its own httptest server): - TestToolsListsTheServersTools, TestToolReadsParameters, TestToolRefusesWhatItDoesntKnowAndCallsNothing (no tools/call, no file), TestToolHelpCallsNothing (no request at all), TestToolSavesTheImage, TestToolWaitsOnWhatIsStillMade (pending _meta, then the old text form, download with the key from the gateway asked, not the URL's host), TestToolErrorIsSaid, TestToolSaysMagpieIsntRunning, TestToolDrawsThroughTheGateway (the real gateway.New().Handler() with a fake vendor: lists, draws, saves the vendor's PNG). - TestImageMCPDrawsAndServesTheImage, ...SlowDrawingIsWaitedOn and ...MakesVideos now check the _meta. Red on the old behaviour: with withMeta setting nothing (what main answers) all three fail ("_meta map[], want pending img_…"). - Broken by hand: dropping the unknown-parameter check makes TestToolRefuses… red (the --model call was made); saving an inline image by its URL instead makes TestToolSavesTheImage red. Both restored. - TestHelpOnEveryCommandDoesNothing covers tool and tools. Run with this change on origin/main |