Commit Graph

346 Commits

Author SHA1 Message Date
HanishKVC db2ffabb18 ChatON: use templated json_get when loading bool key-value fields
With this now even loading chaton_meta.json file will generate
more informative exception, so that user can know which field
is missing, if any.
2024-05-12 18:26:58 +05:30
HanishKVC 470b8885f3 ChatON: Switch to templated json_get for str/bool/etal 2024-05-12 18:19:18 +05:30
HanishKVC 0249c07e6b ChatON:Switch to json_get_str to help identify missing keys better
The json library generates less informative exception message,
which doesnt help one identify which key is missing, so switch to
the new json_get_str helper added in the last commit. It generates
more informative exception message.
2024-05-12 17:44:13 +05:30
HanishKVC 4eae05a6b7 ChatON: json access helper which raises exception if key missing 2024-05-12 17:34:04 +05:30
HanishKVC f94fed92d3 ChatON+MetaHpp: Had forgotten to conv reverse-prompt
Also has dump was using get_value calls with fallback to default,
so it wasnt identifying the missed field.

Have fixed both of those. Also reconverted meta json file.

Misc: interesting avesham and aattam
2024-05-12 16:20:28 +05:30
HanishKVC a3285e8e25 ChatON:Include auto converted ChatONMeta.hpp chat template data
This should allow for using this generic chat templating code flow
along with the included chat template data, without needing to
load any json file at runtime.

However If user wants to change the already included chat template
data, or add new chat template standard/model related data, one can
explicitly load json file.

TODO: Need to cross check this flow once, but logically should work
2024-05-12 14:08:09 +05:30
HanishKVC 1574201f71 ChatON:LoadJSon:ChatTemplates: revPrompt, system-user flags
WIP:NOTE:

Initial go converting from json driven flow to ChatTemplatesGroupKV
related flow done. Needs to be tested.

A optional helper added to load ChatTemplates from a specified
json file.

Need to add a compile time initialized MapOfMapOfVariants wrt
the chat template details of models/standards already known
to the program. So that one can use the llama.cpp and this new
chat template logic, even without json dependency, if one doesnt
want to.
2024-05-12 01:45:19 +05:30
HanishKVC 444d2ccf9c ChatON:LoadJSON: ChatTemplates - global/system/user/assistant
Manually iterate the json object items using begin-end explicitly,
because the implicit iteration for loop related helpers for the
used json lib gives only the values and not a key-value pair.
2024-05-12 01:35:31 +05:30
HanishKVC 2efc09f2d0 ChatON: Unnecessarily indirect nlohmann json
code used for exploring/testing commited just for future reference
2024-05-12 00:42:17 +05:30
HanishKVC b944d04d08 ChatON: Add constructor for ChatTemplates which chains into GKV 2024-05-11 23:42:08 +05:30
HanishKVC d9959b74e7 GroupKV: Get ready for use in llama.cpp ++
Avoid defining GKV_TEST_PRG, used for self testing, by default

Add it to common library
2024-05-11 23:40:03 +05:30
HanishKVC 4a9a6ce256 ChatON: ChatONMetaDump switch to GKV/ChatTemplates based flow 2024-05-11 22:53:45 +05:30
HanishKVC 484c710eab GroupKV:Add GetValue which throws exception 2024-05-11 20:49:51 +05:30
HanishKVC 9d4450d51a GroupKV: Let dump return a string, rather than printing/logging 2024-05-11 19:43:34 +05:30
HanishKVC e999934e91 ChatON:WIP: initial go at GroupKV based flow, instead of json 2024-05-11 19:41:58 +05:30
HanishKVC f294fddf43 GroupKV: Add group_exists checker 2024-05-11 19:18:19 +05:30
HanishKVC dde72df9d3 GroupKV: Rename the internal map 2024-05-11 18:23:06 +05:30
HanishKVC fdefb39518 GroupKV:Make LDBUG macros conditional, avoid condition at usage site
Also change LWARN to LDBUG wrt previously GKV_DEBUG conditional
code
2024-05-11 13:30:56 +05:30
HanishKVC 7f03dd0d4b GroupKV: Add int32_t to variant list, to simplify int use
So that no need to explicitly specify <int64_t> or LL wrt int
literals, which dont need 64bit space by default.

Which also means one shouldnt/cant mix up type of value stored and
default type specified when getting.
2024-05-11 12:45:58 +05:30
HanishKVC 0342124946 GroupKV: Add to_str wrt vectors, help avoid compiler confusion 2024-05-11 12:27:42 +05:30
HanishKVC 7d7c59ec50 GroupKV:Simplify:P2: Rename tags, Make debug logs conditional
Rename all the log messages to have GKV and not SC.

The log messages in get_vector made conditional to GKV_DEBUG, this
was missed out earlier in simpcfg itself.
2024-05-11 11:57:27 +05:30
HanishKVC d764a9d395 GroupKV: Simplify code to the minimal needed for GroupKV - P1 2024-05-11 11:37:06 +05:30
HanishKVC 86b842b172 GroupKV: Duplicate SimpCfg to chop down into GroupKV
IE a minimal MapOfMapOfVariant, with some basic helpers.

This can be the basis of a ChatTemplates object, as well as
SimpCfg built on top of it.
2024-05-11 10:57:32 +05:30
HanishKVC c0506f94bf SimpCfg: Allow for direct initialization lists based init
This should pave way for having a default chat templates dataset
in the code, without needing to load it from a config file, if
one doesnt want to.

TODO: allow for loading config from json into simpcfg, so that
a program which uses llama.cpp can decide, whether it is ok with
what is already there in the internal dataset, or allow for loading
template info at runtime using the simpcfg's simple text file or
additionally include the json code to load template info at runtime
from json file.
2024-05-11 00:33:31 +05:30
HanishKVC fe27902964 SimpCfg: Avoid iostream/cout and format for direct library use
It appears like std::format is not supported in older g++/lib still
in wide use like current debian stable, so avoiding same wrt direct
library use.

Allow for empty VAARGS

NOTE: However test program mode of the same uses cout and format
2024-05-10 22:27:07 +05:30
HanishKVC 1f9a0eb8ce ChatON: Remove unneeded iostream 2024-05-10 21:10:44 +05:30
HanishKVC abb406b888 Merge branch 'master' into hkvc_chaton_v3
Have merged master branch has of 20240510IST12XY with chaton_v3
branch.

As part of same had to update the flow in examples/main/main.cpp
wrt conversion related commit in master branch and my chaton related
commits in this branch.
2024-05-10 13:14:26 +05:30
Johannes Gäßler c12452c7ae
JSON: [key] -> .at(key), assert() -> GGML_ASSERT (#7143) 2024-05-08 21:53:08 +02:00
Dawid Potocki 83330d8cd6
main : add --conversation / -cnv flag (#7108) 2024-05-08 17:32:32 +03:00
HanishKVC 8fe8231313 ChatON:SubPartsAwareTokenizePath: Allow extract subparts testing 2024-05-08 19:51:57 +05:30
HanishKVC a49697b488 ChatON: Keep compiler happy simbly 2024-05-08 19:22:46 +05:30
HanishKVC 868ab608f0 ChatON: Add forceParseSpecial flag to subparts aware tokenizing 2024-05-08 18:42:22 +05:30
HanishKVC b6da7d9c9d ChatON: tokenize keeping in mind the taggedMessage subparts
Initial go
2024-05-08 18:38:07 +05:30
HanishKVC 8dfa31bb91 ChatON: Make c-api wrappers a bit robust incl some cross checks
If the tagged message will be of 0 length, ensure that the passed
dest char* array, has null inserted appropriately.

Check that user has passed a non-null pNumParts.

Dont hard code int32_t size, pick using sizeof
2024-05-08 17:05:45 +05:30
Johannes Gäßler af0a5b6163
server: fix incorrectly reported token probabilities (#7125)
* server: normalize token probabilities

* fix temperature == 0.0f
2024-05-07 23:07:58 +02:00
HanishKVC 76791bad63 ChatON:Fix partsLengths to int32_t type, instead of int
so that the size of the elements is explicit and fixed, so that
it is inturn in sync with the fixed int size specified wrt the
c-api, even with any c compilers with different idea about int.

avoid some ununsed vars, need to update compile flags later to
enable corresponding warnings.
2024-05-07 12:40:49 +05:30
HanishKVC b3a56545d6 ChatON:Reposition alertAssistantAtEnd flag for consistency 2024-05-07 11:49:43 +05:30
HanishKVC 0852f3b7ec ChatON:ExCApi: Rename for consistency 2024-05-07 11:46:40 +05:30
HanishKVC 43a3a91b03 ChatON: Cleanup/Refine initial go at tmpl_apply_ex_capi 2024-05-07 11:44:25 +05:30
HanishKVC 7c288d3dfc ChatON: Rename to partstypes for consistency 2024-05-07 11:32:20 +05:30
HanishKVC 04b4a15177 ChatON: Initial go at chat-template-apply c-api with parts info 2024-05-07 11:08:47 +05:30
HanishKVC f6a86cd209 ChatON: Update the Note a bit 2024-05-07 10:29:16 +05:30
HanishKVC 989c6c4125 SimpCfg: Cleanup the Note a bit to avoid some ambiguities 2024-05-06 11:27:56 +05:30
HanishKVC 344c068d7b SimpCfg:MultiPart keys wrt get_vector
With this and past few commits, now there is simple yet sufficient
support to help move multi-level-hierarchy config files into the
SimpCfg's simple physically 1-level, but if reqd logically multi
level hierarchy flow.

B4 this series of commits also one could have still achieved this,
but there would have been bit more effort needed.
2024-05-06 11:27:56 +05:30
HanishKVC 19d3c88e8a SimpCfg:MultiPart keys wrt get_value etal 2024-05-06 11:27:56 +05:30
HanishKVC 623d0b60da SimpCfg: General MultiPart support, KeyParts not Key wrt SetValue 2024-05-06 11:27:56 +05:30
HanishKVC c6ecd9316e SimpCfg: Use to_str instead of using stringstream directly 2024-05-06 11:27:56 +05:30
HanishKVC 2b14bcaddb SimpCfg:ChatON: add by Humans for All note 2024-05-06 11:27:56 +05:30
HanishKVC 20e5b383c5 SimpCfg:Trim DumpHexString only if SC_DEBUG_VERBOSE 2024-05-06 11:27:56 +05:30
HanishKVC f53c19baac SimpCfg: Update the notes wrt tolower and add test code 2024-05-06 11:27:56 +05:30