Oracle APEX 26.1 and local AI Model
Computer Specs
The AI model you can run on your PC will depend on your hardware, these are my PC Specs so you can compare, maybe you can run a better model.- Processor: Intel Core Ultra 5 245K
- RAM: 32 GB
- Graphic Card: GTX 1050 Ti (4 GB VRAM)
- Operative system: Windows 11 Home single language
Installing Ollama
We'll use Ollama as our tool for AI, you can install it from here:
After installing Ollama you need to download the AI model, there are many
models available:
For My hardware, Gemini recommended
llama3.1:8b (Link) or qwen2.5-coder:14b (Link), llama is not the smartest one but at least is fast and will work for
testing that everything is working fine.
If you want to use the same one open a CDM and type
ollama run llama3.1When it finishes you can test it by typing a message on the console, after testing close it.
Disable AutoStart
Ollama will start with windows automatically and there is no option on settings to disable this, you can open task Manager and go to Start up apps, find ollama and delete it from there, that way you will not load any AI model when you don't need it.Enable external access
Now you have an AI model running on your computer, if you are running APEX on your computer you don't need this step, just uselocalhost:11434 when asked for the model URL. But if you are
using APEX on the cloud or oracleapex.com you need this to make it available,
the good news here is that you don't need to install anything, Pinggy will
create the http tunnel for you with a single command.
First, go to setting on Ollama and make sure the "Expose Ollama to the
network" is selected
create a new file, call it
Execute the file, It will ask for a password, just leave it empty and press enter.
pinggy.bat and insert this:
@echo off title Pinggy echo Connecting to Pinggy... ssh -p 443 -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -R 80:localhost:11434 free.pinggy.io pauseLine 4 makes the magic and would be enought, we are just creating a batch file so you don't have to copy/paste the command everytime you need it.
Execute the file, It will ask for a password, just leave it empty and press enter.
this will give you a URL to access to ollama services
Now you have the URL to access your service, but due to pinggy free service limitants this link will last only 60 minutes, after that time you will need to create a new one and update url on APEX, but for testing this might be enough, however if you need a permanent url you can buy a plan on piggin or try other similar tools.
Now you have the URL to access your service, but due to pinggy free service limitants this link will last only 60 minutes, after that time you will need to create a new one and update url on APEX, but for testing this might be enough, however if you need a permanent url you can buy a plan on piggin or try other similar tools.
Setting APEX
We have everything ready for APEX, on APEX 26.1 go to "Workspace
Utilities > All workspace Utilities" select "Generative AI" and create a new service
Set these parameters
| Parameter | Value |
|---|---|
| AI Provider | Ollama |
| Name | Set a custom name for this AI service |
| Used by APP Builder | Set Yes if you want to use this AI service on builder, i.e. help you to build a query |
| Base URL | Set the URL created by Pinggy |
| Credential | Leave it empty |
| API Key | Leave it empty |
| AI Model | your AI Model name, the same you used when installing the model i.e. llama3.1:8b |
Before click on "Create" you can click on "Test connection", you'll see
that your Pinggy logs this connection:
APEX created a web credentials for this AI service, however this is
linked to a URL for security, we have to change our AI service URL every
60 minutes so removing this validation will save us to update it here as
well, if you want to remove it, go to "Workspace Utilities > All
workspace Utilities" and select "Web Credentials", clear "Valid for
URLs" item and save.
Testing
Now to test that everything worked go to SQL Commands, click on APEX
Assistant and type a simple prompt:
We have received an answer from our local AI and now we can use it for
development and test.... Let's celebrate!!!
Comments
Post a Comment