Skip to content

Commit

Permalink
#4292 - ollama-based recommender
Browse files Browse the repository at this point in the history
- Template variable hints
  • Loading branch information
reckart committed Dec 1, 2023
1 parent ed5a259 commit 40ac46d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@
<div class="row form-row" wicket:enclosure="prompt">
<label class="col-sm-3 col-form-label" wicket:for="prompt">
<wicket:message key="prompt"/>
<div class="small text-muted">
<div class="small text-muted mb-2">
<i class="fas fa-torii-gate"></i> Jinja supported
</div>
<div wicket:id="promptHints" class="small text-muted"/>
</label>
<div class="col-sm-9">
<textarea wicket:id="prompt" class="form-control" rows="10"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.util.ListModel;
Expand All @@ -49,6 +50,7 @@
import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxFormComponentUpdatingBehavior;
import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxLink;
import de.tudarmstadt.ukp.inception.support.lambda.LambdaAjaxSubmitLink;
import de.tudarmstadt.ukp.inception.support.markdown.MarkdownLabel;

public class OllamaRecommenderTraitsEditor
extends AbstractTraitsEditor
Expand Down Expand Up @@ -109,7 +111,14 @@ protected void onSubmit()
form.add(new TextField<String>("model"));
form.add(new TextArea<String>("prompt"));
form.add(new CheckBox("raw").setOutputMarkupPlaceholderTag(true));
form.add(new PromptingModeSelect("promptingMode"));
var markdownLabel = new MarkdownLabel("promptHints",
LoadableDetachableModel.of(this::getPromptHints));
markdownLabel.setOutputMarkupId(true);
form.add(markdownLabel);
form.add(new PromptingModeSelect("promptingMode")
.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
_target.add(markdownLabel);
})));
form.add(new ExtractionModeSelect("extractionMode"));
form.add(new OllamaResponseFormatSelect("format"));
add(form);
Expand Down Expand Up @@ -169,4 +178,9 @@ private void removeOptionSetting(AjaxRequestTarget aTarget, OptionSetting aBindi
optionSettings.getObject().remove(aBinding);
aTarget.add(optionSettingsContainer);
}

private String getPromptHints()
{
return traits.getObject().getPromptingMode().getHints();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,32 @@
public enum PromptingMode
{
@JsonProperty("per-annotation")
PER_ANNOTATION, //
PER_ANNOTATION("""
Template variables:
* `text`: annotation text,
* `sentence`: sentence containing annotation,
* `examples`: labeled annotations"""),

@JsonProperty("per-sentence")
PER_SENTENCE, //
PER_SENTENCE("""
Template variables:
* `text`: sentence text,
* `examples`: labeled annotations"""),

@JsonProperty("per-document")
PER_DOCUMENT
PER_DOCUMENT("""
Template variables:
* `text`: document text""");

private final String hints;

private PromptingMode(String aHints)
{
hints = aHints;
}

public String getHints()
{
return hints;
}
}

0 comments on commit 40ac46d

Please sign in to comment.