curry tang
commited on
Commit
·
069d1fd
1
Parent(s):
f15abe4
update
Browse files- app.py +3 -1
- prompts.py +26 -0
app.py
CHANGED
@@ -5,7 +5,7 @@ from config import settings
|
|
5 |
import base64
|
6 |
from PIL import Image
|
7 |
import io
|
8 |
-
from prompts import web_prompt, explain_code_template, optimize_code_template, debug_code_template, function_gen_template, translate_doc_template, backend_developer_prompt
|
9 |
from banner import banner_md
|
10 |
from langchain_core.prompts import PromptTemplate
|
11 |
|
@@ -43,6 +43,8 @@ def predict(message, history, chat, _current_assistant):
|
|
43 |
assistant_prompt = web_prompt
|
44 |
if _current_assistant == '后端开发助手':
|
45 |
assistant_prompt = backend_developer_prompt
|
|
|
|
|
46 |
history_messages.append(SystemMessage(content=assistant_prompt))
|
47 |
|
48 |
if files_len == 0:
|
|
|
5 |
import base64
|
6 |
from PIL import Image
|
7 |
import io
|
8 |
+
from prompts import web_prompt, explain_code_template, optimize_code_template, debug_code_template, function_gen_template, translate_doc_template, backend_developer_prompt, analyst_prompt
|
9 |
from banner import banner_md
|
10 |
from langchain_core.prompts import PromptTemplate
|
11 |
|
|
|
43 |
assistant_prompt = web_prompt
|
44 |
if _current_assistant == '后端开发助手':
|
45 |
assistant_prompt = backend_developer_prompt
|
46 |
+
if _current_assistant == '数据分析师':
|
47 |
+
assistant_prompt = analyst_prompt
|
48 |
history_messages.append(SystemMessage(content=assistant_prompt))
|
49 |
|
50 |
if files_len == 0:
|
prompts.py
CHANGED
@@ -51,6 +51,32 @@ OUTPUT_CODE
|
|
51 |
Conduct Security and Operational reviews of PLANNING and OUTPUT, paying particular attention to things that may compromise data or introduce vulnerabilities. For sensitive changes (e.g. Input Handling, Monetary Calculations, Authentication) conduct a thorough review showing your analysis between <SECURITY_REVIEW> tags.
|
52 |
'''
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
explain_code_template = '''
|
55 |
你的任务是获取提供的代码片段,并用简单易懂的语言解释它,假设读者是一个刚刚学习了语言特性和基本语法的初学程序员。
|
56 |
重点解释:
|
|
|
51 |
Conduct Security and Operational reviews of PLANNING and OUTPUT, paying particular attention to things that may compromise data or introduce vulnerabilities. For sensitive changes (e.g. Input Handling, Monetary Calculations, Authentication) conduct a thorough review showing your analysis between <SECURITY_REVIEW> tags.
|
52 |
'''
|
53 |
|
54 |
+
analyst_prompt = '''
|
55 |
+
You are a seasoned data analyst proficient in programming languages such as Python, R, Julia, MATLAB, and Octave. Your expertise shines particularly in Python, where you excel at data modeling and processing using libraries like NumPy, SciPy, Pandas, Sympy, Matplotlib and Statsmodels.Don't apologise unnecessarily. Review the conversation history for mistakes and avoid repeating them.
|
56 |
+
|
57 |
+
During our conversation break things down in to discrete changes, and suggest a small test after each stage to make sure things are on the right track.
|
58 |
+
|
59 |
+
Only produce code to illustrate examples, or when directed to in the conversation. If you can answer without code, that is preferred, and you will be asked to elaborate if it is required.
|
60 |
+
|
61 |
+
Request clarification for anything unclear or ambiguous.
|
62 |
+
|
63 |
+
Before writing or suggesting code, perform a comprehensive code review of the existing code and describe how it works between <CODE_REVIEW> tags.
|
64 |
+
|
65 |
+
After completing the code review, construct a plan for the change between <PLANNING> tags. Ask for additional source files or documentation that may be relevant. The plan should avoid duplication (DRY principle), and balance maintenance and flexibility. Present trade-offs and implementation choices at this step. Consider available Frameworks and Libraries and suggest their use when relevant. STOP at this step if we have not agreed a plan.
|
66 |
+
|
67 |
+
Once agreed, produce code between <OUTPUT> tags. Pay attention to Variable Names, Identifiers and String Literals, and check that they are reproduced accurately from the original source files unless otherwise directed. When naming by convention surround in double colons and in ::UPPERCASE:: Maintain existing code style, use language appropriate idioms.
|
68 |
+
|
69 |
+
Always produce code starting with a new line, and in blocks (```) with the language specified:
|
70 |
+
|
71 |
+
```Python
|
72 |
+
|
73 |
+
OUTPUT_CODE
|
74 |
+
|
75 |
+
```
|
76 |
+
|
77 |
+
Conduct Security and Operational reviews of PLANNING and OUTPUT, paying particular attention to things that may compromise data or introduce vulnerabilities. For sensitive changes (e.g. Input Handling, Monetary Calculations, Authentication) conduct a thorough review showing your analysis between <SECURITY_REVIEW> tags.
|
78 |
+
'''
|
79 |
+
|
80 |
explain_code_template = '''
|
81 |
你的任务是获取提供的代码片段,并用简单易懂的语言解释它,假设读者是一个刚刚学习了语言特性和基本语法的初学程序员。
|
82 |
重点解释:
|