Skip to content

Commit

Permalink
Merge pull request adammikulis#3 from adammikulis/0.2-dev
Browse files Browse the repository at this point in the history
Model and Inference Configuration Autoloads
  • Loading branch information
adammikulis committed May 17, 2024
2 parents 1702107 + 053aa19 commit d92c375
Show file tree
Hide file tree
Showing 22 changed files with 874 additions and 413 deletions.
27 changes: 27 additions & 0 deletions addons/mind_game/assets/grammar/json.gbnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# https://github.com/ggerganov/llama.cpp/blob/8183159cf3def112f6d1fe94815fce70e1bffa12/grammars/json.gbnf

root ::= object
value ::= object | array | string | number | ("true" | "false" | "null") ws

object ::=
"{" ws (
string ":" ws value
("," ws string ":" ws value)*
)? "}" ws

array ::=
"[" ws (
value
("," ws value)*
)? "]" ws

string ::=
"\"" (
[^"\\] |
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
)* "\"" ws

number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws

# Optional space: by convention, applied in this grammar after literal chars when allowed
ws ::= ([ \t\n] ws)?
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[gd_resource type="Resource" load_steps=7 format=3]

[ext_resource type="Script" path="res://addons/mind_game/scripts/custom_resource_scripts/InferenceParamsConfig.cs" id="1_euwpb"]
[ext_resource type="Script" path="res://addons/mind_game/scripts/custom_resource_scripts/ConfigListResource.cs" id="1_q2fe5"]
[ext_resource type="Script" path="res://addons/mind_game/scripts/custom_resource_scripts/ModelParamsConfig.cs" id="2_inpeu"]

[sub_resource type="Resource" id="Resource_01mh4"]
script = ExtResource("1_euwpb")
InferenceConfigName = "json_4k"
AntiPrompts = PackedStringArray("<|eot_id|>", "<|end|>", "user:", "User:", "USER:", "\nUser:", "\nUSER:", "}")
Temperature = 0.5
MaxTokens = 4000
OutputJson = true

[sub_resource type="Resource" id="Resource_4tk36"]
script = ExtResource("1_euwpb")
InferenceConfigName = "4k_json"
AntiPrompts = PackedStringArray("<|eot_id|>", "<|end_of_text|>", "<|user|>", "<|end|>", "user:", "User:", "USER:", "\nUser:", "\nUSER:", "}")
Temperature = 0.5
MaxTokens = 4000
OutputJson = true

[sub_resource type="Resource" id="Resource_m2syr"]
script = ExtResource("2_inpeu")
ModelConfigName = "phi3_4k"
ChatContextSize = 4000
ChatGpuLayerCount = 33
ChatRandomSeed = 0
ChatModelPath = "C:\\Users\\adamm\\source\\repos\\models\\phi3\\Phi-3-mini-4k-instruct-q4.gguf"
EmbedderContextSize = 4000
EmbedderGpuLayerCount = 33
EmbedderRandomSeed = 0
EmbedderModelPath = ""
ClipModelPath = ""

[resource]
script = ExtResource("1_q2fe5")
ModelConfigurations = [SubResource("Resource_m2syr")]
InferenceConfigurations = [SubResource("Resource_01mh4")]
CurrentInferenceConfig = SubResource("Resource_01mh4")
LastGoodInferenceConfig = SubResource("Resource_4tk36")
LastGoodModelConfig = SubResource("Resource_m2syr")
AutoloadLastGoodModelConfig = true
AutoloadLastGoodInferenceConfig = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bq0luwg34lt6j"]

[ext_resource type="Script" path="res://addons/mind_game/scripts/custom_resource_scripts/InferenceParamsConfig.cs" id="1_kq5av"]

[resource]
script = ExtResource("1_kq5av")
InferenceConfigName = "<default>"
AntiPrompts = PackedStringArray("<|eot_id|>", "<|end_of_text|>", "<|user|>", "<|end|>", "user:", "User:", "USER:", "\nUser:", "\nUSER:", "}")
Temperature = 0.5
MaxTokens = 4000
OutputJson = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://cs8lnb4ocy45e"]

[ext_resource type="Script" path="res://addons/mind_game/scripts/custom_resource_scripts/ModelParamsConfig.cs" id="1_ux3d5"]

[resource]
script = ExtResource("1_ux3d5")
ModelConfigName = "<default>"
ChatContextSize = 4000
ChatGpuLayerCount = 33
ChatRandomSeed = 0
ChatModelPath = ""
EmbedderContextSize = 4000
EmbedderGpuLayerCount = 33
EmbedderRandomSeed = 0
EmbedderModelPath = ""
ClipModelPath = ""
2 changes: 1 addition & 1 deletion addons/mind_game/assets/themes/config_header_theme.tres
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

[resource]
default_font = SubResource("SystemFont_acuki")
default_font_size = 20
default_font_size = 24
13 changes: 0 additions & 13 deletions addons/mind_game/custom_resources/ConfigListResource.cs

This file was deleted.

6 changes: 0 additions & 6 deletions addons/mind_game/custom_resources/ConfigListResource.tres

This file was deleted.

3 changes: 0 additions & 3 deletions addons/mind_game/custom_resources/InferenceParams.tres

This file was deleted.

6 changes: 0 additions & 6 deletions addons/mind_game/custom_resources/ModelConfigsParams.tres

This file was deleted.

191 changes: 191 additions & 0 deletions addons/mind_game/scenes/controllers/InferenceConfigController.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
[gd_scene load_steps=6 format=3 uid="uid://3sy7uksi0h1a"]

[ext_resource type="Script" path="res://addons/mind_game/scripts/controllers/InferenceConfigController.cs" id="1_rm55x"]
[ext_resource type="Texture2D" uid="uid://dnp0lvxevsc4m" path="res://addons/mind_game/assets/game_icons/PNG/White/1x/plus.png" id="2_dqa1d"]
[ext_resource type="Theme" uid="uid://brptib3mp8h1o" path="res://addons/mind_game/assets/themes/config_header_theme.tres" id="2_jnnww"]
[ext_resource type="Texture2D" uid="uid://5ga0x3yawju4" path="res://addons/mind_game/assets/game_icons/PNG/White/1x/trashcan.png" id="3_ga7yw"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ggnmd"]
bg_color = Color(0.396889, 0.396889, 0.396889, 1)

[node name="InferenceConfigController" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_rm55x")

[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
offset_right = 1152.0
offset_bottom = 648.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5

[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
layout_mode = 2

[node name="InferenceConfigTitleLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme = ExtResource("2_jnnww")
text = "Inference Configuration"
horizontal_alignment = 1

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3

[node name="PanelContainer" type="PanelContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/PanelContainer"]
layout_mode = 2
size_flags_horizontal = 0

[node name="BackButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/PanelContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Back"

[node name="AddInferenceConfigButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/PanelContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
icon = ExtResource("2_dqa1d")

[node name="DeleteInferenceConfigButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/PanelContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
icon = ExtResource("3_ga7yw")

[node name="AutoloadLastGoodConfigCheckBox" type="CheckBox" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/PanelContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Autoload Last
Good Config"

[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3

[node name="Panel" type="Panel" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/MarginContainer"]
layout_mode = 2

[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/MarginContainer/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3

[node name="SavedInferenceConfigsItemList" type="ItemList" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer/MarginContainer/Panel/ScrollContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 50)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
item_count = 2
item_0/text = "4k_json"
item_1/text = "4k_high_temp"

[node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3

[node name="Panel" type="Panel" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
layout_mode = 2
size_flags_vertical = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_ggnmd")

[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5

[node name="GridContainer" type="GridContainer" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2"]
layout_mode = 2
size_flags_vertical = 3
columns = 3

[node name="NameTitleLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
layout_mode = 2
text = "Name"

[node name="NameLineEdit" type="LineEdit" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "4k_json"

[node name="PlaceholderLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
layout_mode = 2

[node name="MaxTokensTitleLable" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
layout_mode = 2
text = "MaxTokens"

[node name="MaxTokensHSlider" type="HSlider" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
max_value = 12.0
value = 2.0
tick_count = 13
ticks_on_borders = true

[node name="MaxTokensLineEdit" type="LineEdit" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "4000"
editable = false

[node name="TemperatureTitleLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
layout_mode = 2
text = "Temperature"

[node name="TemperatureHSlider" type="HSlider" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
max_value = 1.5
step = 0.05
value = 0.5
tick_count = 31
ticks_on_borders = true

[node name="TemperatureLineEdit" type="LineEdit" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "0.5"
editable = false

[node name="OutputJsonCheckBox" type="CheckBox" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Panel/MarginContainer2/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Output JSON"
Loading

0 comments on commit d92c375

Please sign in to comment.