File size: 1,237 Bytes
ba0ce5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import random
import argilla as rg
from chat_interface_preference import ChatInterface
def random_response(message, history, request):
response = random.choice(["Yes", "No"])
for char in response:
yield char
style = "<style>.user-message,.system-message{display:flex;margin:10px}.user-message .message-content{background-color:#c2e3f7;color:#000}.system-message .message-content{background-color:#f5f5f5;color:#000}.message-content{padding:10px;border-radius:10px;max-width:70%;word-wrap:break-word}.container{display:flex;justify-content:space-between}.column{width:48%}</style>"
client = rg.Argilla(api_url="https://davidberenstein1957-argilla-gradio.hf.space", api_key="owner.apikey")
required_settings = rg.Settings(
fields=[rg.TextField(name="conversation")],
questions=[
rg.TextQuestion(name="chosen"),
rg.TextQuestion(name="rejected"),
],
)
name = "test"
if client.datasets(name=name).exists():
dataset: rg.Dataset = client.datasets(name=name)
else:
dataset = rg.Dataset(name=name, settings=required_settings)
dataset.create()
demo = ChatInterface(random_response, cache_examples=False, css=style, rg_dataset=dataset)
if __name__ == "__main__":
demo.launch()
|