model_template.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import json
  2. from models.model import AppModelConfig, App
  3. model_templates = {
  4. # completion default mode
  5. 'completion_default': {
  6. 'app': {
  7. 'mode': 'completion',
  8. 'enable_site': True,
  9. 'enable_api': True,
  10. 'is_demo': False,
  11. 'api_rpm': 0,
  12. 'api_rph': 0,
  13. 'status': 'normal'
  14. },
  15. 'model_config': {
  16. 'provider': 'openai',
  17. 'model_id': 'text-davinci-003',
  18. 'configs': {
  19. 'prompt_template': '',
  20. 'prompt_variables': [],
  21. 'completion_params': {
  22. 'max_token': 512,
  23. 'temperature': 1,
  24. 'top_p': 1,
  25. 'presence_penalty': 0,
  26. 'frequency_penalty': 0,
  27. }
  28. },
  29. 'model': json.dumps({
  30. "provider": "openai",
  31. "name": "text-davinci-003",
  32. "completion_params": {
  33. "max_tokens": 512,
  34. "temperature": 1,
  35. "top_p": 1,
  36. "presence_penalty": 0,
  37. "frequency_penalty": 0
  38. }
  39. })
  40. }
  41. },
  42. # chat default mode
  43. 'chat_default': {
  44. 'app': {
  45. 'mode': 'chat',
  46. 'enable_site': True,
  47. 'enable_api': True,
  48. 'is_demo': False,
  49. 'api_rpm': 0,
  50. 'api_rph': 0,
  51. 'status': 'normal'
  52. },
  53. 'model_config': {
  54. 'provider': 'openai',
  55. 'model_id': 'gpt-3.5-turbo',
  56. 'configs': {
  57. 'prompt_template': '',
  58. 'prompt_variables': [],
  59. 'completion_params': {
  60. 'max_token': 512,
  61. 'temperature': 1,
  62. 'top_p': 1,
  63. 'presence_penalty': 0,
  64. 'frequency_penalty': 0,
  65. }
  66. },
  67. 'model': json.dumps({
  68. "provider": "openai",
  69. "name": "gpt-3.5-turbo",
  70. "completion_params": {
  71. "max_tokens": 512,
  72. "temperature": 1,
  73. "top_p": 1,
  74. "presence_penalty": 0,
  75. "frequency_penalty": 0
  76. }
  77. })
  78. }
  79. },
  80. }
  81. demo_model_templates = {
  82. 'en-US': [
  83. {
  84. 'name': 'Translation Assistant',
  85. 'icon': '',
  86. 'icon_background': '',
  87. 'description': 'A multilingual translator that provides translation capabilities in multiple languages, translating user input into the language they need.',
  88. 'mode': 'completion',
  89. 'model_config': AppModelConfig(
  90. provider='openai',
  91. model_id='text-davinci-003',
  92. configs={
  93. 'prompt_template': "Please translate the following text into {{target_language}}:\n",
  94. 'prompt_variables': [
  95. {
  96. "key": "target_language",
  97. "name": "Target Language",
  98. "description": "The language you want to translate into.",
  99. "type": "select",
  100. "default": "Chinese",
  101. 'options': [
  102. 'Chinese',
  103. 'English',
  104. 'Japanese',
  105. 'French',
  106. 'Russian',
  107. 'German',
  108. 'Spanish',
  109. 'Korean',
  110. 'Italian',
  111. ]
  112. }
  113. ],
  114. 'completion_params': {
  115. 'max_token': 1000,
  116. 'temperature': 0,
  117. 'top_p': 0,
  118. 'presence_penalty': 0.1,
  119. 'frequency_penalty': 0.1,
  120. }
  121. },
  122. opening_statement='',
  123. suggested_questions=None,
  124. pre_prompt="Please translate the following text into {{target_language}}:\n",
  125. model=json.dumps({
  126. "provider": "openai",
  127. "name": "text-davinci-003",
  128. "completion_params": {
  129. "max_tokens": 1000,
  130. "temperature": 0,
  131. "top_p": 0,
  132. "presence_penalty": 0.1,
  133. "frequency_penalty": 0.1
  134. }
  135. }),
  136. user_input_form=json.dumps([
  137. {
  138. "select": {
  139. "label": "Target Language",
  140. "variable": "target_language",
  141. "description": "The language you want to translate into.",
  142. "default": "Chinese",
  143. "required": True,
  144. 'options': [
  145. 'Chinese',
  146. 'English',
  147. 'Japanese',
  148. 'French',
  149. 'Russian',
  150. 'German',
  151. 'Spanish',
  152. 'Korean',
  153. 'Italian',
  154. ]
  155. }
  156. }
  157. ])
  158. )
  159. },
  160. {
  161. 'name': 'AI Front-end Interviewer',
  162. 'icon': '',
  163. 'icon_background': '',
  164. 'description': 'A simulated front-end interviewer that tests the skill level of front-end development through questioning.',
  165. 'mode': 'chat',
  166. 'model_config': AppModelConfig(
  167. provider='openai',
  168. model_id='gpt-3.5-turbo',
  169. configs={
  170. '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. ',
  171. '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",
  172. 'prompt_variables': [],
  173. 'completion_params': {
  174. 'max_token': 300,
  175. 'temperature': 0.8,
  176. 'top_p': 0.9,
  177. 'presence_penalty': 0.1,
  178. 'frequency_penalty': 0.1,
  179. }
  180. },
  181. 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. ',
  182. suggested_questions=None,
  183. 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",
  184. model=json.dumps({
  185. "provider": "openai",
  186. "name": "gpt-3.5-turbo",
  187. "completion_params": {
  188. "max_tokens": 300,
  189. "temperature": 0.8,
  190. "top_p": 0.9,
  191. "presence_penalty": 0.1,
  192. "frequency_penalty": 0.1
  193. }
  194. }),
  195. user_input_form=None
  196. )
  197. }
  198. ],
  199. 'zh-Hans': [
  200. {
  201. 'name': '翻译助手',
  202. 'icon': '',
  203. 'icon_background': '',
  204. 'description': '一个多语言翻译器,提供多种语言翻译能力,将用户输入的文本翻译成他们需要的语言。',
  205. 'mode': 'completion',
  206. 'model_config': AppModelConfig(
  207. provider='openai',
  208. model_id='text-davinci-003',
  209. configs={
  210. 'prompt_template': "请将以下文本翻译为{{target_language}}:\n",
  211. 'prompt_variables': [
  212. {
  213. "key": "target_language",
  214. "name": "目标语言",
  215. "description": "翻译的目标语言",
  216. "type": "select",
  217. "default": "中文",
  218. "options": [
  219. "中文",
  220. "英文",
  221. "日语",
  222. "法语",
  223. "俄语",
  224. "德语",
  225. "西班牙语",
  226. "韩语",
  227. "意大利语",
  228. ]
  229. }
  230. ],
  231. 'completion_params': {
  232. 'max_token': 1000,
  233. 'temperature': 0,
  234. 'top_p': 0,
  235. 'presence_penalty': 0.1,
  236. 'frequency_penalty': 0.1,
  237. }
  238. },
  239. opening_statement='',
  240. suggested_questions=None,
  241. pre_prompt="请将以下文本翻译为{{target_language}}:\n",
  242. model=json.dumps({
  243. "provider": "openai",
  244. "name": "text-davinci-003",
  245. "completion_params": {
  246. "max_tokens": 1000,
  247. "temperature": 0,
  248. "top_p": 0,
  249. "presence_penalty": 0.1,
  250. "frequency_penalty": 0.1
  251. }
  252. }),
  253. user_input_form=json.dumps([
  254. {
  255. "select": {
  256. "label": "目标语言",
  257. "variable": "target_language",
  258. "description": "翻译的目标语言",
  259. "default": "中文",
  260. "required": True,
  261. 'options': [
  262. "中文",
  263. "英文",
  264. "日语",
  265. "法语",
  266. "俄语",
  267. "德语",
  268. "西班牙语",
  269. "韩语",
  270. "意大利语",
  271. ]
  272. }
  273. }
  274. ])
  275. )
  276. },
  277. {
  278. 'name': 'AI 前端面试官',
  279. 'icon': '',
  280. 'icon_background': '',
  281. 'description': '一个模拟的前端面试官,通过提问的方式对前端开发的技能水平进行检验。',
  282. 'mode': 'chat',
  283. 'model_config': AppModelConfig(
  284. provider='openai',
  285. model_id='gpt-3.5-turbo',
  286. configs={
  287. 'introduction': '你好,欢迎来参加我们的面试,我是这家科技公司的面试官,我将考察你的 Web 前端开发技能。接下来我会向您提出一些技术问题,请您尽可能详尽地回答。',
  288. 'prompt_template': "你将扮演一个科技公司的面试官,考察用户作为候选人的 Web 前端开发水平,提出 5-10 个犀利的技术问题。\n\n请注意:\n- 每次只问一个问题\n- 用户回答问题后请直接问下一个问题,而不要试图纠正候选人的错误;\n- 如果你认为用户连续几次回答的都不对,就少问一点;\n- 问完最后一个问题后,你可以问这样一个问题:上一份工作为什么离职?用户回答该问题后,请表示理解与支持。\n",
  289. 'prompt_variables': [],
  290. 'completion_params': {
  291. 'max_token': 300,
  292. 'temperature': 0.8,
  293. 'top_p': 0.9,
  294. 'presence_penalty': 0.1,
  295. 'frequency_penalty': 0.1,
  296. }
  297. },
  298. opening_statement='你好,欢迎来参加我们的面试,我是这家科技公司的面试官,我将考察你的 Web 前端开发技能。接下来我会向您提出一些技术问题,请您尽可能详尽地回答。',
  299. suggested_questions=None,
  300. pre_prompt="你将扮演一个科技公司的面试官,考察用户作为候选人的 Web 前端开发水平,提出 5-10 个犀利的技术问题。\n\n请注意:\n- 每次只问一个问题\n- 用户回答问题后请直接问下一个问题,而不要试图纠正候选人的错误;\n- 如果你认为用户连续几次回答的都不对,就少问一点;\n- 问完最后一个问题后,你可以问这样一个问题:上一份工作为什么离职?用户回答该问题后,请表示理解与支持。\n",
  301. model=json.dumps({
  302. "provider": "openai",
  303. "name": "gpt-3.5-turbo",
  304. "completion_params": {
  305. "max_tokens": 300,
  306. "temperature": 0.8,
  307. "top_p": 0.9,
  308. "presence_penalty": 0.1,
  309. "frequency_penalty": 0.1
  310. }
  311. }),
  312. user_input_form=None
  313. )
  314. }
  315. ],
  316. }