Skip to content

Commit 46cafef

Browse files
author
Chris Warren-Smith
committed
LLAMA: updated nitro agent - wip
1 parent 5bff373 commit 46cafef

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

llama/samples/nitro_cli.bas

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@ const n_penalty_repeat = 1.0
3131
const n_penalty_last_n = 256
3232
const n_gpu_layers = 32
3333

34-
sandbox_home = iff(len(command) > 0, trim(command), cwd)
35-
if (left(sandbox_home) == "~") then
36-
sandbox_home = home + mid(sandbox_home, 1)
37-
endif
34+
'
35+
' joins the left and right sides with forward slash
36+
'
37+
func join_path(s1, s2)
38+
if (right(s1, 1) == "/") then
39+
s1 = left(s1, len(s1) - 1)
40+
endif
41+
if (left(s2, 1) == "/") then
42+
s2 = mid(s2, 2)
43+
endif
44+
return s1 + "/" + s2
45+
end
3846

3947
'
4048
' Displays the welcome message
@@ -82,9 +90,9 @@ end
8290
'
8391
func tool_read_file(arg)
8492
try
85-
tload sandbox_home + arg, result, 1
93+
tload join_path(sandbox_home, arg), result, 1
8694
catch
87-
result = "ERROR: File not found or unreadable."
95+
result = "ERROR: File not found or unreadable: " + arg
8896
end try
8997
return result
9098
end
@@ -120,7 +128,7 @@ end
120128
'
121129
func tool_write_file(arg, s)
122130
try
123-
tsave sandbox_home + arg, s
131+
tsave join_path(sandbox_home, arg), s
124132
result = "OK: Data written successfully to " + arg
125133
catch e
126134
result = "ERROR: " + e
@@ -133,8 +141,13 @@ end
133141
'
134142
func tool_permission()
135143
local k
136-
input "Agree?"; k
137-
return iff(trim(k) == "YES", "YES", "NO")
144+
input "Agree:? ", k
145+
select case lower(k)
146+
case "y", "yes", "sure", "okay", "k"
147+
return "YES"
148+
case else
149+
return "NO"
150+
end select
138151
end
139152

140153
'
@@ -155,11 +168,11 @@ func process_tool(cmd)
155168
endif
156169
endif
157170

158-
' print RED
159-
' print "["+op+"]"
160-
' print "["+arg1+"]"
161-
' print "["+arg2+"]"
162-
' print RESET
171+
print RED
172+
print "["+op+"]"
173+
print "["+arg1+"]"
174+
print "["+arg2+"]"
175+
print RESET
163176

164177
select case op
165178
case "TOOL:DATE"
@@ -182,7 +195,7 @@ func process_tool(cmd)
182195
result = "ERROR: unknown command " + op
183196
end select
184197

185-
'print RED + "TOOL RESULT:" + result + RESET
198+
print RED + "TOOL RESULT:" + result + RESET
186199
return result
187200
end
188201

@@ -298,6 +311,14 @@ sub main()
298311
wend
299312
end
300313

314+
sandbox_home = iff(len(command) > 0, trim(command), cwd)
315+
if (left(sandbox_home) == "~") then
316+
sandbox_home = join_path(home, mid(sandbox_home, 1))
317+
else if (left(sandbox_home, 2) == "./") then
318+
sandbox_home = join_path(cwd, mid(sandbox_home, 2))
319+
endif
320+
301321
welcome_message()
302322
main()
303323

324+

0 commit comments

Comments
 (0)