Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to support agent chat sft. #572

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions finetune_demo/finetune.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照评论修改

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
import json
import jieba
import dataclasses as dc
import functools
Expand Down Expand Up @@ -243,6 +244,18 @@ def process_message(message):
v is not None}
elif 'tools' in message:
del message['tools']

# convert tarin data of agent chat.
if message['role'] == 'assistant':
content = message['content']
if isinstance(content, str) and content.startswith("{") and content.endswith("}"):
try:
content_ = eval(content)
if isinstance(content_, dict) and "name" in content_ and "arguments" in content_:
message['content'] = json.dumps(content_["arguments"], ensure_ascii=False)
message['metadata'] = content_["name"]
except:
pass
return message


Expand Down