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.
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
| Component | CT ID | Provider | Type |
|---|---|---|---|
TOpenAI | 46 | OpenAI | Cloud API |
TGemini | 47 | Cloud API | |
TClaude | 48 | Anthropic | Cloud API |
TDeepSeek | 49 | DeepSeek | Cloud API |
TGrok | 50 | xAI | Cloud API |
TOllama | 51 | Ollama | Local Server |
TTransformer | 52 | Local | On-Device Model |
TWhisper | 110 | OpenAI/Local | Speech-to-Text |
TEmbeddings | 111 | Various | Vector Embeddings |
Common Properties (all AI controls)
| Property | Type | Description |
|---|---|---|
cApiKey | String | API authentication key |
cModel | String | Model name (e.g. "gpt-4o", "claude-sonnet-4-20250514") |
nTemperature | Numeric | Creativity (0.0 = deterministic, 2.0 = creative) |
nMaxTokens | Numeric | Maximum response length |
cSystemPrompt | String | System instructions for the AI |
lStream | Logical | Enable streaming responses (token by token) |
Common Events
| Event | Parameters | Description |
|---|---|---|
OnResponse | cResponse | Full response received |
OnStream | cToken | Each token during streaming |
OnError | cError, nCode | API error occurred |
OnTokenCount | nPrompt, nCompletion | Token usage report |
Common Methods
| Method | Parameters | Description |
|---|---|---|
:Chat( cMessage ) | String | Send a chat message, fires OnResponse |
:Complete( cPrompt ) | String | Text completion |
:Embed( cText ) | String | Get 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.
| Property | Type | Default | Description |
|---|---|---|---|
cHost | String | "localhost" | Ollama server host |
nPort | Numeric | 11434 | Ollama server port |
cModel | String | "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.
| Property | Type | Default | Description |
|---|---|---|---|
nLayers | Numeric | 6 | Number of encoder/decoder layers |
nHeads | Numeric | 8 | Number of attention heads |
nEmbedDim | Numeric | 512 | Embedding dimension (d_model) |
nFFDim | Numeric | 2048 | Feed-forward dimension |
nVocabSize | Numeric | 50257 | Vocabulary size |
nMaxSeqLen | Numeric | 512 | Maximum sequence length |
nDropout | Numeric | 0.1 | Dropout rate |
cWeightsFile | String | "" | Pre-trained weights path |
lCausal | Logical | .T. | Use causal mask (decoder mode) |
| Event | Description |
|---|---|
OnAttention | Access attention weights for visualization |
OnGenerate | Token generated during inference |
OnTrainStep | Training step completed (with loss) |
OnLoss | Loss value computed |
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.
| Property | Type | Default | Description |
|---|---|---|---|
cAudioFile | String | "" | Path to audio file for transcription |
cLanguage | String | "en" | Language code (e.g., "en", "es", "fr") |
cModel | String | "whisper-1" | Model size (tiny, base, small, medium, large) |
lTranslate | Logical | .F. | Translate to English |
nTask | Numeric | 0 | 0=transcribe, 1=translate |
| Event | Description |
|---|---|
OnTranscription | Full transcription received |
OnSegment | Each transcript segment (with timestamps) |
OnError | Transcription 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.
| Property | Type | Default | Description |
|---|---|---|---|
cModel | String | "text-embedding-ada-002" | Embedding model name |
nDimensions | Numeric | 1536 | Vector dimension count |
cMetric | String | "cosine" | Similarity metric (cosine, euclidean, dotproduct) |
aVectors | Array | {} | Cached embedding vectors |
| Method | Parameters | Description |
|---|---|---|
:Embed( cText ) | String | Generate embedding for text, returns array |
:Similarity( aVec1, aVec2 ) | Arrays | Calculate similarity between vectors |
:Index( cText, cId ) | Strings | Add text to vector index with ID |
:Search( cQuery, nTop ) | String, Number | Search indexed vectors, return top N |
| Event | Description |
|---|---|
OnEmbed | Embedding generated (with vector array) |
OnSearch | Search results received (with similarities) |
OnError | Embedding 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 )
Use TEmbeddings to build a semantic search engine: index your documents, then search by meaning rather than keywords. Perfect for knowledge bases and FAQs.