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 = "" 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()