Skip to content
Snippets Groups Projects
Commit 6c484fc0 authored by Grießhaber Daniel's avatar Grießhaber Daniel :squid:
Browse files

add textual editor

parent df42a740
No related branches found
No related tags found
1 merge request!5Llm as a judge
......@@ -5,6 +5,9 @@ from itertools import zip_longest
from pathlib import Path
from typing import Any, Optional
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Footer, TextArea
from tqdm import tqdm, trange
from evoprompt.models import LLMModel
......@@ -18,6 +21,20 @@ logger = logging.getLogger(__name__)
PARAPHRASE_PROMPT = """You are given an instruction that describes a task. Write a response that paraphrases the instruction. Only output the paraphrased instruction bracketed in <prompt> and </prompt>."""
class EditText(App):
BINDINGS = [
Binding(key="q", action="quit", description="Quit the app"),
]
def __init__(self, text):
self.text = text + "asdasdasd"
super().__init__()
def compose(self) -> ComposeResult:
self.text_area = TextArea.code_editor(self.text)
yield Footer(self.text_area)
@log_calls("Paraphrasing prompts")
def paraphrase_prompts(
model: LLMModel,
......@@ -266,6 +283,11 @@ class PromptOptimization:
logger.info(f"Prompt judged as bad. Letting User change the prompt.")
editor = EditText(response)
editor.run()
response = editor.text_area.text
print(response)
def load_snapshot(path: Path):
import json
......
......@@ -10,3 +10,4 @@ py7zr
rouge-score
sacrebleu
sacremoses
textual
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment