Jason commited on
Commit
5874926
·
1 Parent(s): 74815a7
Files changed (1) hide show
  1. app.py +40 -40
app.py CHANGED
@@ -9,43 +9,43 @@ rg.init(
9
  #extra_headers={"Authorization": f"Bearer YOUR_HF_TOKEN"}
10
  )
11
 
12
- banking_ds = load_dataset("argilla/banking_sentiment_setfit", split="train")
13
-
14
- # Argilla expects labels in the annotation column
15
- banking_ds = banking_ds.rename_column("label", "annotation")
16
-
17
- # Build argilla dataset from datasets
18
- argilla_ds = rg.read_datasets(banking_ds, task="TextClassification")
19
-
20
- rg.log(argilla_ds, "banking_sentiment")
21
-
22
- # def evaluate_response(prompt, response, quality, feedback):
23
- # record = rg.FeedbackRecord(
24
- # fields={"prompt": prompt, "llm_response": response},
25
- # responses=[{
26
- # "values": {
27
- # "quality": quality,
28
- # "feedback": feedback
29
- # }
30
- # }]
31
- # )
32
- # dataset = rg.FeedbackDataset.from_argilla("llm-eval")
33
- # dataset.add_records(record)
34
- # return "Evaluation submitted!"
35
-
36
- # with gr.Blocks() as demo:
37
- # gr.Markdown("## LLM Response Evaluation")
38
- # with gr.Row():
39
- # prompt = gr.Textbox(label="Original Prompt")
40
- # response = gr.Textbox(label="LLM Response")
41
- # quality = gr.Radio([1,2,3,4,5], label="Quality Rating")
42
- # feedback = gr.Textbox(label="Additional Feedback")
43
- # submit = gr.Button("Submit")
44
- # output = gr.Textbox()
45
- # submit.click(
46
- # fn=evaluate_response,
47
- # inputs=[prompt, response, quality, feedback],
48
- # outputs=output
49
- # )
50
-
51
- # demo.launch()
 
9
  #extra_headers={"Authorization": f"Bearer YOUR_HF_TOKEN"}
10
  )
11
 
12
+ # banking_ds = load_dataset("argilla/banking_sentiment_setfit", split="train")
13
+
14
+ # # Argilla expects labels in the annotation column
15
+ # banking_ds = banking_ds.rename_column("label", "annotation")
16
+
17
+ # # Build argilla dataset from datasets
18
+ # argilla_ds = rg.read_datasets(banking_ds, task="TextClassification")
19
+
20
+ # rg.log(argilla_ds, "banking_sentiment")
21
+
22
+ def evaluate_response(prompt, response, quality, feedback):
23
+ record = rg.FeedbackRecord(
24
+ fields={"prompt": prompt, "llm_response": response},
25
+ responses=[{
26
+ "values": {
27
+ "quality": quality,
28
+ "feedback": feedback
29
+ }
30
+ }]
31
+ )
32
+ dataset = rg.FeedbackDataset.from_argilla("llm-eval")
33
+ dataset.add_records(record)
34
+ return "Evaluation submitted!"
35
+
36
+ with gr.Blocks() as demo:
37
+ gr.Markdown("## LLM Response Evaluation")
38
+ with gr.Row():
39
+ prompt = gr.Textbox(label="Original Prompt")
40
+ response = gr.Textbox(label="LLM Response")
41
+ quality = gr.Radio([1,2,3,4,5], label="Quality Rating")
42
+ feedback = gr.Textbox(label="Additional Feedback")
43
+ submit = gr.Button("Submit")
44
+ output = gr.Textbox()
45
+ submit.click(
46
+ fn=evaluate_response,
47
+ inputs=[prompt, response, quality, feedback],
48
+ outputs=output
49
+ )
50
+
51
+ demo.launch()