Use message text as prompt when using default prompt

master
M66B 1 month ago
parent 29ea8b8d4c
commit 6925385074

@ -46,9 +46,7 @@ public class AI {
static Spanned completeChat(Context context, long id, CharSequence body, long template) throws JSONException, IOException { static Spanned completeChat(Context context, long id, CharSequence body, long template) throws JSONException, IOException {
String reply = null; String reply = null;
if (body == null || TextUtils.isEmpty(body.toString().trim())) { if (body == null || body.length() == 0 || template < 0L /* Default */) {
body = "?";
File file = EntityMessage.getFile(context, id); File file = EntityMessage.getFile(context, id);
if (file.exists()) { if (file.exists()) {
Document d = JsoupEx.parse(file); Document d = JsoupEx.parse(file);
@ -68,13 +66,20 @@ public class AI {
} }
String prompt = null; String prompt = null;
DB db = DB.getInstance(context); if (template < 0L)
EntityAnswer t = db.answer().getAnswer(template); prompt = (body == null ? null : body.toString());
if (t != null) { else {
String html = t.getHtml(context, null); DB db = DB.getInstance(context);
prompt = JsoupEx.parse(html).body().text(); EntityAnswer t = db.answer().getAnswer(template);
if (t != null) {
String html = t.getHtml(context, null);
prompt = JsoupEx.parse(html).body().text();
}
} }
if (body == null || body.length() == 0)
body = "?";
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (OpenAI.isAvailable(context)) { if (OpenAI.isAvailable(context)) {

@ -2697,7 +2697,7 @@ public class FragmentCompose extends FragmentBase {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", working); args.putLong("id", working);
args.putCharSequence("body", body); args.putCharSequence("body", body);
args.putLong("template", template == null ? -1L : template); args.putLong("template", template == null ? 0L : template);
new SimpleTask<Spanned>() { new SimpleTask<Spanned>() {
@Override @Override

Loading…
Cancel
Save