AI Controls NEW

HarbourBuilder is the first xBase IDE with built-in AI components. Drop AI components on your form, set an API key, and interact with the world's most powerful language models.

Local AI with Ollama

The TOllama component connects to a local Ollama instance — no API key needed, fully private, works offline. Perfect for development and enterprise environments.

AI Components Overview

ComponentCT IDProviderType
TOpenAI46OpenAICloud API
TGemini47GoogleCloud API
TClaude48AnthropicCloud API
TDeepSeek49DeepSeekCloud API
TGrok50xAICloud API
TOllama51OllamaLocal Server
TTransformer52LocalOn-Device Model
TWhisper110OpenAI/LocalSpeech-to-Text
TEmbeddings111VariousVector Embeddings

Common Properties (all AI controls)

PropertyTypeDescription
cApiKeyStringAPI authentication key
cModelStringModel name (e.g. "gpt-4o", "claude-sonnet-4-20250514")
nTemperatureNumericCreativity (0.0 = deterministic, 2.0 = creative)
nMaxTokensNumericMaximum response length
cSystemPromptStringSystem instructions for the AI
lStreamLogicalEnable streaming responses (token by token)

Common Events

EventParametersDescription
OnResponsecResponseFull response received
OnStreamcTokenEach token during streaming
OnErrorcError, nCodeAPI error occurred
OnTokenCountnPrompt, nCompletionToken usage report

Common Methods

MethodParametersDescription
:Chat( cMessage )StringSend a chat message, fires OnResponse
:Complete( cPrompt )StringText completion
:Embed( cText )StringGet embedding vector

TOpenAI CT = 46

Connect to OpenAI API (GPT-4o, GPT-4, GPT-3.5).

oAI := TOpenAI():New()
oAI:cApiKey := "sk-..."
oAI:cModel  := "gpt-4o"
oAI:OnResponse := { |cResp| oMemo:Text := cResp }
oAI:Chat( "Explain Harbour classes" )

TGemini CT = 47

Connect to Google Gemini API.

Default model: gemini-2.5-flash

TClaude CT = 48

Connect to Anthropic Claude API.

Default model: claude-sonnet-4-20250514

TDeepSeek CT = 49

Connect to DeepSeek API. Excellent for code generation.

Default model: deepseek-chat

TGrok CT = 50

Connect to xAI Grok API.

Default model: grok-3

TOllama CT = 51

Connect to local Ollama instance. No API key required.

PropertyTypeDefaultDescription
cHostString"localhost"Ollama server host
nPortNumeric11434Ollama server port
cModelString"llama3"Local model name
oAI := TOllama():New()
oAI:cModel := "codellama"
oAI:OnStream := { |cToken| oOutput:Text += cToken }
oAI:Chat( "Write a Harbour function to sort an array" )

TTransformer CT = 52

Full transformer architecture component. Train, fine-tune, and run inference locally.

PropertyTypeDefaultDescription
nLayersNumeric6Number of encoder/decoder layers
nHeadsNumeric8Number of attention heads
nEmbedDimNumeric512Embedding dimension (d_model)
nFFDimNumeric2048Feed-forward dimension
nVocabSizeNumeric50257Vocabulary size
nMaxSeqLenNumeric512Maximum sequence length
nDropoutNumeric0.1Dropout rate
cWeightsFileString""Pre-trained weights path
lCausalLogical.T.Use causal mask (decoder mode)
EventDescription
OnAttentionAccess attention weights for visualization
OnGenerateToken generated during inference
OnTrainStepTraining step completed (with loss)
OnLossLoss value computed
graph LR A[Input Text] --> B[Tokenizer] B --> C[Embedding + PE] C --> D["N x (MHA + FFN)"] D --> E[Linear + Softmax] E --> F[Output Tokens] style D fill:#58a6ff,stroke:#388bfd,color:#0d1117
Didactic Examples

See the samples/projects/transformer/ folder for 7 complete examples: attention visualizer, text generator, training from scratch, tokenizer explorer, sentiment analyzer, translator, and a full "Attention Is All You Need" walkthrough.

TWhisper CT = 110

Speech-to-text transcription using OpenAI's Whisper model or local Whisper implementations. Convert audio files and real-time microphone input to text.

PropertyTypeDefaultDescription
cAudioFileString""Path to audio file for transcription
cLanguageString"en"Language code (e.g., "en", "es", "fr")
cModelString"whisper-1"Model size (tiny, base, small, medium, large)
lTranslateLogical.F.Translate to English
nTaskNumeric00=transcribe, 1=translate
EventDescription
OnTranscriptionFull transcription received
OnSegmentEach transcript segment (with timestamps)
OnErrorTranscription error occurred
oWhisper := TWhisper():New()
oWhisper:cAudioFile := "recording.wav"
oWhisper:cLanguage := "en"
oWhisper:OnTranscription := { |cText| oMemo:Text := cText }
oWhisper:Transcribe()

TEmbeddings CT = 111

Generate vector embeddings for text similarity search, semantic search, clustering, and retrieval. Supports multiple providers including OpenAI, Ollama, and local models.

PropertyTypeDefaultDescription
cModelString"text-embedding-ada-002"Embedding model name
nDimensionsNumeric1536Vector dimension count
cMetricString"cosine"Similarity metric (cosine, euclidean, dotproduct)
aVectorsArray{}Cached embedding vectors
MethodParametersDescription
:Embed( cText )StringGenerate embedding for text, returns array
:Similarity( aVec1, aVec2 )ArraysCalculate similarity between vectors
:Index( cText, cId )StringsAdd text to vector index with ID
:Search( cQuery, nTop )String, NumberSearch indexed vectors, return top N
EventDescription
OnEmbedEmbedding generated (with vector array)
OnSearchSearch results received (with similarities)
OnErrorEmbedding error occurred
oEmb := TEmbeddings():New()
oEmb:cModel := "text-embedding-ada-002"

// Index some documents
oEmb:Index( "HarbourBuilder is a visual IDE", "doc1" )
oEmb:Index( "xBase language for database apps", "doc2" )

// Search
oEmb:OnSearch := { |aResults| ShowResults( aResults ) }
oEmb:Search( "visual development environment", 5 )
Semantic Search Use Case

Use TEmbeddings to build a semantic search engine: index your documents, then search by meaning rather than keywords. Perfect for knowledge bases and FAQs.

On This Page

AI Controls Overview Common Properties Common Events Common Methods TOpenAI TGemini TClaude TDeepSeek TGrok TOllama TTransformer TWhisper TEmbeddings