Giter VIP home page Giter VIP logo

godot-llm-experiment's Introduction

Introduction

Trying to integrate an LLM into Godot.

First use-case: for spicing up NPC chatter.

Video:

Video

Screenshot:

It works

Work log

See docs/worklog.md.

Linux-only for now. (Mac and Windows folks, please send PRs!)

Quickstart

mkdir -p models
cd models
wget https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q5_K_M.gguf
cd ..

git clone https://github.com/ggerganov/llama.cpp.git llama_dot_cpp
git clone https://github.com/godotengine/godot-cpp.git

cp SConstruct-llamacpp llama_dot_cpp/SConstruct
cd llama_dot_cpp
scons -j31
cd ..

cd godot-cpp
git checkout godot-4.1.1-stable
cp gdextension/extension_api.json ../the-game/extension_api.json
scons platform=linux -j31 custom_api_file=$(pwd)/../the-game/extension_api.json
cd ..

cp llama_dot_cpp/libllama.so the-game/bin
# build my gdextension here:
scons platform=linux -j31

cp models/mistral-7b-instruct-v0.1.Q5_K_M.gguf the-game/bin/
# load the game in Godot

Note that if you run scons -c in the root, it will remove the built dependencies in llama_dot_cpp, so scons have to be run for the latter again for building the extension.

So, any future iterations look like this:

rm the-game/bin/*.so;  scons -c
# make changes to the extension code
cd llama_dot_cpp
scons -j31
cd ..
cp llama_dot_cpp/libllama.so the-game/bin
scons platform=linux -j31

Or

rm the-game/bin/libgdllm.linux.template_debug.x86_64.so
rm src/*.os
scons platform=linux -j31

If any experts in scons/c++ reads this, I think the SConstruct-llamacpp step is probably unnecessary, and that I can get away with building llama.cpp using its own Makefile, and then just linking to the resulting .a file in the extension's SConstruct file. But I'm not sure how to do that.

Export

cd the-game
godot --export-debug "Linux/X11" godot-llm-experiment.x86_64
cd ..

(I see this when I run the above command.)

It will run from here with ./godot-llm-experiment.x86_64, because it's alongside the bin/ folder.

To run it standalone, outside of the context of the source/project files:

TMP=$(mktemp -d)
cp the-game/godot-llm-experiment.x86_64 $TMP
cp -R the-game/bin $TMP
cd $TMP
./godot-llm-experiment.x86_64

You can now publish $TMP as a ZIP file.

Credits

godot-llm-experiment's People

Contributors

opyate avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.