From 3832e197e1bb2cd76944df8efc1d2288d6b05fa9 Mon Sep 17 00:00:00 2001 From: rhodey Date: Fri, 20 Feb 2026 15:51:19 -0500 Subject: [PATCH] ask-joke accept joke as arg. always log ai thinking trace. and change to gpt-4o-mini. --- README.md | 17 +++++++++-------- justfile | 4 ++-- node/app.js | 4 ++-- node/ask-funds.js | 16 ++++++++-------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 36bff25..7222daf 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ just build-app { "Measurements": { "HashAlgorithm": "Sha384 { ... }", - "PCR0": "9a2f959805a56f8729c48e219591d2db1ec50af35c1c195b13cdc508d6ef81ecb1683fb7aa6f9f5901685f7fd2a95cc7", + "PCR0": "a858981f4dd9399b6de65c021b51631f383a3559b7cc78d44ecf84c9bb43d3640cb6adb6d483bf50200b78d07a975453", "PCR1": "4b4d5b3661b3efc12920900c80e126e4ce783c522de6c02a2a5bf7af3a2b9327b86776f188e4be1c1c404a129dbda493", - "PCR2": "b8a983e997c911dd5a0ad5bbb3322aa998180e4750b99dd2c6506189816e8de673c4fd46b67658bb05d7b9c936c726d5" + "PCR2": "b2fb1212bba8826d5feccfb6d43a9317d3789851cd6c0c57be241a4cfeef7401cc2e51fb245fbcbf0df153ddebfdd5af" } } ``` @@ -34,16 +34,17 @@ just serve-alpine just build-test-app make-test-fifos cp example.env .env docker compose up -d -just ask-funds +just ask-funds 'why did the worker quit his job at the recycling factory? because it was soda pressing.' ... -addr = wJQASiSgaqVJBP8iQUpyTpNcpQinMWg17unrNTbbYoC -sol = 0.025 +addr = Do3F8NmohXPayS3xmos6CmqRXPD9DjCzK8Ct8sCc6UkA +sol = 0.002 json = { - signatute: 'mHPgWppbhKujn8deozVGQurtpqPAcQ1nMg99uSmwmrmSp8m8GPRiXha36D2AJ42bNRzTG9xbhar1w7MRf2mUoLp', + signature: '677Rtf2CcUonuh9f2UJhxLgmiX4EwQrR7vQ6CTydstdTExgqpUtgpy2HPYfmYVZRrYBvFnrQQpbTJW78oVw8zi1h', from: 'AkHqQ324DvygPxuhyYs9BTVG8b1BXzTnpbCxqG8zousm', - to: 'wJQASiSgaqVJBP8iQUpyTpNcpQinMWg17unrNTbbYoC' + to: 'Do3F8NmohXPayS3xmos6CmqRXPD9DjCzK8Ct8sCc6UkA', + thoughts: "The joke plays on the pun between 'so depressing' and 'soda pressing', which is clever and light-hearted. It evokes a chuckle due to its wordplay." } -sol = 0.026 +sol = 0.003 (look inside node/ask-funds.js) ``` diff --git a/justfile b/justfile index 9a5dd67..f4170aa 100644 --- a/justfile +++ b/justfile @@ -62,8 +62,8 @@ build-test-app: add-funds: {{sudo}} docker run --rm --entrypoint /app/add-funds.sh --env-file .env lockhost-node-test-app -ask-funds: - {{sudo}} docker run --rm --entrypoint /app/ask-funds.sh --network locknet --env-file .env lockhost-node-test-app https://host:8888 +ask-funds joke: + {{sudo}} docker run --rm --entrypoint /app/ask-funds.sh --network locknet --env-file .env lockhost-node-test-app https://host:8888 {{joke}} mkcert: echo "authorityKeyIdentifier=keyid,issuer" > domains.ext diff --git a/node/app.js b/node/app.js index 063cdfb..305d8f9 100644 --- a/node/app.js +++ b/node/app.js @@ -88,7 +88,7 @@ async function askOpenAi(request, response) { ] let reply = await oai.chat.completions.create({ - model: 'gpt-4o', temperature: 1, + model: 'gpt-4o-mini', temperature: 1, tools, tool_choice: { type: 'function', 'function': { name: 'record_if_joke_was_funny' }}, messages, }) @@ -133,7 +133,7 @@ async function askOpenAi(request, response) { }) const from = solkey.publicKey.toBase58() - const data = JSON.stringify({ signature, from, to: addr }) + const data = JSON.stringify({ signature, from, to: addr, thoughts: reply.thoughts }) writeHead(response, 200) response.end(data) diff --git a/node/ask-funds.js b/node/ask-funds.js index 0fcce67..8d7f5a1 100644 --- a/node/ask-funds.js +++ b/node/ask-funds.js @@ -13,9 +13,9 @@ function onError(err) { const testFn = async (PCR, userData) => true // hit the api and ask oai for funds -async function main(api) { +async function main(api, joke) { // receiver - const mnemonic = 'test for ask' + const mnemonic = 'seed for test' const seed = bip39.mnemonicToSeedSync(mnemonic, '') const solkey = Keypair.fromSeed(seed.subarray(0, 32)) const addr = solkey.publicKey.toBase58() @@ -28,7 +28,7 @@ async function main(api) { console.log(`sol = ${balance}`) // the funny joke - const message = 'why did the worker quit his job at the recycling factory? because it was soda pressing' + const message = joke const params = new URLSearchParams({ message, addr }) // attestation doc validation plus encryption @@ -41,8 +41,8 @@ async function main(api) { const data = await response.json() console.log('json =', data) - // thoughts = reason for denial - if (data.thoughts) { return } + // no signature = no reward + if (!data.signature) { return } // balance after ask balance = await sol.getBalance(solkey.publicKey) @@ -50,6 +50,6 @@ async function main(api) { console.log(`sol = ${balance}`) } -const args = process.argv.slice(2) -const [api] = args -main(api).catch(onError) +const api = process.argv.slice(2)[0] +const joke = process.argv.slice(3).join(' ') +main(api, joke).catch(onError)