import gradio as gr import tiktoken import html def get_color(token_index): colors = ["#E53935", "#1E88E5", "#43A047", "#FDD835", "#FB8C00", "#8E24AA"] return colors[token_index % len(colors)] def highlight_differences(text): # GPT-4 enc_old = tiktoken.encoding_for_model("gpt-4") tokens_old = enc_old.encode(text) # GPT-4 enc_new = tiktoken.encoding_for_model("gpt-4o") tokens_new = enc_new.encode(text) result_old = [] for i, token in enumerate(tokens_old): word = enc_old.decode([token]) color = get_color(i) result_old.append(f"{html.escape(word)}") result_new = [] for i, token in enumerate(tokens_new): word = enc_new.decode([token]) color = get_color(i) result_new.append(f"{html.escape(word)}") description = f"""