model_template.py 15 KB

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