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 {
String reply = null;
if (body == null || TextUtils.isEmpty(body.toString().trim())) {
body = "?";
if (body == null || body.length() == 0 || template < 0L /* Default */) {
File file = EntityMessage.getFile(context, id);
if (file.exists()) {
Document d = JsoupEx.parse(file);
@ -68,13 +66,20 @@ public class AI {
}
String prompt = null;
DB db = DB.getInstance(context);
EntityAnswer t = db.answer().getAnswer(template);
if (t != null) {
String html = t.getHtml(context, null);
prompt = JsoupEx.parse(html).body().text();
if (template < 0L)
prompt = (body == null ? null : body.toString());
else {
DB db = DB.getInstance(context);
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();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (OpenAI.isAvailable(context)) {

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

Loading…
Cancel
Save