import gradio as gr from gpt4all import GPT4All from urllib.request import urlopen import json import re # populate all models available from GPT4All url = "https://raw.githubusercontent.com/nomic-ai/gpt4all/main/gpt4all-chat/metadata/models3.json" response = urlopen(url) data_json = json.loads(response.read()) def model_choices(): model_list = [data_json[i]['filename'] for i in range(len(data_json))] return model_list # get each models' description model_description = {model['filename']: model['description'] for model in data_json} def remove_endtags(html_string, tags): """Remove rear HTML tags from the input string.""" for tag in tags: html_string = re.sub(fr"", "", html_string) return html_string def replace_starttags(html_string, replacements): """Replace starting HTML tags with the corresponding values.""" for tag, replacement in replacements.items(): html_string = html_string.replace(tag, replacement) return html_string def format_html_string(html_string): """Format the HTML string to a readable text format.""" endtags_to_remove = ["ul", "li", "br", "strong", "a"] html_string = remove_endtags(html_string, endtags_to_remove) starttag_replacements = { "