Skip to content

Commit

Permalink
add yaml parse error message
Browse files Browse the repository at this point in the history
  • Loading branch information
slimslenderslacks committed Nov 26, 2024
1 parent 5410cd5 commit c5e5155
Show file tree
Hide file tree
Showing 17 changed files with 363 additions and 131 deletions.
4 changes: 0 additions & 4 deletions dev/conversations_t.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
:prompts (fs/file "/Users/slim/docker/labs-ai-tools-for-devs/prompts/curl/README.md")
:host-dir "/Users/slim/vonwig/altaservice"})

(alter-var-root
#'jsonrpc/notify
(fn [_] (partial (if (:jsonrpc opts) jsonrpc/-notify jsonrpc/-println) opts)))

(try
(main/with-options opts ["run"])
(catch Throwable t
Expand Down
13 changes: 13 additions & 0 deletions graphs/prompts/journals/2024_11_21.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- `revo` for graphql/rag and fine-grained data access
- bismuth
- ratatui rust cli
- paige
- agents building infrastructure was super interesting
- > if you ask a really concise question, you'll get many fewer questions for clarification
- tinfoil
- attestations
- nvidia gpus now shipping with gpms
- confidentiality
- enclaves
- aws nitro hypervisors
-
1 change: 1 addition & 0 deletions graphs/prompts/journals/2024_11_22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [[br]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
- Run some prompts checked in to GitHub against a project in the current working directory.
id:: 66d779c7-c1b7-40c6-a635-fa712da492de
```sh
docker run
--rm -it \
--pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/host-services/backend.sock:/host-services/docker-desktop-backend.sock \
-e "DOCKER_DESKTOP_SOCKET_PATH=/host-services/docker-desktop-backend.sock" \
--mount type=volume,source=docker-prompts,target=/prompts \
-e "OPENAI_API_KEY_LOCATION=/root" \
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
vonwig/prompts:latest \
run \
--host-dir $PWD \
--platform $(uname -o) \
--prompts "github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker"
```
- Most of this is boiler plate except:
- the `--user` option in line 10 requires a valid DOCKER_HUB user name
- the `--prompts` option in line 12 requires a valid [github reference]([[GitHub Refs]]) to some markdown prompts
- if the project is located somewhere other than $PWD then the `--host-dir` will need to be updated.
- Run a local prompt markdown file against a project in the current working directory. In this example, the prompts are not pulled from GitHub. Instead, our prompts are being developed in a directory called `$PROMPTS_DIR`. In this example, the local prompt file is `$PROMPTS_DIR/myprompts.md`.
id:: 66d77f1b-1684-480d-ad7b-5e9f53292fe4
```sh
docker run
--rm -it \
--pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/host-services/backend.sock:/host-services/docker-desktop-backend.sock \
-e "DOCKER_DESKTOP_SOCKET_PATH=/host-services/docker-desktop-backend.sock" \
--mount type=volume,source=docker-prompts,target=/prompts \
-e "OPENAI_API_KEY_LOCATION=/root" \
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
--mount type=bind,source=$PROMPTS_DIR,target=/app/workdir \
--workdir /app/workdir \
vonwig/prompts:latest \
run \
--host-dir $PWD \
--platform $(uname -o) \
--prompts-file myprompts.md
```
- Most of this is boiler plate except:
- the `--user` option in line 12 requires a valid DOCKER_HUB user name
- the `--prompts-file` option in line 14 is a relative path to a prompts file (relative to $PROMPTS_DIR)
- if the project being analyzed is located somewhere other than $PWD then the `--host-dir` will need to be updated.
- [[Running the Prompt Engine]]
- [[Authoring Prompts]]
- id:: 66d7f3ff-8769-40b3-b6b5-fc4fceea879e
```
---
extractors:
- name: linguist
image: vonwig/go-linguist:latest
command:
- -json
output-handler: linguist
tools:
- name: findutils-by-name
description: find files in a project by name
parameters:
type: object
properties:
glob:
type: string
description: the glob pattern for files that should be found
container:
image: vonwig/findutils:latest
command:
- find
- .
- -name
model: llama3.1
url: http://localhost/v1/chat/completions
stream: false
---
# Prompt system
You are an expert on analyzing project content.
# Prompt user
{{#linguist}}
This project contains {{language}} code.
{{/linguist}}
Can you find any language specific project files and list them?
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
- Run some prompts checked in to GitHub against a project in the current working directory.
id:: 66d779c7-c1b7-40c6-a635-fa712da492de
```sh
docker run
--rm -it \
--pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/host-services/backend.sock:/host-services/docker-desktop-backend.sock \
-e "DOCKER_DESKTOP_SOCKET_PATH=/host-services/docker-desktop-backend.sock" \
--mount type=volume,source=docker-prompts,target=/prompts \
-e "OPENAI_API_KEY_LOCATION=/root" \
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
vonwig/prompts:latest \
run \
--host-dir $PWD \
--platform $(uname -o) \
--prompts "github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker"
```
- Most of this is boiler plate except:
- the `--user` option in line 10 requires a valid DOCKER_HUB user name
- the `--prompts` option in line 12 requires a valid [github reference]([[GitHub Refs]]) to some markdown prompts
- if the project is located somewhere other than $PWD then the `--host-dir` will need to be updated.
- Run a local prompt markdown file against a project in the current working directory. In this example, the prompts are not pulled from GitHub. Instead, our prompts are being developed in a directory called `$PROMPTS_DIR`. In this example, the local prompt file is `$PROMPTS_DIR/myprompts.md`.
id:: 66d77f1b-1684-480d-ad7b-5e9f53292fe4
```sh
docker run
--rm -it \
--pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /run/host-services/backend.sock:/host-services/docker-desktop-backend.sock \
-e "DOCKER_DESKTOP_SOCKET_PATH=/host-services/docker-desktop-backend.sock" \
--mount type=volume,source=docker-prompts,target=/prompts \
-e "OPENAI_API_KEY_LOCATION=/root" \
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
--mount type=bind,source=$PROMPTS_DIR,target=/app/workdir \
--workdir /app/workdir \
vonwig/prompts:latest \
run \
--host-dir $PWD \
--platform $(uname -o) \
--prompts-file myprompts.md
```
- Most of this is boiler plate except:
- the `--user` option in line 12 requires a valid DOCKER_HUB user name
- the `--prompts-file` option in line 14 is a relative path to a prompts file (relative to $PROMPTS_DIR)
- if the project being analyzed is located somewhere other than $PWD then the `--host-dir` will need to be updated.
- [[Running the Prompt Engine]]
- [[Authoring Prompts]]
- ---
id:: 66d7f3ff-8769-40b3-b6b5-fc4fceea879e
extractors:
- name: linguist
image: vonwig/go-linguist:latest
command:
- -json
output-handler: linguist
tools:
- name: findutils-by-name
description: find files in a project by name
parameters:
type: object
properties:
glob:
type: string
description: the glob pattern for files that should be found
container:
image: vonwig/findutils:latest
command:
- find
- .
- -name
model: llama3.1
url: http://localhost/v1/chat/completions
stream: false
---

# Prompt system

You are an expert on analyzing project content.

# Prompt user

{{#linguist}}
This project contains {{language}} code.
{{/linguist}}

Can you find any language specific project files and list them?
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Prompt files
The simplest prompt file is just markdown content. We use `h1` headers to delineate the blocks containing prompts and the name of the header to determine the prompt role.
A prompt file can also contain metadata about how to generate and run the prompt.
{{embed ((66d7f3ff-8769-40b3-b6b5-fc4fceea879e)) }}
The example above defines a lot of metadata. A prompt file might also be very simple.
{{embed ((66d8a396-9268-4917-882f-da4c52b7b5dd)) }}
Use the [prompt engine]([[Running the Prompt Engine]]) to run this prompt file against an LLM.
- ## Prompt Metadata
-
3 changes: 3 additions & 0 deletions graphs/prompts/pages/volumes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Volumes are managed by the top-level container. In other words, we construct them as we need them.
- the `--thread-id` allows the user of the prompt engine to control the names of the volume
- by default, tool containers will be started with at least one volume mounted at `/thread`
11 changes: 11 additions & 0 deletions prompts/examples/empty-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Summary

This prompt defines no tools. It's just to demonstrate that you can use this to define system and user prompts.

# prompt system

You try to start every sentence with the letter 'a'.

# prompt user

Can you give me a quick summary of the NASA space program?
3 changes: 3 additions & 0 deletions prompts/examples/no-prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Summary

There are no prompts or tools in this file. The engine should complain.
2 changes: 1 addition & 1 deletion prompts/sql/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tools:
type: string
description: a human description of the query we need to run
type: "prompt"
prompt: sql-agent.md
prompt: github:docker/labs-ai-tools-for-devs?path=prompts/sql/sql-agent.md
host-dir: /Users/slim/docker/labs-ai-tools-for-devs/prompts/sql # override host-dir while testing
---

Expand Down
24 changes: 3 additions & 21 deletions src/docker.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[cheshire.core :as json]
[clojure.core.async :as async]
[clojure.pprint :refer [pprint]]
[clojure.spec.alpha :as spec]
[clojure.string :as string]
[creds]
jsonrpc
logging)
logging
schema)
(:import
[java.net UnixDomainSocketAddress]
[java.nio ByteBuffer]
Expand Down Expand Up @@ -225,25 +225,6 @@
"--vs-machine-id" "none"
"--workspace" "/docker"]})

(spec/def ::host-dir string?)
(spec/def ::entrypoint string?)
(spec/def ::user string?)
(spec/def ::jwt string?)
(spec/def ::image string?)
(spec/def ::command (spec/coll-of string?))
(spec/def ::container-definition (spec/keys :opt-un [::host-dir ::entrypoint ::command ::user ::jwt]
:req-un [::image]))

(spec/def ::pty-output string?)
(spec/def ::exit-code integer?)
(spec/def ::info any?)
(spec/def ::done #{:timeout :exited})
(spec/def ::timeout integer?)
(spec/def ::kill-container any?)

(spec/def ::container-response (spec/keys :req-un [::pty-output ::exit-code ::info ::done]
:opt-un [::timeout ::kill-container]))

(defn- -pull [m]
(pull (merge m
{:serveraddress "https://index.docker.io/v1/"}
Expand Down Expand Up @@ -384,6 +365,7 @@
" params ::container-definition
returns ::container-response"
[m]
;; (schema/validate :schema/container-definition)
(if (-> m :stdin :file)
(run-with-stdin-content m)
(run-function m)))
Expand Down
Loading

0 comments on commit c5e5155

Please sign in to comment.