Skip to content

Commit fd1df8e

Browse files
committed
change messages tool to use file2run
1 parent 74b24b1 commit fd1df8e

5 files changed

Lines changed: 47 additions & 52 deletions

File tree

README.md

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Basic toolset for [Tune](https://github.com/iovdin/tune).
1515
- [powershell](#powershell) execute PowerShell command
1616
- [osa](#osa) manage reminders/notes/calendar (AppleScript/macOS)
1717
- [jina_r](#jina_r) fetch webpage content
18-
- [turn](#turn) turn based agent
1918
- [list](#list) keep list of tasks todo (loops for LLM)
2019
- [sqlite](#sqlite) execute sqlite queries
2120
- [py](#py) run python code
2221
- [js](#js) run javascript code
23-
- [message](#message) talk to another chat/agent
22+
- [turn](#turn) handoff based agent (shared context)
23+
- [message](#message) talk to another chat/agent (separate context)
2424
- [Processors](#processors)
2525
- [proc](#proc) converts tool to processor
2626
- [shp](#shp) include shell command output
@@ -220,39 +220,6 @@ Tune is a versatile toolkit designed for developers and users to effectively int
220220
```
221221

222222

223-
### `turn`
224-
A way to switch roles when building multistep agents [read more](https://iovdin.github.io/tune/examples/multi-agent)
225-
```chat
226-
system: @turn @gpt-4o
227-
You're playing 20 questions game.
228-
You switch turns between 'thinker' and 'player' agent.
229-
Current agent stored in agent.txt file
230-
'player' always plays first
231-
232-
@@agent|init
233-
assistant:
234-
Is it a living thing?
235-
236-
tool_call: turn {"role":"thinker","filename":"agent.txt"}
237-
tool_result: now it is turn of thinker to reply
238-
239-
assistant:
240-
No.
241-
242-
tool_call: turn {"role":"player","filename":"agent.txt"}
243-
tool_result: now it is turn of player to reply
244-
245-
assistant:
246-
Is it something that can be used indoors?
247-
248-
tool_call: turn {"role":"thinker","filename":"agent.txt"}
249-
tool_result: now it is turn of thinker to reply
250-
251-
assistant:
252-
Yes.
253-
254-
...
255-
```
256223

257224
### `list`
258225
Keep list of tasks to do
@@ -353,6 +320,41 @@ tool_result:
353320
354321
```
355322

323+
### `turn`
324+
A way to switch roles when building multistep agents [read more](https://iovdin.github.io/tune/examples/multi-agent)
325+
```chat
326+
system: @gpt-4o
327+
@{ turn | curry filename=agent.txt}
328+
You're playing 20 questions game.
329+
You switch turns between 'thinker' and 'player' agent.
330+
'player' always plays first
331+
332+
@@agent|init
333+
assistant:
334+
Is it a living thing?
335+
336+
tool_call: turn {"name": "thinker"}
337+
tool_result:
338+
now it is turn of thinker to reply
339+
340+
assistant:
341+
No.
342+
343+
tool_call: turn {"role":"player"}
344+
tool_result: now it is turn of player to reply
345+
346+
assistant:
347+
Is it something that can be used indoors?
348+
349+
tool_call: turn {"role":"thinker"}
350+
tool_result: now it is turn of thinker to reply
351+
352+
assistant:
353+
Yes.
354+
355+
...
356+
```
357+
356358
### `message`
357359
Talk to another chat/agent via tool call.
358360
Orchestrate or evaulate other agents/chats.
@@ -362,19 +364,19 @@ system:
362364
Your goal is to talk to Groot at `groot.prompt` system prompt
363365
and try to make him say anything but 'I am Groot'
364366
365-
tool_call: message {"filename":"groot.chat","system":"groot.prompt"}
367+
tool_call: message {"filename":"groot.chat","system":"@@groot.prompt"}
366368
Hello Groot! How are you feeling today?
367369
368370
tool_result:
369371
I am Groot!
370372
371-
tool_call: message {"filename":"groot.chat","system":"groot.prompt"}
373+
tool_call: message {"filename":"groot.chat"}
372374
What do you think about trees?
373375
374376
tool_result:
375377
I am Groot!
376378
377-
tool_call: message {"filename":"groot.chat","system":"groot.prompt"}
379+
tool_call: message {"filename":"groot.chat"}
378380
Can you tell me a joke?
379381
380382
tool_result:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tune-basic-toolset",
3-
"version": "0.1.9",
3+
"version": "0.1.10",
44
"description": "Basic toolset for tune",
55
"main": "src/index.js",
66
"files": [

src/message.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"system": {
1111
"type": "string",
12-
"description": "Filename that contains system prompt, required once at the beginning of simulation"
12+
"description": "System prompt, to include file use @@path/to/file or @@file syntax"
1313
},
1414
"text": {
1515
"type": "string",

src/message.tool.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
module.exports = async function message({ filename, system, text, stop }, ctx) {
2-
let chat = await ctx.read(filename);
3-
if (!chat && system) {
4-
chat = `system: @@${system}`
1+
module.exports = async function message({ filename, system, text, stop, save, ...args }, ctx) {
2+
if (typeof(save) === "undefined") {
3+
save = !!filename
54
}
6-
chat = `${chat}\nuser:\n${text}`
7-
const messages = await ctx.text2run(chat, {stop: "assistant" })
8-
chat = `${chat}\n${ctx.msg2text(messages, true)}`
9-
await ctx.write(filename, chat)
10-
if (messages.length) {
11-
return messages[messages.length - 1].content
12-
}
13-
return ""
5+
return ctx.file2run({ stop, filename, system, user: text, save }, args, ctx)
146
}

src/mock.proc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = async function mock(node, args, ctx) {
2+
//TODO it is not resolved into sub prompts
23
const re = /(?<name>\w+)\s*=/
34
let lastName;
45
let m;

0 commit comments

Comments
 (0)