SceneTree doesnt run

Godot Version

4.5.stable

Question

I have a script which has type SceneTree, I cannot get it to run. I am new to godot so if something is super obvious, just tell me.

Program:

extends SceneTree

const server = {"host": "https://localhost","port": 11434}
const model = "gpt-oss:120b-cloud"
var prompt = [
	{
		"role": "user",
		"content": "Hello! I am Nathanne."
	},
	{
		"role": "assistant",
		"content": "Hello, Nathanne. I am ChatGPT, an AI assistant developed by OpenAI."
	},
	{
		"role": "user",
		"content": "Can you tell me back my name? (Answer in one sentence only)"
	}
]
# Preload the NokoModel module, which provides functions to manage AI models.
const NokoModel = preload("res://addons/noko/modules/NokoModel.gd")

# Preload the NokoPrompt module, which provides functions to interact with AI models via prompts.
const NokoPrompt = preload("res://addons/noko/modules/NokoPrompt.gd")



func _init():
	call_deferred("_Call_Models()")

func _Call_Models():
	
	print("Loading Models")
	
	var root = get_root()
	
	if await NokoModel.load_chat_model(root, server, model, false):
		print("Successfully loaded model: " + model)
	else:
		print("Something went wrong trying to load model: " + model)
		quit()  # Terminate the application if loading fails.
	
	# Asynchronously send the conversation prompt to the AI model and await the response.
	var generated = await NokoPrompt.chat(root, server, model, prompt)
	
	# Output the assistant's response from the AI model.
	print(prompt)
	print(model + ":\t" + generated["body"]["message"]["content"])
	
	# Asynchronously unload the chat model from the server to free up resources.
	if await NokoModel.unload_chat_model(root, server, model, false):
		print("Successfully unloaded model: " + model)
	else:
		print("Something went wrong trying to unload model: " + model)

For reference, I am using this: GitHub - nthnn/noko: User-friendly Godot plugin that facilitates seamless interaction with Ollama models via API that empowers developers to enhance their games with interactive Large Language Models (LLMs), enabling dynamic dialogues, intelligent NPCs, and more.​

I believe you have been punked by AI. That README was clearly written by AI.

As far as I know, you can’t do that. You can add and remove things from SceneTree, but you can’t write your own. If you want to write your own you need to compile your own custom version of Godot and you’ll need to write it in C++. Perhaps I am wrong, but that code looks like it was written by AI which just made this code up.

Even if you can, you would have to somehow indicate to the engine how to use this new version of SceneTree instead of the default, which nowhere in the documentation does it tell you how to do this.

In the instructions, it says to:

Copy the addons/noko directory into your Godot project’s addons folder.​

However there is no addons folder anywhere in the project. So there is no addon. It’s not going to work.

Other Options

There are two other options that may be more viable that I recommend trying out:

How are you trying to run this script? SceneTree type nodes are only useful if set as the Main Loop. You can assing this in your project setting at "application/run/main_loop_type" or run godot -s your_script.gs

2 Likes