Jason commited on
Commit
74815a7
·
1 Parent(s): eea53ad

test argilla

Browse files
Files changed (2) hide show
  1. app.py +51 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import argilla as rg
3
+ from datasets import load_dataset
4
+
5
+ # Connect to Argilla (adjust URL and API key as needed)
6
+ rg.init(
7
+ api_url="https://jhsu12/MedLLM-DataAnnotation-argilla-space.hf.space",
8
+ #api_key="your-api-key",
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()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.0.0
2
+ argilla
3
+ huggingface_hub