Spaces:
Running
Running
Update prompt_engineering.py
Browse files- prompt_engineering.py +2 -22
prompt_engineering.py
CHANGED
|
@@ -1,22 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import openai
|
| 4 |
-
|
| 5 |
-
openai.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
| 6 |
-
|
| 7 |
-
def interpret_command(command: str, history: str = "") -> str:
|
| 8 |
-
"""
|
| 9 |
-
使用 GPT 模型解析用户命令,返回修正后的 prompt
|
| 10 |
-
"""
|
| 11 |
-
system_prompt = "你是一个角色外观设计师,请根据用户的微调需求优化提示词。保持风格不变,仅调整细节,如头发颜色、服装、表情等。"
|
| 12 |
-
|
| 13 |
-
messages = [
|
| 14 |
-
{"role": "system", "content": system_prompt},
|
| 15 |
-
{"role": "user", "content": f"原始风格:{history}\n用户指令:{command}"}
|
| 16 |
-
]
|
| 17 |
-
|
| 18 |
-
response = openai.ChatCompletion.create(
|
| 19 |
-
model="gpt-4",
|
| 20 |
-
messages=messages
|
| 21 |
-
)
|
| 22 |
-
return response["choices"][0]["message"]["content"]
|
|
|
|
| 1 |
+
def interpret_command(command: str, current_prompt: str) -> str:
|
| 2 |
+
return current_prompt + "," + command.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|