{"id":3579,"date":"2025-01-22T14:26:47","date_gmt":"2025-01-22T01:26:47","guid":{"rendered":"https:\/\/www.talkcrypto.org\/blog\/?p=3579"},"modified":"2025-02-16T15:07:37","modified_gmt":"2025-02-16T02:07:37","slug":"subquery-fancy-greeter-step-by-step","status":"publish","type":"post","link":"https:\/\/www.talkcrypto.org\/blog\/2025\/01\/22\/subquery-fancy-greeter-step-by-step\/","title":{"rendered":"SubQuery Fancy Greeter Step by Step"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Getting the SubQuery Fancy Greeter up and running only takes a few minutes, if you know what you are doing. Otherwise, it can take a frustrating half to one whole day. The key is in the preparation, just like any cooking show. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The prep<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll need <a href=\"https:\/\/docs.deno.com\/runtime\/getting_started\/installation\/\">Deno<\/a> installed as well as <a href=\"https:\/\/ollama.com\/download\">Ollama<\/a> if you want to run the example locally. Otherwise, you can connect to OpenAI&#8217;s endpoint but you&#8217;ll need a paid API key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have the above installed, run these commands to check:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>seandotau@aseandotaus-MBP ~ % deno --version\ndeno 2.1.6 (stable, release, aarch64-apple-darwin)\nv8 13.0.245.12-rusty\ntypescript 5.6.2\nseandotau@aseandotaus-MBP ~ % ollama --version\nollama version is 0.5.11<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Deno<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To install Deno, run the following command: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deno install -g -f --allow-env --allow-net --allow-import --allow-read --allow-write --allow-ffi --allow-run --unstable-worker-options -n subql-ai jsr:@subql\/ai-app-framework\/cli<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>deno install<\/code>: Installs a script or tool globally.<br><code>-g<\/code>: Stands for &#8220;global,&#8221; meaning this tool will be installed globally and can be run from anywhere.<br><code>-f<\/code>: Forcefully installs the tool, even if a version is already installed.<br><code>--allow-env<\/code>: Grants the script permission to access environment variables.<br><code>--allow-net<\/code>: Grants the script permission to access the network.<br><code>--allow-import<\/code>: Allows the script to import other modules or files.<br><code>--allow-read<\/code>: Grants the script permission to read files from the file system.<br><code>--allow-write<\/code>: Grants the script permission to write files to the file system.<br><code>--allow-ffi<\/code>: Allows the script to use Foreign Function Interface (FFI) calls to interact with native code.<br><code>--allow-run<\/code>: Allows the script to run subprocesses.<br><code>--unstable-worker-options<\/code>: Enables experimental or unstable worker options (Deno may evolve and this option might not be permanent).<br><code>-n subql-ai<\/code>: Specifies the name of the tool or binary being installed (<code>subql-ai<\/code> in this case).<br><code>jsr:@subql\/ai-app-framework\/cli<\/code>: Refers to the source code or module being installed. It&#8217;s using a JS package specifier to fetch a module (<code>@subql\/ai-app-framework\/cli<\/code>) from a URL or registry (the <code>jsr:<\/code> prefix).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Ollama<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">See <a href=\"https:\/\/www.talkcrypto.org\/blog\/2025\/01\/08\/ollama-for-beginners\/\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a new app<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>subql-ai init<\/code> and provide a project name. Then specify the LLM model. You should have downloaded a model when installing Ollama. If not, download one following the instructions <a href=\"https:\/\/www.talkcrypto.org\/blog\/2025\/01\/08\/ollama-for-beginners\/\">here<\/a> and restart this process. I&#8217;ll use llama3.2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>seandotau@aseandotaus-MBP subquery % subql-ai init\nEnter a project name:  testai\nEnter a LLM model llama3.2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should have a folder structure like the following: <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"198\" height=\"168\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-3.png\" alt=\"\" class=\"wp-image-3580\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the tricky bit. Update the manifest file to: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  endpoints: &#91;\"localhost:11434\"],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">which is the endpoint for your local llama3.2 dataset. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"706\" height=\"514\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-4.png\" alt=\"\" class=\"wp-image-3581\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-4.png 706w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-4-300x218.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Running the app<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Assuming you have Ollama running in the background already and you have the correct model version, then run the app via: <code>subql-ai -p .\/manifest.ts<\/code>. You should get: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>seandotau@aseandotaus-MBP testai % subql-ai -p .\/manifest.ts\n&#91;12:54:33.357] INFO (app): Subql AI Framework (0.0.5)\n\u2714 Loaded project manifest\n\u2714 Loaded project source\nListening on http:\/\/0.0.0.0:7827\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now in another terminal, run: <code>subql-ai repl<\/code>. You should get:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>seandotau@aseandotaus-MBP testai % subql-ai repl\nSpecial messages:\n    \/bye: to exit (ctrl + c also works)\n    \/clear: to remove all previous chat history\n\nEnter a message:  hi\nThat was quick! It seems like I have the user's name already. Let me try something a bit more personalized.\n\nWhat's your favorite hobby or interest?\nEnter a message:  <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"219\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-5-1024x219.png\" alt=\"\" class=\"wp-image-3582\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-5-1024x219.png 1024w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-5-300x64.png 300w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-5-768x164.png 768w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/02\/image-5.png 1076w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There you have it. Running SubQuery&#8217;s AI framework with a local instance of Ollama within minutes. There are other options of running the app such as via Docker, and connecting to OpenAI which I&#8217;ll explore in another write up. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting the SubQuery Fancy Greeter up and running only takes<\/p>\n","protected":false},"author":1,"featured_media":3584,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50],"tags":[],"class_list":["post-3579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"featured_image_urls":{"full":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",778,441,false],"thumbnail":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM-150x150.png",150,150,true],"medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM-300x170.png",300,170,true],"medium_large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM-768x435.png",640,363,true],"large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",640,363,false],"1536x1536":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",778,441,false],"2048x2048":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",778,441,false],"chromenews-featured":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",778,441,false],"chromenews-large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM.png",778,441,false],"chromenews-medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2025\/01\/Screenshot-2025-02-16-at-1.05.55\u202fPM-590x410.png",590,410,true]},"author_info":{"info":["seandotau"]},"category_info":"<a href=\"https:\/\/www.talkcrypto.org\/blog\/category\/ai\/\" rel=\"category tag\">AI<\/a>","tag_info":"AI","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/3579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/comments?post=3579"}],"version-history":[{"count":1,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/3579\/revisions"}],"predecessor-version":[{"id":3583,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/3579\/revisions\/3583"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media\/3584"}],"wp:attachment":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media?parent=3579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/categories?post=3579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/tags?post=3579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}