kopia lustrzana https://github.com/gd3kr/BlenderGPT
added option to delete previous chat messages
rodzic
86ccd40c2e
commit
4929faf0fa
22
__init__.py
22
__init__.py
|
@ -135,6 +135,16 @@ def split_area_to_text_editor(context):
|
||||||
new_area.type = 'TEXT_EDITOR'
|
new_area.type = 'TEXT_EDITOR'
|
||||||
return new_area
|
return new_area
|
||||||
|
|
||||||
|
class GPT4_OT_DeleteMessage(bpy.types.Operator):
|
||||||
|
bl_idname = "gpt4.delete_message"
|
||||||
|
bl_label = "Delete Message"
|
||||||
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
|
message_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
context.scene.gpt4_chat_history.remove(self.message_index)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
class GPT4_OT_ShowCode(bpy.types.Operator):
|
class GPT4_OT_ShowCode(bpy.types.Operator):
|
||||||
bl_idname = "gpt4.show_code"
|
bl_idname = "gpt4.show_code"
|
||||||
|
@ -182,14 +192,19 @@ class GPT4_PT_Panel(bpy.types.Panel):
|
||||||
|
|
||||||
column.label(text="Chat history:")
|
column.label(text="Chat history:")
|
||||||
box = column.box()
|
box = column.box()
|
||||||
for message in context.scene.gpt4_chat_history:
|
for index, message in enumerate(context.scene.gpt4_chat_history):
|
||||||
if message.type == 'assistant':
|
if message.type == 'assistant':
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.label(text="Assistant: ")
|
row.label(text="Assistant: ")
|
||||||
show_code_op = row.operator("gpt4.show_code", text="Show Code")
|
show_code_op = row.operator("gpt4.show_code", text="Show Code")
|
||||||
show_code_op.code = message.content
|
show_code_op.code = message.content
|
||||||
|
delete_message_op = row.operator("gpt4.delete_message", text="", icon="TRASH", emboss=False)
|
||||||
|
delete_message_op.message_index = index
|
||||||
else:
|
else:
|
||||||
box.label(text=f"User: {message.content}")
|
row = box.row()
|
||||||
|
row.label(text=f"User: {message.content}")
|
||||||
|
delete_message_op = row.operator("gpt4.delete_message", text="", icon="TRASH", emboss=False)
|
||||||
|
delete_message_op.message_index = index
|
||||||
|
|
||||||
column.separator()
|
column.separator()
|
||||||
|
|
||||||
|
@ -291,6 +306,8 @@ def register():
|
||||||
bpy.utils.register_class(GPT4_PT_Panel)
|
bpy.utils.register_class(GPT4_PT_Panel)
|
||||||
bpy.utils.register_class(GPT4_OT_ClearChat)
|
bpy.utils.register_class(GPT4_OT_ClearChat)
|
||||||
bpy.utils.register_class(GPT4_OT_ShowCode)
|
bpy.utils.register_class(GPT4_OT_ShowCode)
|
||||||
|
bpy.utils.register_class(GPT4_OT_DeleteMessage)
|
||||||
|
|
||||||
|
|
||||||
bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
|
bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
|
||||||
init_props()
|
init_props()
|
||||||
|
@ -302,6 +319,7 @@ def unregister():
|
||||||
bpy.utils.unregister_class(GPT4_PT_Panel)
|
bpy.utils.unregister_class(GPT4_PT_Panel)
|
||||||
bpy.utils.unregister_class(GPT4_OT_ClearChat)
|
bpy.utils.unregister_class(GPT4_OT_ClearChat)
|
||||||
bpy.utils.register_class(GPT4_OT_ShowCode)
|
bpy.utils.register_class(GPT4_OT_ShowCode)
|
||||||
|
bpy.utils.register_class(GPT4_OT_DeleteMessage)
|
||||||
|
|
||||||
bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
|
bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
|
||||||
clear_props()
|
clear_props()
|
||||||
|
|
Ładowanie…
Reference in New Issue