Skip to content

Commit

Permalink
Merge pull request #11 from docker/cm/jsonrpc
Browse files Browse the repository at this point in the history
Improve prompt runner
  • Loading branch information
ColinMcNeil authored Aug 14, 2024
2 parents 3a44977 + 6fff4c2 commit 7023789
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
16 changes: 15 additions & 1 deletion src/extension/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
21 changes: 5 additions & 16 deletions src/extension/ui/src/args.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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'
];

}

0 comments on commit 7023789

Please sign in to comment.