diff --git a/src/extension/ui/src/App.tsx b/src/extension/ui/src/App.tsx index 71b1dc1..14c8f09 100644 --- a/src/extension/ui/src/App.tsx +++ b/src/extension/ui/src/App.tsx @@ -113,10 +113,24 @@ export function App() { } updateOutput("Running prompts\n") const args = getRunArgs(selectedPrompt!, selectedProject!, "", client.host.platform) + client.docker.cli.exec("run", args, { stream: { + splitOutputLines: true, onOutput: ({ stdout, stderr }) => { - output += stdout || stderr; + if (stdout && stdout.startsWith('{')) { + let rpcMessage = stdout.split('}Content-Length:')[0] + if (!rpcMessage.endsWith('}')) { + rpcMessage += '}' + } + const json = JSON.parse(rpcMessage) + if (json.params.content) { + output += json.params.content + } + } + if (stderr) { + output += stderr + } setRunOut(output); }, onError: (err) => { diff --git a/src/extension/ui/src/args.ts b/src/extension/ui/src/args.ts index dd7bb69..f1e6d04 100644 --- a/src/extension/ui/src/args.ts +++ b/src/extension/ui/src/args.ts @@ -1,15 +1,4 @@ export const getRunArgs = (prompt_ref: string, project_dir: string, username: string, platform: string) => { - // docker run --rm \ - // -it \ - // -v /var/run/docker.sock:/var/run/docker.sock \ - // --mount type=volume,source=docker-prompts,target=/prompts \ - // --mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ - // vonwig/prompts:latest \ - // run \ - // $PWD \ - // $USER \ - // "$(uname -o)" \ - // "github:docker/labs-githooks?ref=main&path=prompts/git_hooks" return [ '--rm', '-v', @@ -20,10 +9,10 @@ export const getRunArgs = (prompt_ref: string, project_dir: string, username: st 'type=volume,source=docker-prompts,target=/prompts', 'vonwig/prompts:latest', 'run', - project_dir, - username, - platform, - prompt_ref + "--host-dir", project_dir, + "--user", username, + "--platform", platform, + "--prompts", prompt_ref, + '--jsonrpc' ]; - } \ No newline at end of file