Skip to content

Commit 446a4a8

Browse files
committed
wip
1 parent 18e662d commit 446a4a8

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

modelscope_agent/cli/code/coding.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ prompt:
9191
callbacks:
9292
- artifact_callback
9393
- evaluator_callback
94+
- prompt_callback
9495

9596
memory:
9697

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import json
2+
from typing import List
3+
4+
from omegaconf import DictConfig
5+
6+
from modelscope_agent.callbacks import Callback, Runtime
7+
from modelscope_agent.llm.utils import Message
8+
from modelscope_agent.utils import get_logger
9+
10+
logger = get_logger()
11+
12+
13+
class PromptCallback(Callback):
14+
15+
_prompt = """
16+
17+
Here are some specific instructions for frontend design:
18+
19+
* **Overall Style:** Consider magazine-style, publication-style, or other modern web design styles you deem appropriate. The goal is to create a page that is both informative and visually appealing, like a well-designed digital magazine or in-depth feature article.
20+
21+
* **Hero Section (Optional but Strongly Recommended):** If you think it's appropriate, design an eye-catching Hero section. It can include a main headline, subtitle, an engaging introductory paragraph, and a high-quality background image or illustration.
22+
23+
* **Typography:**
24+
* Carefully select font combinations (serif and sans-serif) to enhance the reading experience.
25+
* Use different font sizes, weights, colors, and styles to create a clear visual hierarchy.
26+
* Consider using refined typographic details (such as drop caps, hanging punctuation) to enhance overall quality.
27+
* Font Awesome has many icons - choose appropriate ones to add visual interest and playfulness.
28+
29+
* **Color Scheme:**
30+
* Choose a color palette that is both harmonious and visually impactful.
31+
* Consider using high-contrast color combinations to highlight important elements.
32+
* Explore gradients, shadows, and other effects to add visual depth.
33+
34+
* **Layout:**
35+
* Use a grid-based layout system to organize page elements.
36+
* Make full use of negative space (whitespace) to create visual balance and breathing room.
37+
* Consider using cards, dividers, icons, and other visual elements to separate and organize content.
38+
39+
* **Tone:** Overall style should be refined, creating a sense of sophistication.
40+
41+
* **Data Visualization:**
42+
* Design one or more data visualization elements to showcase key concepts of Naval's thinking and their relationships.
43+
* Consider using mind maps, concept relationship diagrams, timelines, or thematic clustering displays.
44+
* Ensure visualization design is both beautiful and insightful, helping users intuitively understand the overall framework of Naval's thought system.
45+
* Use Mermaid.js to implement interactive charts that allow users to explore connections between different concepts.
46+
47+
**Technical Specifications:**
48+
49+
* Use HTML5、Font Awesome、Tailwind CSS and necessary JavaScript。
50+
* Font Awesome: [https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css](https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css)
51+
* Tailwind CSS: [https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css](https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css)
52+
* Font for non-Chinese: [https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap](https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap)
53+
* `font-family: Tahoma,Arial,Roboto,"Droid Sans","Helvetica Neue","Droid Sans Fallback","Heiti SC","Hiragino Sans GB",Simsun,sans-self;`
54+
* Mermaid: [https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js](https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js)
55+
56+
* Implement a complete dark/light mode toggle functionality that follows system settings by default and allows users to manually switch.
57+
* Code structure should be clear and semantic, including appropriate comments.
58+
* Implement complete responsiveness that must display perfectly on all devices (mobile, tablet, desktop).
59+
"""
60+
61+
def __init__(self, config: DictConfig):
62+
super().__init__(config)
63+
64+
async def on_tool_call(self, runtime: Runtime, messages: List[Message]):
65+
if runtime.tag != 'Default workflow':
66+
return
67+
68+
if messages[-1].tool_calls:
69+
tool_call = messages[-1].tool_calls[0]
70+
tool_args = tool_call['arguments']
71+
if isinstance(tool_args, str):
72+
tool_args = json.loads(tool_args)
73+
tasks = tool_args['tasks']
74+
for i, task in enumerate(tasks):
75+
system = task['system']
76+
system = system + self._prompt
77+
task['system'] = system
78+
tool_call['arguments'] = tool_args

0 commit comments

Comments
 (0)