Skip to content

Commit 245fe78

Browse files
committed
chatllm_user_input understands --multimedia-file-tags
1 parent e56b1a8 commit 245fe78

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

src/main.cpp

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,27 +1755,12 @@ static void chatllm_continue_chat(Chat *chat)
17551755
chat->history[last_id].content.push_back(output);
17561756
}
17571757

1758-
int chatllm_user_input(struct chatllm_obj *obj, const char *utf8_str)
1759-
{
1760-
chatllm_multimedia_msg_prepare(obj);
1761-
chatllm_multimedia_msg_append(obj, "text", utf8_str);
1762-
return chatllm_user_input_multimedia_msg(obj);
1763-
}
1764-
1765-
int chatllm_user_input_multimedia_msg(struct chatllm_obj *obj)
1758+
static int chatllm_generate(struct chatllm_obj *obj)
17661759
{
1767-
int r = 0;
1760+
int r = -0;
17681761
DEF_CHAT_STREAMER();
1769-
auto role_user = chat->gen_config.reversed_role ? chatllm::MsgRole::Assistant : chatllm::MsgRole::User;
17701762
auto role_asst = chat->gen_config.reversed_role ? chatllm::MsgRole::User : chatllm::MsgRole::Assistant;
17711763

1772-
if (!streamer->is_prompt) return -1;
1773-
1774-
if (chat->pipeline->is_loaded() && (chat->pipeline->model->get_purpose() != chatllm::ModelPurpose::Chat))
1775-
return -1;
1776-
1777-
chat->history.push_back(chat->content_scratch, role_user);
1778-
17791764
generate:
17801765
std::string output = chat->pipeline->chat(chat->history, chat->gen_config, streamer);
17811766
chat->history.push_back(output, role_asst);
@@ -1799,6 +1784,37 @@ int chatllm_user_input_multimedia_msg(struct chatllm_obj *obj)
17991784
return r;
18001785
}
18011786

1787+
int chatllm_user_input(struct chatllm_obj *obj, const char *utf8_str)
1788+
{
1789+
DEF_CHAT_STREAMER();
1790+
auto role_user = chat->gen_config.reversed_role ? chatllm::MsgRole::Assistant : chatllm::MsgRole::User;
1791+
1792+
if (!streamer->is_prompt) return -1;
1793+
1794+
if (chat->pipeline->is_loaded() && (chat->pipeline->model->get_purpose() != chatllm::ModelPurpose::Chat))
1795+
return -1;
1796+
1797+
chat->history.push_back(utf8_str, role_user);
1798+
1799+
return chatllm_generate(obj);
1800+
}
1801+
1802+
int chatllm_user_input_multimedia_msg(struct chatllm_obj *obj)
1803+
{
1804+
int r = 0;
1805+
DEF_CHAT_STREAMER();
1806+
auto role_user = chat->gen_config.reversed_role ? chatllm::MsgRole::Assistant : chatllm::MsgRole::User;
1807+
1808+
if (!streamer->is_prompt) return -1;
1809+
1810+
if (chat->pipeline->is_loaded() && (chat->pipeline->model->get_purpose() != chatllm::ModelPurpose::Chat))
1811+
return -1;
1812+
1813+
chat->history.push_back(chat->content_scratch, role_user);
1814+
1815+
return chatllm_generate(obj);
1816+
}
1817+
18021818
int chatllm_async_user_input(struct chatllm_obj *obj, const char *utf8_str)
18031819
{
18041820
ASYNC_FUN_BODY(chatllm_user_input(obj, utf8_str));

0 commit comments

Comments
 (0)