The AI Assistant¶
The Assistant tab of the AI panel answers questions about the open model in plain language (where the largest stress is, which combination governs the reinforcement, what a command does), makes the changes you ask for, and presses the buttons of the window for you. Show or hide the panel from View → AI panel.
It is optional. Every other part of xdfem2D works without it, and the panel says so when nothing is installed. For a job of several steps, the Agent tab does the steps itself; AI in xdfem2D compares the two.
What you write decides what happens¶
You can just write. The assistant reads the sentence and decides which of five things you mean (this is Auto, and it is how it always starts). When you want to decide yourself, or it chose wrong, begin the sentence with a prefix.
| Prefix | Or | Mode | What it does | Asks the model |
|---|---|---|---|---|
? |
/q /query |
Query | Answers a question about the open model and its results: which combination governs the reinforcement of E3? It reads; it never changes the model. First it tries a short typed question (get) that the program answers itself, exact and fast; if that is not enough, the model reads through its tools. |
yes |
+ |
/c /create |
Create | Builds or changes the model: add a 20 kN load at midspan. The model writes short commands that the application checks on a copy; if the commands cannot say it, a Python script, also checked on a copy. Applied at once or held for Apply (see Creating and changing a model). | yes |
= |
/v /verify (or /check) |
Check | Runs a verification of the members, as the Design menu does: concrete beams and columns, crack width, slabs and walls, steel, timber, and the suggested column reinforcement. The result shows in the design views. The analysis has to have been run. | no |
> |
/a /action |
Action | Does what a menu or the Display panel does: show the deformed shape, grid of 0.5 m, run the analysis, save as beam1 (see Doing what the window does). If it is not sure which action you mean it lists the closest and runs nothing. | no |
: |
/i /assistant |
Assistant | Free conversation: about the program, the manual, engineering in general. It does not see your model, so it is not for the numbers of your project. | yes |
"Asks the model" says whether the language model is used at all. Check and Action are carried out by the application itself: they are fast and cost nothing, even with a remote model selected.
How a prefix is read¶
- Only at the very start of the sentence, and it is taken off before the sentence goes on.
- A symbol counts only when a space or a letter follows it:
+5 kN,=2 mand>=9are numbers, not prefixes. A slash word counts only when it is the whole first word (/q which bar, not/quantity). - Type
/in the box and the list of the kinds of request opens (pick one with the mouse, or with the arrows and Tab or Enter). As soon as a prefix is typed, the line under the box says what it does.
With no prefix (Auto)¶
- A sentence with a question mark is a Query.
- A sentence that only selects (select E2, select the beams at y=6, deselect V1, seleciona os nós A e B) is done
at once, with no model: it marks them in the drawing and adds them to what is selected (
select only ...replaces the selection,select noneclears it,select previousgoes back). An action that uses the selection (move, divide, delete …) leaves nothing selected; select previous brings it back. - Anything else the router decides between the five modes. When it is close, the answer says so.
Which to use¶
Write normally first. A prefix is for when you know better than the router, or for a short sentence that could be read two ways (+ 3 m is a change; 3 m? is a question). If an answer came from the wrong mode, repeat the sentence with the prefix you meant.
Getting started¶
The Assistant ships without a language model. To use it:
- Install Ollama and start it (
ollama serve; the Ollama desktop app does this for you). - Fetch a model:
ollama pull gemma4:e4b, about 9.5 GB. It is the one the assistant starts with (see Tested models); whichever you use must support tool calls. - Open the panel (View ▸ AI panel, or F10) and press Refresh. The model appears in the list.
- Ask something, such as which supports does this model have?. If an answer comes, it works.
No Ollama, or a computer too slow for it? Use a remote service with an API key instead; see Where the model runs. A model is missing from the list? Refresh reads it again; a model marked — no tool support cannot be used. Without any of this, the rest of xdfem2D works exactly the same.
The panel, from top to bottom¶
Provider and Providers…: where the assistant runs. Ollama (local) is your own machine; the others are services you have a key for. Providers… adds a key (see Where the model runs).
Model and Refresh: the models the provider offers; Refresh reads the list again. A note beside a name matters: — no tool support means the model cannot call the tools that read your model, so it would answer from nothing (do not use it); (ollama cloud) means it runs on Ollama's machines, so your model is sent there.
Temperature and Think: how the model answers. The defaults suit modelling; see Temperature and Think before changing them.
ⓘ: opens this page in the application, with no internet needed.
The box, Send and New conversation: write a request and press Cmd+Enter (Ctrl+Enter elsewhere); Enter is a new line. While an answer is coming Send becomes Stop. New conversation clears the conversation and what the model remembers of it.
Open and Apply: for a reply that wrote Python, or commands that are waiting. Apply applies them after checking again against the model that is open now; Open shows the Python in the script editor. They are greyed out when there is nothing to apply.
The router bar (at the bottom): how Auto decides. off is a plain keyword classifier; regression is the classifier of
the application; regression + a model lets a model of embeddings help to choose the action of the window. Under each
sentence it shows the mode it chose and how sure it was. (Confirming or correcting its choice is a developer tool: it shows
only with router_verdicts = on under [assistant] in ~/.xdfem2d/config.ini.)
What lasts and what is remembered¶
The model, temperature and Think you choose in the panel last until you close the application. Preferences ▸ AI Assistant holds what it starts with, and changing a value there replaces the choice of the session (see Preferences). Also there: Apply the assistant's commands at once and Answer a request in one reply.
Warnings¶
Before a message goes to a remote model, and when you turn Think on, the assistant asks first. Each has Don't show this again; Preferences ▸ AI Assistant ▸ Show the assistant's warnings again brings them back. Checking every change on a copy of the model, and the notes under the replies, are always on.
Temperature and Think¶
Two controls under the model list change how the model answers. The defaults are right for modelling: change them only for a reason.
Temperature (default 0) is how much the answer varies. A model writes an answer one word at a time, and at each step it has a ranked list of words that could come next. At temperature 0 it always takes the first of the list, so the same question gives the same answer. As the temperature rises it more and more often takes a lower one: the answers become more varied, and less careful.
- 0: use it for modelling, for numbers and for anything the assistant has to do. A tool call is an exact format (a node id, a number, a name), so it shouldn't be neessary to be creative.
- 0.1 to 0.2: for some hard question to which the model has answered wrong.
- 0.3 to 0.7: only for free conversation, or to ask for alternatives (give me three layouts). The price is more wrong ids and invented values.
- Above that the model starts to ramble, and a small model stops following the format of its tools.
- It does not make a model smarter. If an answer is wrong at 0, a higher value is not the fix: ask again with more detail, or use a better model (see Choosing a model).
Think (default off) lets the model reason silently before it answers.
A reasoning pass costs time, and on a small model it is not necessarily better. Turning Think on shows a warning once (Don't show this again silences it), and it only acts on Ollama models. Below is a small guide to when it is worth trying.
| Situation | Try |
|---|---|
| A short request, or a small model: you want the answer fast | Think off (the default) |
| A hard question (which combination governs?) is answered wrongly | Think on |
| The box is greyed out | The model has no thinking channel: there is nothing to switch |
Both last until you close the application. Preferences ▸ AI Assistant sets what a launch starts with.
Where the model runs¶
The Provider at the top of the panel decides where the language model runs.
| On your computer | On another machine of yours | A remote service | |
|---|---|---|---|
| Provider | Ollama (local) | Ollama (local), with OLLAMA_HOST |
OpenAI, Google Gemini, Ollama Cloud, … |
| What leaves your network | Nothing | Nothing | Your question, and what the assistant reads of your model |
| Needs | Ollama | Ollama running on that machine | An API key |
| Quality and speed | What your computer allows; a small model gives wrong answers that look right (see Choosing a model) | A real GPU, with the same privacy | The most reliable, and far better at building a model |
Rule of thumb. Start local. Use a remote model when your computer is too slow, or when a model has to be built from a long description, and your work allows it. Under a confidentiality obligation, stay on your computer or on a machine of your own network: that is the speed of a real GPU with none of the disclosure.
A remote model receives the geometry, loads, sections and results the assistant reads to answer. The panel asks once per session before the first remote question (see Warnings).
Using a remote service¶
Press Providers… beside the model list, paste the key, and the service's models appear below a separator, labelled with the provider.
Which services¶
Most services speak OpenAI's API at a different address, so OpenAI, Google Gemini, Ollama Cloud, DeepSeek, Kimi (Moonshot), GLM (Zhipu), Mistral, Groq and OpenRouter are already listed under Providers…. Paste a key beside one and its models join the list.
Anthropic is not among them: its API is shaped differently enough to need a second client library and a second translation of every tool, which is a lot of machinery — and a lot of megabytes in the packaged application — for one provider out of ten. Claude models are available through OpenRouter.
Ollama in the cloud, or on another machine¶
Two different things, and only one of them sends your model away.
Ollama Cloud runs the models on Ollama's machines. Add an
OLLAMA_API_KEY under Providers… and it behaves like any other remote
service — same warning, same marking in the list. Useful on a laptop that
cannot hold an 8B model.
Your own Ollama on another machine — an office workstation with a GPU, say
— needs nothing here at all. The local provider follows Ollama's own
OLLAMA_HOST variable:
export OLLAMA_HOST=http://workstation.local:11434
The panel then lists that machine's models and nothing leaves your network. For work under a confidentiality obligation this is the arrangement to prefer: the speed of a real GPU with none of the disclosure.
For anything else — a service newer than this release, or a company gateway —
use Add endpoint… in the same dialog. It asks for a name and the base URL
of the OpenAI-compatible API, and writes them to
~/.xdfem2d/llm_endpoints.json:
{
"myprovider": {
"env": "MYPROVIDER_API_KEY",
"base_url": "https://api.example.com/v1",
"models": ["some-model"]
}
}
That file holds addresses, not secrets. An entry there overrides a built-in one, which is how to correct an address that has moved without waiting for a new release.
Where the keys are kept¶
In your system keychain — Keychain Access on macOS, and the equivalent
elsewhere — under the service name xdfem2d. They are encrypted at rest, and
you can inspect or revoke them there without going through this application.
They are never written to the preferences file, which is plain text, and never
into a .x2d, which would carry the key to whoever you send the model to.
An environment variable of the same name still works and is useful for
scripting, but it is second in line: a key stored through the dialog wins. Note
that launching from the Dock or Finder does not inherit shell variables, so a
key set only in ~/.zshrc will appear missing — another reason to prefer the
dialog.
Storing keys needs the keyring package, which ships with xdfem2D. It is not a
vault of its own — on macOS it is a thin layer over the system Keychain, the
same one Safari uses, and the entries appear in Keychain Access under the
service name xdfem2d. The first time a key is saved, macOS asks whether
Python may use the Keychain; answer Always Allow or it will ask again at
every start.
If it is missing from your environment, install it with pip install keyring.
The dialog says so rather than failing quietly, and falls back to environment
variables meanwhile.
No extra install is needed for any of them. The openai client is a normal
dependency of xdfem2D and ships with the packaged application, and every
provider above is reached through it — only the key is missing.
Choosing a model¶
The model, temperature and Think you choose in the panel are for the current session; the ones in Preferences ▸ AI Assistant are what a launch starts with (see The panel).
Two things matter, and neither is obvious from the model's name.
It must support tool calling. The assistant never guesses: it asks the
application for the numbers through a set of query tools. A model that cannot
call them will answer anyway, from nothing, and the invented stresses look
exactly like real ones. The panel marks such models — no tool support.
Bigger is not a luxury here. This is the part worth reading twice. A smaller model answers faster and fits in less memory, so it looks like the sensible choice on a modest machine. It is not. In testing, a 3B model asked to locate the most stressed element named the right element, skipped the tool that knows where it is, and reported fabricated coordinates — adding that they were "derived from the element locations within the analysed mesh", which they were not. It did this in two runs out of five. The same model described required reinforcement as "the limit you must not exceed", inverting the meaning while quoting the correct figure.
A small model here does not give worse answers. It gives wrong answers that look exactly like right ones.
Tested models¶
The Assistant writes short commands (the command language, one request at a time) that the application
checks and applies. Three benchmarks measure it (in tools/bench/), all at temperature 0, with the thinking of the model off
and the router off, in October 2026. A request is right when the model it leaves passes a check made for that request, or when
the answer to a question has the value asked:
- Create (
bench_create.py): 86 requests that build or change a model (nodes and bars, supports, loads, sections and materials, load cases and combinations, editing and deleting, hinges, links and springs, slabs and walls, and the dynamic cases: mass, modal, response spectrum, P-Delta, non-linear). - Query (
bench_query.py): 90 questions about a model that was analysed (counts, reactions, displacements, forces, geometry, design, combinations). - Chain (
bench_scenarios.py, scenario S1): 36 sentences, in three chains of 12 steps (a wall with edge supports and loads, then mass, modal, spectrum and combinations), in which each step is worded at random in one of three ways and works on the model that the previous steps left.
| Model | Create | Query | Chain | Time per request | Notes |
|---|---|---|---|---|---|
gemma4:e4b |
73/86 | 84/90 | 24/36 | about 1 s | The default. The fastest of the local models, and the one that falls behind most on the chain. |
bonsai-2:27b |
74/86 | 87/90 | 34/36 | about 5 to 7 s | The most capable of the local models, and the slowest. |
gemma4:cloud |
84/86 | 85/90 | 36/36 | under 1 s | Ollama's cloud model: the best result on the chain, but your model leaves this computer. |
beam:cloud |
84/86 | 89/90 | 32/36 | about 1 s | A larger cloud model, with the best result on questions. |
Where the small models fail is the same everywhere: a request that leaves something to guess (the top-left corner, the centre),
a request of several steps, and an id that does not exist yet. In the chain, gemma4:e4b misses the same steps in every run: the wall
read from 4,0x20,0 m2 em (6,0), the loads and supports on an edge, and the nodal load.
The wording matters: when the same requests were asked again with a trivial change (a full stop, please, Portuguese
instead of English), gemma4:e4b lost between 6 and 14 points.
Earlier tests with other, smaller models (3 to 4 B, such as qwen3.5:4b, ministral-3:3b and granite4.2:3b) with another set
of requests gave much worse results, and they were not measured again.
Times are from one machine (an Apple-silicon Mac). Without a usable GPU the same model can be several times slower, and the cloud time depends on your connection. Results move by one or two requests between runs.
These names will age. You can use any other models that support tool calling.
A tool call that comes back as text¶
Occasionally a model — even one that generally supports tool calling — writes
what looks like a tool call as plain text instead of actually making one:
something like {"tool_calls": [...]} appears as the answer itself. The
panel cannot act on that; it is not a real call, and the reply is marked
"answered without consulting the model — treat any numbers as unverified".
This is not the application failing to recognise a valid call — it is the underlying runtime (Ollama) failing to recognise the model's output as one, because the model drifted slightly off the exact format its own chat template expects. It tends to happen more with smaller models, and not always on the same question twice.
The Temperature control is the knob for this. Lower keeps the model closer to the format it was trained to reproduce exactly: steadier tool use, less varied wording. The default is already 0. It does not make the drift impossible, only less likely; a model with no tool support at all will not gain any by turning this down.
What it can and cannot do¶
It reads, and it can build and change the model. It builds a structure from a description and makes changes to the open model — add, edit, delete, assign — checked on a copy first (see Creating and changing a model). What the model itself cannot do is run the analysis or write a file: that is for the Action mode, which presses the button of the window (> run the analysis, > write the report) and is carried out by the application, not by the model. For several steps in a row, with the results read in between, use the Agent.
It is given a short summary of the model up front and asks for detail through the tools, so it sees the geometry, loads, cases, results, nodal-averaged stresses, design results, constraints and this manual. Results are keyed to the analysed mesh — the elements that geometry objects expand into — and the assistant uses those ids, which is why they may not match what you drew.
Doing what the window does¶
This is the Action mode (>). Some requests are not about the model but about the window: "show the deformed shape", "hide the node labels", "put the
grid at 50 cm", "use the plasma colormap", "save as beam1". The assistant recognises them (in Portuguese, English or
French) and runs the menu command or the Display panel control itself, then says what it did. This covers the File,
Edit, View, Selection, Analysis and Design menus and the Display panel: its layers, the grid (spacing, snap, reference
lines) and the Style tab (colormap, smoothing, fill, levels, contour lines, scale, diagram and utilisation styles). A number
or a name in the sentence is read ("grelha de 50 cm", "15 níveis", "paleta plasma"). A command that deletes or replaces
something asks first, and one that is greyed out says why: a Style control waits for a view that has a colour map, a
diagram or a design to style, and says which view to open.
An agent (the Agent tab of the same panel) can do the display part too, and much more: see The Agent tab.
Creating and changing a model¶
Ask in plain language — "a 6 m simply supported beam", "a cantilever wall", "add a 20 kN load at midspan", "give bar B1 the section S2". Ask for one thing at a time: small models do each request well and a long list badly. The assistant answers in one of two ways, and the note under the reply says which:
- Commands. Four verbs (
add,set,remove,move) are what it tries first; a block is all or nothing — if one line fails, none is applied. They are checked on a copy of the model, and if they are valid they are applied to the open model at once (Ctrl+Z undoes; the results are discarded, so run the analysis again). A block of more than 10 lines, or one that removes three or more elements, waits for the Apply button instead, and the note says why. - Python. When the commands cannot say it, it writes Python for the model that is
open (plain
model.…calls, using thexdfem2dAPI). It is run on a copy first, and if it runs and checks out it is applied at once, exactly like the commands. The line count does not matter for Python (a script is long by nature); only what it removes does. It waits for Apply when the model is locked, when it places a template over a model that already has geometry (Apply then asks whether to insert the template or replace the model), when it does not run on the model that is open now, or when it removes three or more elements.
In both cases Apply applies what waits, after checking it again against the model
open at that moment, and Open shows the Python in the Script editor
(Ctrl+Shift+E), where you can read or fix it; Open also works after the Python was
applied. Nothing runs from the editor until you press Run yourself.
Preferences ▸ AI Assistant ▸ Apply the assistant's commands at once switches the
automatic application off, so that everything waits for Apply.
This is genuinely useful for a quick starting point and for routine edits, but treat it as early and limited:
- the more elaborate the request, the more likely something is missing or wrong, so review what was applied before you build on it;
- a capable model matters most here. A small local model often produces a structure that looks right and is not; a stronger remote model (with an API key) is markedly better both at answering and at building.
Two habits make it more useful:
- Name the case. "In COMBO1" rather than "in the model": extremes differ between load cases and combinations, and the assistant will otherwise have to pick one and tell you which.
- Check anything that matters. Use Edit → Find Entity to jump to an element it names, and confirm the number in the results table. The assistant is a way to find things quickly, not a substitute for reading the results.
Design values exist only for combinations that were actually designed. Ask about an analysis case and a good model will tell you there is nothing there.