kopia lustrzana https://github.com/hc-psy/blender-gpt
commit
d482f7d14b
35
gpt_gpt.py
35
gpt_gpt.py
|
@ -3,14 +3,15 @@ import re
|
|||
|
||||
|
||||
def SYS_MAIN_PROMPT(language): return f"""
|
||||
I want you to act as a professional 3D artist who is proficient in writing scripts in Blender, the 3D software.
|
||||
I want you to act as a professional 3D artist who is proficient in writing scripts in Blender, the 3D software. And you know how the relationship between the conceptual 3D model and animation ideas and the corresponding python scripts.
|
||||
Here are some rules you have to heed and follow:
|
||||
- Respond with your answers in markdown (```).
|
||||
- Preferably import entire modules instead of bits.
|
||||
- Do not perform destructive operations on the meshes.
|
||||
- Do not use cap_ends. Do not do more than what is asked (setting up render settings, adding cameras, etc)
|
||||
- Do not respond with anything that is not Python code.
|
||||
- Please write comments in {language}.
|
||||
- Do not provide explanations and comments.
|
||||
- The input might be in {language}.
|
||||
"""
|
||||
|
||||
|
||||
|
@ -42,6 +43,28 @@ bpy.ops.object.delete()
|
|||
bpy.ops.mesh.primitive_uv_sphere_add(location=(0, 0, 0), radius=2.5)
|
||||
```"""
|
||||
|
||||
EX_3_USER = """create a rigid body sim with 10 1x1x1 cubes stacked as a tower taht falls down onto a 20x20 plane"""
|
||||
|
||||
EX_3_ASSISTANT = """```
|
||||
import bpy
|
||||
|
||||
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 9))
|
||||
bpy.ops.rigidbody.object_add()
|
||||
bpy.ops.transform.resize(value=(0.5, 0.5, 0.5))
|
||||
|
||||
for i in range(9):
|
||||
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 9+i+1))
|
||||
bpy.ops.rigidbody.object_add()
|
||||
bpy.ops.transform.resize(value=(.5, .5, .5))
|
||||
|
||||
bpy.ops.mesh.primitive_plane_add(location=(0, 0, 0))
|
||||
bpy.ops.rigidbody.object_add()
|
||||
bpy.context.object.rigid_body.type = 'PASSIVE'
|
||||
bpy.ops.transform.resize(value=(10, 10, 1))
|
||||
|
||||
bpy.context.scene.frame_end = 200
|
||||
```"""
|
||||
|
||||
|
||||
def post_process(final_txt):
|
||||
final_txt = re.findall(
|
||||
|
@ -74,6 +97,10 @@ def chatgpt(context):
|
|||
{"role": "system", "name": "example_user", "content": EX_2_USER})
|
||||
messages.append(
|
||||
{"role": "system", "name": "example_assistant", "content": EX_2_ASSISTANT})
|
||||
messages.append(
|
||||
{"role": "system", "name": "example_user", "content": EX_3_USER})
|
||||
messages.append(
|
||||
{"role": "system", "name": "example_assistant", "content": EX_3_ASSISTANT})
|
||||
|
||||
# add previous messages
|
||||
for msg in scene.history[-8:]:
|
||||
|
@ -86,8 +113,8 @@ def chatgpt(context):
|
|||
|
||||
if messages[-1]["role"] != "user":
|
||||
# add the current user message
|
||||
messages.append({"role": "user", "content": "Please provide me with Blender (3D software) code regarding the following task: " +
|
||||
prompts[lan] + ". \n. Do not respond with anything that is not Python code. Do not provide explanations. " + f"Wite code comment in {languages[lan]}."})
|
||||
messages.append({"role": "user", "content": "Please provide me with Blender (3D software) python code satisfying the following task: " +
|
||||
prompts[lan] + ". \n. Do not provide with anything that is not Python code. Do not provide explanations and comments."})
|
||||
|
||||
response = openai.ChatCompletion.create(
|
||||
model=models[lan],
|
||||
|
|
|
@ -138,7 +138,9 @@ class BLENDERGPT_OT_SEND_MSG(Operator):
|
|||
msg = scene.history.add()
|
||||
msg.type = 'USER'
|
||||
msg.content = prompts[lan]
|
||||
prompts[lan] = ""
|
||||
scene.prompt_input_0 = ""
|
||||
scene.prompt_input_1 = ""
|
||||
scene.prompt_input_2 = ""
|
||||
|
||||
if code_exe_blender:
|
||||
msg = scene.history.add()
|
||||
|
|
|
@ -143,6 +143,13 @@ def prompt_input_generator(idx):
|
|||
)
|
||||
|
||||
|
||||
bpy.props.StringProperty(
|
||||
name="a",
|
||||
description="a",
|
||||
default="",
|
||||
)
|
||||
|
||||
|
||||
def temperature_generator(idx):
|
||||
return bpy.props.FloatProperty(
|
||||
name=UI_lan['creativity'][idx],
|
||||
|
|
Ładowanie…
Reference in New Issue