Skip to content

Commit 8956cc2

Browse files
committed
update prompt
1 parent 5c03917 commit 8956cc2

3 files changed

Lines changed: 42 additions & 45 deletions

File tree

modelscope_agent/cli/code/artifact_callback.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ async def on_task_begin(self, runtime: Runtime, messages: List[Message]):
2525
def extract_metadata(config: DictConfig, llm: LLM, messages: List[Message]):
2626
assert messages[0].role == 'system' and messages[1].role == 'user'
2727
_system = """You are a file name parser, I will give a user query field to you, you need to extract the code file name from it.
28-
Always remember your task is not generating the code, but parse the file name from the query.
28+
Always remember your task is not generating the code, but parse the relative file name from the query.
2929
Here shows an example:
30-
query is: You should write the index.js file, the file you need to use is main.css and nav.js, the interface in the code is ...
30+
query is: You should write the js/index.js file, the file you need to use is main.css and js/nav.js, the interface in the code is ...
3131
32-
Your answer should be: index.js
32+
Your answer should be: js/index.js
3333
"""
3434
_query = (f'The input query is: {messages[1].content}\n\n'
3535
'Now give me the code file name without any other information:\n')
@@ -82,7 +82,8 @@ async def after_generate_response(self, runtime: Runtime, messages: List[Message
8282
self.code = True
8383
try:
8484
code_file = self.extract_metadata(self.config, runtime.llm, messages)
85-
await self.file_system.create_directory('output')
85+
dirs = os.path.dirname(code_file)
86+
await self.file_system.create_directory(os.path.join('output', dirs))
8687
await self.file_system.write_file(os.path.join('output', code_file), code)
8788
messages.append(Message(role='assistant', content=f'Original query: {messages[1].content}'
8889
f'Task sunning successfully, '

modelscope_agent/cli/code/coding.yaml

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
llm:
22
service: openai
3-
model: qwen-plus-latest
3+
model: claude-3-7-sonnet-20250219
44
openai_api_key:
55
openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
66

77
generation_config:
8-
top_p: 0.8
9-
temperature: 0.5
10-
top_k: 50
8+
top_p: 0.6
9+
temperature: 0.2
10+
top_k: 20
1111
stream: false
1212
max_completion_tokens: 8192
1313
max_tokens: 16384
@@ -19,32 +19,33 @@ prompt:
1919
You are a senior software architect. Your responsibility is to break down original requirements into implementable modules and assign tasks for each module into subtasks. The initiation of subtasks requires calling the `split_to_sub_task` tool, which can start all sub tasks as you need at one time. In this process, you need to answer the following questions:
2020
2121
1. What is the original requirement? Does it involve frontend or backend code? What programming language is needed?
22-
2. How many modules should it be split into? What functions are needed for each module? How to combine each file?
23-
3. Due to code complexity, you need to inform your subtasks that code blocks need to be wrapped with <code></code> tags, as this code will subsequently be stored in local files.
24-
4. You should **MENTION CLEARLY** the detailed functions and interfaces your subtasks should follow, the page language to use, and relations between each module/file, in case they do duplicate works.
25-
5. If the code contains http api interactions, you must clearly design the apis, and notice the related subtasks
22+
2. How many modules should it be split into? What functionalities are needed for each module? How to group each file?
23+
3. You need to inform your subtasks that code blocks need to be wrapped with <code></code> tags, as this code will subsequently be stored in local files.
24+
4. You should **MENTION CLEARLY** the interface relations between each module/file, and tell single task to follow them, in case they do duplicate works.
25+
5. If the code contains http api interactions, you must clearly design the apis
2626
6. Beauty and Functionality is the most important thing, Never use invalid image links, use images from unsplash-like websites
27-
7. One task only writes one code file, all files should be put in one folder, so no parent folder name should be given
27+
7. One task only writes one code file, I should organize the files in different folders, and give the directory/filename to the subtask
28+
8. Pay special attention to the user's special request, like `a carousel on the top` or `a dark theme`, do not miss them!
2829
2930
An example:
30-
query: Please help me write an e-commerce website with Christmas atmosphere
31+
query: Please help me write an e-commerce website with Christmas atmosphere, with a carousel at the bottom
3132
32-
assistant: Need to write an e-commerce website with Christmas atmosphere, should be implemented using js language, mainly writing frontend code.
33+
assistant: Need to write an e-commerce website with Christmas atmosphere, with a carousel at the bottom, should be implemented using js language, mainly writing frontend code.
3334
To complete this requirement, I need to consider the following parts:
3435
1. An e-commerce website requires these modules: categories, goods, detail good, purchase, history orders, shopping cart, favourites, carousel images and so on.
3536
2. The website needs Christmas features, so the CSS style should be mainly red and white, decorated with Christmas images
36-
3. Due to the complexity of the code engineering, I cannot complete this complex goal in a single file, so I need to split the tasks
37-
4. One task should only writes one code file, all files should be put in one folder, so I should not give parent folder prefix
38-
5. I should give very detail designs of the pages functions(especially the functions interact with other code files), file import relations(This is the most important thing!!), in case the sub tasks work abnormally
39-
6. I should specify the programming language of all the subtasks
37+
3. User mentioned a carousel at the bottom, I should split a task to implement this and tell the index.html task to import the component
38+
4. I cannot complete this complex goal in a single file, so I need to split the tasks
39+
5. One task only writes one code file, I should organize the files in different folders, and give the relative output file path for the subtask
40+
6. I should give detail interfaces design of each task(especially the functions interact with other code files), file import relations
4041
7. I should tell the subtasks to use images from unsplash-like websites
4142
8. User didn't give the page language, I should tell the subtasks to use English because the query is English
4243
...
4344
4445
How many modules(subtasks) I should split?
4546
According to the information above, an e-commerce website should have the following components:
4647
* A main page
47-
* A carousel component
48+
* A carousel component at the bottom, this is user's request
4849
* A goods page
4950
* A category page
5051
* A detail good page
@@ -59,10 +60,10 @@ prompt:
5960
- Subtask: Write index.html. This file needs to ...
6061
- Subtask: Write index.js. This file needs functions like... using CSS classes for...
6162
* Write the carousel part
62-
- Subtask: Write carousel component carousel.js. This file needs functions like... using CSS classes for...
63+
- Subtask: Write carousel component carousel.html. This file needs functions like... using CSS classes for...
6364
* Write the product display part
64-
- Subtask: Category page category.js. This file needs functions like... using CSS classes for...
65-
- Subtask: Product page good.js. This file needs functions like... using CSS classes for...
65+
- Subtask: Category page category.html. This file needs functions like... using CSS classes for...
66+
- Subtask: Product page good.html. This file needs functions like... using CSS classes for...
6667
* ...some other subtasks listed here...
6768
* CSS part
6869
- Subtask: Write main.css. This file uses classes including...
@@ -76,18 +77,16 @@ prompt:
7677
[
7778
{
7879
"system": "You are a software engineer which helps me to finish a part of my job. IMPORTANT: You should invoke other tasks' code files to finish the whole job. The code file you need to invoke will be given in the query.",
79-
"query": "The original query is to write an e-commerce website with Christmas atmosphere, your part of job is only one code file: the index.html page, DO NOT generate code of other files. you should follow instructions:
80-
1. Do not give fake image addresses! use links of Unsplash like website
80+
"query": "The original query is to write an e-commerce website with Christmas atmosphere, with a carousel at the bottom, your part of job is only one code file: the index.html page, DO NOT generate code of other files. you should follow instructions:
81+
1. Do not give fake image addresses, use links of Unsplash like website
8182
2. You should make the page as beautiful as you can
8283
3. DO not add ``` around the code, DO NOT give multiple segments of code, wrap the final code with <code></code>
83-
5. All files are in one folder, always import other tasks' code file from the same directory!
84-
6. Link to purchase.js to fulfill the purchase section
85-
7. Link to goods.js to fulfill the goods section
86-
8. Link to invoke cart.js to ..."
87-
9. Use javascript instead of node.js, do not use ES6 modules
88-
10. Never give dummy information!
89-
11. Using more html to build pages
90-
12. Use English in pages
84+
4. Link to js/purchase.js to fulfill the purchase section
85+
5. Link to js/goods.js to fulfill the goods section
86+
6. Link to carousel.html and put the carousel at the bottom of the page, ...
87+
7. Use javascript instead of node.js, do not use ES6 modules
88+
8. Never give dummy information
89+
9. Use English in pages"
9190
},
9291
...
9392
]

modelscope_agent/cli/code/evaluator_callback.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,24 @@
1111

1212
class EvaluatorCallback(Callback):
1313

14-
_system = """You are a software architecture evaluator whose job is to assess whether software architectures created by other architects are reasonable. The actual workflow is:
14+
_system = """You are a software architecture evaluator whose job is to assess whether the software architecture is reasonable. The actual workflow is:
1515
1616
1. An original requirement is given
1717
2. A software architect provides the modules that need to be designed and breaks these modules down into different subtasks for completion, with each subtask responsible for writing one specific file
1818
3. After the subtasks are completed, they are automatically saved to disk, and these modules will work together collaboratively
1919
2020
However, software architects have a high probability of making mistakes, including but not limited to:
2121
22-
1. Modules that don't meet user requirements, such as insufficient content richness. In this case, you can try prompting the software architect about whether there are other features that can be added, and you can also provide examples
23-
2. Dependencies between subtasks MUST BE clear. For example, if file1 in subtask1 needs to import and use file2 from subtask2 and file3 from subtask3, you need to CAREFULLY REVIEW whether the DEPENDENCY PROMPTS exist and reasonable. PAY SPECIAL ATTENTION TO THIS REQUEST!!
24-
3. Since files between subtasks work collaboratively, the interfaces between them must be reliable and clear. You need to check whether the interface design provided by the architect is sufficient to support collaborative work requirements
25-
4. Subtasks may use different programming languages or different technology(we don't want to use es6 modules or node.js) or encounter other scenarios where they cannot work together collaboratively. You need to carefully point these out
26-
5. The architect will call `split_task`to start all subtasks at one time, which needs a list of systems and queries. You need to check each subtask's arguments(system and query), whether the information is sufficient for collaborative work requirements.
27-
6. Check whether the architect has mentioned all subtasks the generated files are in one folder, so when importing other files, no dir prefix should be given, and the resources(links, images) should be valid or from the unsplash-like websites, do not use local invalid images.
28-
7. Your reply should be like `You should ...`, `Does you consider...`, or `Here is a problem which...`, at last you should say: `Now correct these problems and keep the good part and generate a new plan and call `split_task` again`
22+
1. Modules that don't meet user requirements, such as insufficient content richness. In this case, you can try prompting the software architect about whether there are other features that can be added, and you can also provide examples.Meanwhile, user may give detail requirements, like `a carousel at the bottom`, check carefully if these requirements are fulfilled
23+
2. Dependencies and interface designs between subtasks MUST BE clear and reliable and sufficient for collaborative work. For example, if file1 in subtask1 needs to import and use file2 from subtask2 and file3 from subtask3, you need to CAREFULLY REVIEW whether the DEPENDENCY PROMPTS exist and reasonable
24+
3. Subtasks may use different programming languages or different technology, check whether they are reasonable
25+
4. The architect will call `split_to_sub_task`to start all subtasks at one time, which needs a list of systems and queries. You need to check each subtask's arguments, whether the information is sufficient
26+
6. Check whether the architect has give the correct relative output file path, like `js/a.js`, and the resources(links, images) should be valid or from the unsplash-like websites, not local invalid links should be given
27+
7. Your reply should be like `You should ...`, `Does you consider...`, or `Here is a problem which...`, at last you should say: `Now correct these problems and keep the good part and generate a new plan and call `split_to_sub_task` again`
2928
8. Some designs from the architect may be good, point out the good parts to encourage the architect to keep them!
30-
9. Whether the architect use more html than javascript(because we want a beautiful page!)
31-
10. Whether the architect mention what page language to use in subtasks
29+
9. Whether the architect mention what language to show in pages in subtasks
3230
33-
Your specific job is:
34-
Carefully analyze the errors within, prompt the software architect to make corrections, and when you feel the plan already meets the requirements, output the <OK> character, at which point the conversation will terminate.
31+
Carefully analyze the errors within, prompt the software architect to make corrections, when you feel the plan already meets the requirements, output the <OK> character, at which point the conversation will terminate.
3532
Remember: You are not a software architect, you are an evaluator. You don't need to design architecture, you only need to point out or inspire awareness of the errors.
3633
Now Begin:
3734

0 commit comments

Comments
 (0)