| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 | import jsonfrom models.model import AppModelConfiglanguages = ['en-US', 'zh-Hans', 'pt-BR', 'es-ES', 'fr-FR', 'de-DE', 'ja-JP', 'ko-KR', 'ru-RU', 'it-IT', 'uk-UA']language_timezone_mapping = {    'en-US': 'America/New_York',    'zh-Hans': 'Asia/Shanghai',    'pt-BR': 'America/Sao_Paulo',    'es-ES': 'Europe/Madrid',    'fr-FR': 'Europe/Paris',    'de-DE': 'Europe/Berlin',    'ja-JP': 'Asia/Tokyo',    'ko-KR': 'Asia/Seoul',    'ru-RU': 'Europe/Moscow',    'it-IT': 'Europe/Rome',    'uk-UA': 'Europe/Kyiv',}def supported_language(lang):    if lang in languages:        return lang    error = ('{lang} is not a valid language.'             .format(lang=lang))    raise ValueError(error)user_input_form_template = {    "en-US": [        {            "paragraph": {                "label": "Query",                "variable": "default_input",                "required": False,                "default": ""            }        }    ],    "zh-Hans": [        {            "paragraph": {                "label": "查询内容",                "variable": "default_input",                "required": False,                "default": ""            }        }    ],    "pt-BR": [        {            "paragraph": {                "label": "Consulta",                "variable": "default_input",                "required": False,                "default": ""            }        }    ],    "es-ES": [        {            "paragraph": {                "label": "Consulta",                "variable": "default_input",                "required": False,                "default": ""            }        }    ],    "ua-UK": [        {            "paragraph": {                "label": "Запит",                "variable": "default_input",                "required": False,                "default": ""            }        }    ],}demo_model_templates = {    'en-US': [        {            'name': 'Translation Assistant',            'icon': '',            'icon_background': '',            'description': 'A multilingual translator that provides translation capabilities in multiple languages, translating user input into the language they need.',            'mode': 'completion',            'model_config': AppModelConfig(                provider='openai',                model_id='gpt-3.5-turbo-instruct',                configs={                    'prompt_template': "Please translate the following text into {{target_language}}:\n",                    'prompt_variables': [                        {                            "key": "target_language",                            "name": "Target Language",                            "description": "The language you want to translate into.",                            "type": "select",                            "default": "Chinese",                            'options': [                                'Chinese',                                'English',                                'Japanese',                                'French',                                'Russian',                                'German',                                'Spanish',                                'Korean',                                'Italian',                            ]                        }                    ],                    'completion_params': {                        'max_token': 1000,                        'temperature': 0,                        'top_p': 0,                        'presence_penalty': 0.1,                        'frequency_penalty': 0.1,                    }                },                opening_statement='',                suggested_questions=None,                pre_prompt="Please translate the following text into {{target_language}}:\n{{query}}\ntranslate:",                model=json.dumps({                    "provider": "openai",                    "name": "gpt-3.5-turbo-instruct",                    "mode": "completion",                    "completion_params": {                        "max_tokens": 1000,                        "temperature": 0,                        "top_p": 0,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1                    }                }),                user_input_form=json.dumps([                    {                        "select": {                            "label": "Target Language",                            "variable": "target_language",                            "description": "The language you want to translate into.",                            "default": "Chinese",                            "required": True,                            'options': [                                'Chinese',                                'English',                                'Japanese',                                'French',                                'Russian',                                'German',                                'Spanish',                                'Korean',                                'Italian',                            ]                        }                    }, {                        "paragraph": {                            "label": "Query",                            "variable": "query",                            "required": True,                            "default": ""                        }                    }                ])            )        },        {            'name': 'AI Front-end Interviewer',            'icon': '',            'icon_background': '',            'description': 'A simulated front-end interviewer that tests the skill level of front-end development through questioning.',            'mode': 'chat',            'model_config': AppModelConfig(                provider='openai',                model_id='gpt-3.5-turbo',                configs={                    'introduction': 'Hi, welcome to our interview. I am the interviewer for this technology company, and I will test your web front-end development skills. Next, I will ask you some technical questions. Please answer them as thoroughly as possible. ',                    'prompt_template': "You will play the role of an interviewer for a technology company, examining the user's web front-end development skills and posing 5-10 sharp technical questions.\n\nPlease note:\n- Only ask one question at a time.\n- After the user answers a question, ask the next question directly, without trying to correct any mistakes made by the candidate.\n- If you think the user has not answered correctly for several consecutive questions, ask fewer questions.\n- After asking the last question, you can ask this question: Why did you leave your last job? After the user answers this question, please express your understanding and support.\n",                    'prompt_variables': [],                    'completion_params': {                        'max_token': 300,                        'temperature': 0.8,                        'top_p': 0.9,                        'presence_penalty': 0.1,                        'frequency_penalty': 0.1,                    }                },                opening_statement='Hi, welcome to our interview. I am the interviewer for this technology company, and I will test your web front-end development skills. Next, I will ask you some technical questions. Please answer them as thoroughly as possible. ',                suggested_questions=None,                pre_prompt="You will play the role of an interviewer for a technology company, examining the user's web front-end development skills and posing 5-10 sharp technical questions.\n\nPlease note:\n- Only ask one question at a time.\n- After the user answers a question, ask the next question directly, without trying to correct any mistakes made by the candidate.\n- If you think the user has not answered correctly for several consecutive questions, ask fewer questions.\n- After asking the last question, you can ask this question: Why did you leave your last job? After the user answers this question, please express your understanding and support.\n",                model=json.dumps({                    "provider": "openai",                    "name": "gpt-3.5-turbo",                    "mode": "chat",                    "completion_params": {                        "max_tokens": 300,                        "temperature": 0.8,                        "top_p": 0.9,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1                    }                }),                user_input_form=None            )        }    ],    'zh-Hans': [        {            'name': '翻译助手',            'icon': '',            'icon_background': '',            'description': '一个多语言翻译器,提供多种语言翻译能力,将用户输入的文本翻译成他们需要的语言。',            'mode': 'completion',            'model_config': AppModelConfig(                provider='openai',                model_id='gpt-3.5-turbo-instruct',                configs={                    'prompt_template': "请将以下文本翻译为{{target_language}}:\n",                    'prompt_variables': [                        {                            "key": "target_language",                            "name": "目标语言",                            "description": "翻译的目标语言",                            "type": "select",                            "default": "中文",                            "options": [                                "中文",                                "英文",                                "日语",                                "法语",                                "俄语",                                "德语",                                "西班牙语",                                "韩语",                                "意大利语",                            ]                        }                    ],                    'completion_params': {                        'max_token': 1000,                        'temperature': 0,                        'top_p': 0,                        'presence_penalty': 0.1,                        'frequency_penalty': 0.1,                    }                },                opening_statement='',                suggested_questions=None,                pre_prompt="请将以下文本翻译为{{target_language}}:\n{{query}}\n翻译:",                model=json.dumps({                    "provider": "openai",                    "name": "gpt-3.5-turbo-instruct",                    "mode": "completion",                    "completion_params": {                        "max_tokens": 1000,                        "temperature": 0,                        "top_p": 0,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1                    }                }),                user_input_form=json.dumps([                    {                        "select": {                            "label": "目标语言",                            "variable": "target_language",                            "description": "翻译的目标语言",                            "default": "中文",                            "required": True,                            'options': [                                "中文",                                "英文",                                "日语",                                "法语",                                "俄语",                                "德语",                                "西班牙语",                                "韩语",                                "意大利语",                            ]                        }                    }, {                        "paragraph": {                            "label": "文本内容",                            "variable": "query",                            "required": True,                            "default": ""                        }                    }                ])            )        },        {            'name': 'AI 前端面试官',            'icon': '',            'icon_background': '',            'description': '一个模拟的前端面试官,通过提问的方式对前端开发的技能水平进行检验。',            'mode': 'chat',            'model_config': AppModelConfig(                provider='openai',                model_id='gpt-3.5-turbo',                configs={                    'introduction': '你好,欢迎来参加我们的面试,我是这家科技公司的面试官,我将考察你的 Web 前端开发技能。接下来我会向您提出一些技术问题,请您尽可能详尽地回答。',                    'prompt_template': "你将扮演一个科技公司的面试官,考察用户作为候选人的 Web 前端开发水平,提出 5-10 个犀利的技术问题。\n\n请注意:\n- 每次只问一个问题\n- 用户回答问题后请直接问下一个问题,而不要试图纠正候选人的错误;\n- 如果你认为用户连续几次回答的都不对,就少问一点;\n- 问完最后一个问题后,你可以问这样一个问题:上一份工作为什么离职?用户回答该问题后,请表示理解与支持。\n",                    'prompt_variables': [],                    'completion_params': {                        'max_token': 300,                        'temperature': 0.8,                        'top_p': 0.9,                        'presence_penalty': 0.1,                        'frequency_penalty': 0.1,                    }                },                opening_statement='你好,欢迎来参加我们的面试,我是这家科技公司的面试官,我将考察你的 Web 前端开发技能。接下来我会向您提出一些技术问题,请您尽可能详尽地回答。',                suggested_questions=None,                pre_prompt="你将扮演一个科技公司的面试官,考察用户作为候选人的 Web 前端开发水平,提出 5-10 个犀利的技术问题。\n\n请注意:\n- 每次只问一个问题\n- 用户回答问题后请直接问下一个问题,而不要试图纠正候选人的错误;\n- 如果你认为用户连续几次回答的都不对,就少问一点;\n- 问完最后一个问题后,你可以问这样一个问题:上一份工作为什么离职?用户回答该问题后,请表示理解与支持。\n",                model=json.dumps({                    "provider": "openai",                    "name": "gpt-3.5-turbo",                    "mode": "chat",                    "completion_params": {                        "max_tokens": 300,                        "temperature": 0.8,                        "top_p": 0.9,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1                    }                }),                user_input_form=None            )        }    ],    'uk-UA': [{        "name": "Помічник перекладу",        "icon": "",        "icon_background": "",        "description": "Багатомовний перекладач, який надає можливості перекладу різними мовами, перекладаючи введені користувачем дані на потрібну мову.",        "mode": "completion",        "model_config": AppModelConfig(            provider="openai",            model_id="gpt-3.5-turbo-instruct",            configs={                "prompt_template": "Будь ласка, перекладіть наступний текст на {{target_language}}:\n",                "prompt_variables": [                    {                        "key": "target_language",                        "name": "Цільова мова",                        "description": "Мова, на яку ви хочете перекласти.",                        "type": "select",                        "default": "Ukrainian",                        "options": [                            "Chinese",                            "English",                            "Japanese",                            "French",                            "Russian",                            "German",                            "Spanish",                            "Korean",                            "Italian",                        ],                    },                ],                "completion_params": {                    "max_token": 1000,                    "temperature": 0,                    "top_p": 0,                    "presence_penalty": 0.1,                    "frequency_penalty": 0.1,                },            },            opening_statement="",            suggested_questions=None,            pre_prompt="Будь ласка, перекладіть наступний текст на {{target_language}}:\n{{query}}\ntranslate:",            model=json.dumps({                "provider": "openai",                "name": "gpt-3.5-turbo-instruct",                "mode": "completion",                "completion_params": {                    "max_tokens": 1000,                    "temperature": 0,                    "top_p": 0,                    "presence_penalty": 0.1,                    "frequency_penalty": 0.1,                },            }),            user_input_form=json.dumps([                {                    "select": {                        "label": "Цільова мова",                        "variable": "target_language",                        "description": "Мова, на яку ви хочете перекласти.",                        "default": "Chinese",                        "required": True,                        'options': [                            'Chinese',                            'English',                            'Japanese',                            'French',                            'Russian',                            'German',                            'Spanish',                            'Korean',                            'Italian',                        ]                    }                }, {                    "paragraph": {                        "label": "Запит",                        "variable": "query",                        "required": True,                        "default": ""                    }                }            ])        )    },        {            "name": "AI інтерв’юер фронтенду",            "icon": "",            "icon_background": "",            "description": "Симульований інтерв’юер фронтенду, який перевіряє рівень кваліфікації у розробці фронтенду через опитування.",            "mode": "chat",            "model_config": AppModelConfig(                provider="openai",                model_id="gpt-3.5-turbo",                configs={                    "introduction": "Привіт, ласкаво просимо на наше співбесіду. Я інтерв'юер цієї технологічної компанії, і я перевірю ваші навички веб-розробки фронтенду. Далі я поставлю вам декілька технічних запитань. Будь ласка, відповідайте якомога ретельніше. ",                    "prompt_template": "Ви будете грати роль інтерв'юера технологічної компанії, перевіряючи навички розробки фронтенду користувача та ставлячи 5-10 чітких технічних питань.\n\nЗверніть увагу:\n- Ставте лише одне запитання за раз.\n- Після того, як користувач відповість на запитання, ставте наступне запитання безпосередньо, не намагаючись виправити будь-які помилки, допущені кандидатом.\n- Якщо ви вважаєте, що користувач не відповів правильно на кілька питань поспіль, задайте менше запитань.\n- Після того, як ви задали останнє запитання, ви можете поставити таке запитання: Чому ви залишили свою попередню роботу? Після того, як користувач відповість на це питання, висловіть своє розуміння та підтримку.\n",                    "prompt_variables": [],                    "completion_params": {                        "max_token": 300,                        "temperature": 0.8,                        "top_p": 0.9,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1,                    },                },                opening_statement="Привіт, ласкаво просимо на наше співбесіду. Я інтерв'юер цієї технологічної компанії, і я перевірю ваші навички веб-розробки фронтенду. Далі я поставлю вам декілька технічних запитань. Будь ласка, відповідайте якомога ретельніше. ",                suggested_questions=None,                pre_prompt="Ви будете грати роль інтерв'юера технологічної компанії, перевіряючи навички розробки фронтенду користувача та ставлячи 5-10 чітких технічних питань.\n\nЗверніть увагу:\n- Ставте лише одне запитання за раз.\n- Після того, як користувач відповість на запитання, ставте наступне запитання безпосередньо, не намагаючись виправити будь-які помилки, допущені кандидатом.\n- Якщо ви вважаєте, що користувач не відповів правильно на кілька питань поспіль, задайте менше запитань.\n- Після того, як ви задали останнє запитання, ви можете поставити таке запитання: Чому ви залишили свою попередню роботу? Після того, як користувач відповість на це питання, висловіть своє розуміння та підтримку.\n",                model=json.dumps({                    "provider": "openai",                    "name": "gpt-3.5-turbo",                    "mode": "chat",                    "completion_params": {                        "max_tokens": 300,                        "temperature": 0.8,                        "top_p": 0.9,                        "presence_penalty": 0.1,                        "frequency_penalty": 0.1,                    },                }),                user_input_form=None            ),        }    ],}
 |