You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rudimentary support of openai chat completions tools calls (ggml-org#981)
* Rudimentary support of openai chat completions tools calls
-Most small models are not smart enough to do this, especially a combined tool call + role play response, but at least this allows experimentation along these lines with koboldcpp
* try to also support specified function and tool choice set to none
Allow tools start and end messages to be configured in adapter
Try to force grammar to specific function call if specified (untested)
* ensure tools get listed right after user content and before end of user message content
* omit grammars approach try prompting instead
-use more extensive json parsing and direct instructions to models to try to obtain the desired result
-seems to work relatively well with Mistral-7B-Instruct-v.0.3.Q4_K_M.gguf and neuralhermes-2.5-mistral-7b.Q4_K_M.gguf
-question of whether this is too opinionated of an approach, should the instructions be things that can be passed with the prompt template?
* add back llamacpp recommended json grammar
Go back to adding grammar but use "official" llamacpp grammar only not a custom one just for openai
* Tidy up, remove unnecessary globals
* clarity
* fix missing local variable error
This worked to fix the error I mentioned on my last comment
---------
Co-authored-by: Concedo <39025047+LostRuins@users.noreply.github.com>
response_array= [{"id": "insert an id for the response", "type": "function", "function": {"name": "insert the name of the function you want to call", "arguments": {"first property key": "first property value", "second property key": "second property value"}}}]
936
+
json_formatting_instruction=" Use this style of JSON object formatting to give your answer if you think the user is asking you to perform an action: "+json.dumps(response_array, indent=0)
json_formatting_instruction=f"The user is asking you to use the style of this JSON object formatting to complete the parameters for the specific function named {specified_function} in the following format: "+json.dumps([{"id": "insert an id for the response", "type": "function", "function": {"name": f"{specified_function}", "arguments": {"first property key": "first property value", "second property key": "second property value"}}}], indent=0)
944
+
exceptExceptionase:
945
+
# In case of any issues, just revert back to no specified function
946
+
pass
947
+
messages_string+=json_formatting_instruction
948
+
949
+
# Set temperature low automatically if function calling
950
+
genparams["temperature"] =0.2
951
+
genparams["using_openai_tools"] =True
952
+
953
+
# Set grammar to llamacpp example grammar to force json response (see https://github.com/ggerganov/llama.cpp/blob/master/grammars/json_arr.gbnf)
954
+
genparams["grammar"] =r"""
955
+
root ::= arr
956
+
value ::= object | array | string | number | ("true" | "false" | "null") ws
0 commit comments