Skip to content

Commit

Permalink
fix dump hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
monofuel committed Apr 21, 2024
1 parent 1c06d2c commit ee59d47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/llama_leap.nim
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ proc dumpHook(v: var ShowModel, fieldName: var string) =
fieldName = "template"


proc dumpHook(s: var string, v: object) =
proc dumpHook*(s: var string, v: object) =
## jsony `hack` to skip optional fields that are nil
s.add '{'
var i = 0
Expand Down
25 changes: 24 additions & 1 deletion tests/test_llama_leap.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,31 @@

import llama_leap, jsony, std/[unittest, json, options, strutils]

proc dumpHook*(s: var string, v: object) =
## jsony `hack` to skip optional fields that are nil
s.add '{'
var i = 0
# Normal objects.
for k, e in v.fieldPairs:
when compiles(e.isSome):
if e.isSome:
if i > 0:
s.add ','
s.dumpHook(k)
s.add ':'
s.dumpHook(e)
inc i
else:
if i > 0:
s.add ','
s.dumpHook(k)
s.add ':'
s.dumpHook(e)
inc i
s.add '}'

const
TestModel = "llama2"
TestModel = "llama3"
TestModelfileName = "test-pirate-llama2"

suite "llama_leap":
Expand Down

0 comments on commit ee59d47

Please sign in to comment.