File tree 5 files changed +72
-1
lines changed
5 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ config_version=5
11
11
[application ]
12
12
13
13
config/name ="godot cpp template"
14
- config/features =PackedStringArray ("4.1 " , "Forward Plus" )
14
+ config/features =PackedStringArray ("4.2 " , "Forward Plus" )
15
15
config/icon ="res://icon.svg"
Original file line number Diff line number Diff line change
1
+ #ifndef LLAMA_CONTEXT_H
2
+ #define LLAMA_CONTEXT_H
3
+
4
+ #include < godot_cpp/classes/node.hpp>
5
+ #include " llama_model.h"
6
+
7
+ namespace godot {
8
+ class LlamaContext : public Node {
9
+ GDCLASS (LlamaContext, Node)
10
+
11
+ private:
12
+ LlamaModel model;
13
+
14
+ protected:
15
+ static void _bind_methods ();
16
+
17
+ public:
18
+ LlamaContext ();
19
+ ~LlamaContext ();
20
+ };
21
+ }
22
+
23
+ #endif
Original file line number Diff line number Diff line change
1
+ #include " llama.h"
2
+ #include " common.h"
3
+ #include " llama_model.h"
4
+ #include < godot_cpp/core/class_db.hpp>
5
+
6
+ using namespace godot ;
7
+
8
+ void LlamaModel::_bind_methods () {
9
+ }
10
+
11
+ LlamaModel::LlamaModel () {
12
+ llama_model_params model_params = llama_model_default_params ();
13
+ model = llama_load_model_from_file (resource_path, model_params);
14
+
15
+ if (model == NULL ) {
16
+ ERR_FAIL_NULL_MSG (model, " Unable to load model" );
17
+ }
18
+ }
19
+
20
+ LlamaModel::~LlamaModel () {
21
+ llama_free_model (model);
22
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef LLAMA_MODEL_H
2
+ #define LLAMA_MODEL_H
3
+
4
+ #include " llama.h"
5
+ #include < godot_cpp/classes/resource.hpp>
6
+
7
+ namespace godot {
8
+
9
+ class LlamaModel : public Resource {
10
+ GDCLASS (LlamaModel, Resource)
11
+
12
+ private:
13
+ const char * resource_path;
14
+ llama_model* model;
15
+
16
+ protected:
17
+ static void _bind_methods ();
18
+
19
+ public:
20
+ LlamaModel ();
21
+ ~LlamaModel ();
22
+ };
23
+
24
+ } // namespace godot
25
+
26
+ #endif
You can’t perform that action at this time.
0 commit comments