Skip to content

Commit a60064a

Browse files
committed
prevent loading model in editor
1 parent 97b11e8 commit a60064a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

godot/main.tscn

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[gd_scene load_steps=3 format=3 uid="uid://7oo8yj56scb1"]
1+
[gd_scene load_steps=4 format=3 uid="uid://7oo8yj56scb1"]
22

33
[ext_resource type="Texture2D" uid="uid://dplw232htshgc" path="res://addons/godot-llama-cpp/assets/godot-llama-cpp-1024x1024.svg" id="1_ojdoj"]
44
[ext_resource type="Script" path="res://main.gd" id="1_wiuk3"]
5+
[ext_resource type="LlamaModel" path="res://models/stablelm-2-zephyr-1_6b-Q4_K_M.gguf" id="3_hnmbg"]
56

67
[node name="Node" type="Node"]
78
script = ExtResource("1_wiuk3")
@@ -10,3 +11,6 @@ script = ExtResource("1_wiuk3")
1011
position = Vector2(601, 325)
1112
scale = Vector2(0.2, 0.2)
1213
texture = ExtResource("1_ojdoj")
14+
15+
[node name="LlamaContext" type="LlamaContext" parent="."]
16+
model = ExtResource("3_hnmbg")

src/llama_model_loader.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <godot_cpp/core/class_db.hpp>
44
#include <godot_cpp/classes/file_access.hpp>
55
#include <godot_cpp/classes/project_settings.hpp>
6+
#include <godot_cpp/classes/engine.hpp>
67

78
using namespace godot;
89

@@ -19,6 +20,10 @@ Variant godot::LlamaModelLoader::_load(const String &path, const String &origina
1920
return ERR_FILE_NOT_FOUND;
2021
}
2122

23+
if (Engine::get_singleton()->is_editor_hint()) {
24+
return { model };
25+
}
26+
2227
String absPath = ProjectSettings::get_singleton()->globalize_path(path);
2328

2429
model->load_model(absPath);

0 commit comments

Comments
 (0)