mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-04-28 03:30:20 +00:00
strip_oaicontent_of_media placeholder (+2 squashed commit)
Squashed commit: [7ccd52ef4] placeholder [71fd2d7bb] strip_oaicontent_of_media
This commit is contained in:
parent
addea2b62a
commit
177e0d7515
1 changed files with 16 additions and 0 deletions
16
koboldcpp.py
16
koboldcpp.py
|
|
@ -2543,6 +2543,21 @@ def extract_all_names_from_tool_array(tools_array):
|
|||
pass
|
||||
return toolnames
|
||||
|
||||
def strip_oaicontent_of_media(oaicontent):
|
||||
if isinstance(oaicontent, list):
|
||||
outarr = []
|
||||
for x in oaicontent:
|
||||
if not isinstance(x, dict):
|
||||
outarr.append({"type": "unknown", "data": "(base64 data attached)"})
|
||||
continue
|
||||
xtype = x.get("type","data")
|
||||
if xtype=="text":
|
||||
outarr.append(x)
|
||||
else:
|
||||
outarr.append({"type":xtype, "data":"(base64 data attached)"})
|
||||
return outarr
|
||||
return oaicontent
|
||||
|
||||
#returns the found JSON of the correct tool to use, or None if no tool is suitable
|
||||
def determine_tool_json_to_use(genparams, curr_ctx, assistant_message_start, is_followup_tool):
|
||||
# tools handling: Check if user is passing a openai tools array, if so add to end of prompt before assistant prompt unless tool_choice has been set to None
|
||||
|
|
@ -2565,6 +2580,7 @@ def determine_tool_json_to_use(genparams, curr_ctx, assistant_message_start, is_
|
|||
for message in reversed_messages:
|
||||
if message["role"] == "user":
|
||||
last_user_message = message["content"]
|
||||
last_user_message = strip_oaicontent_of_media(last_user_message)
|
||||
last_user_message = f"\n\nUser's current request: {last_user_message}"
|
||||
break
|
||||
tool_call_chunk = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue