You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What about the idea to add a library for the following statements and functions:
I know that yet there is no community to discuss the idea, but still is nice practice to place for discussion :-)
LLM BASIC Programming Reference
This hypothetical programming reference defines the statements and functions for interacting with multiple Large Language Models (LLMs) and providers using a classic BASIC programming style.
1. Core Communication & State
These statements manage the flow of interaction, sending prompts, and receiving replies.
Statement
Purpose
Example
Classic BASIC Analogy
LLMGET
Sends the prompt (first variable) to the active LLM and stores the AI's reply in the second variable.
LLMGET PROMPT, REPLY
INPUT / READ
LLMPROMPT
Declares the variable that will hold the main prompt string.
LLMPROMPT QUERY_TEXT
Variable declaration
LLMSET
Sets an AI configuration parameter, such as the model's 'TEMPERATURE' (creativity) or the 'SYSTEM' (persona) instruction.
LLMSET "TEMPERATURE", 0.7
Setting an environment variable
LLMRESET
Clears the session's conversation history or resets all AI parameters to defaults.
LLMRESET
CLEAR
LLMWAIT
Pauses the program's execution until the LLM has finished generating a reply.
LLMWAIT
Implicit wait on INPUT
2. Provider & Model Selection
These statements and functions allow for dynamic management and switching between different AI services and models.
Statement / Function
Purpose
Example
LLMADD
Registers a new AI provider (e.g., API key) for use in the program. Run this at startup.
LLMADD "PROVIDER_A", API_KEY_A
LLMUSE
Selects the active provider and model for subsequent LLMGET calls.
LLMUSE "PROVIDER_B", "MODEL_HIGH_RES"
LLMGETPROVIDER ( )
Returns the name of the currently active AI provider.
CURRENT_P = LLMGETPROVIDER()
LLMGETMODEL ( )
Returns the name of the currently active AI model.
CURRENT_M = LLMGETMODEL()
LLMCHECKMODEL ( )
Returns 1 if the specified model is available from the active provider, 0 otherwise.
IF LLMCHECKMODEL("MODEL_32K") THEN GOTO BIGTASK
3. Text & Data Analysis Functions
These functions inspect the prompt or reply, using LLM-specific analysis and classic BASIC string manipulation style.
Function
Purpose
Example
Classic BASIC Analogy
LLMLEN ( )
Returns the estimated number of tokens (LLM units of length) in the specified string.
PRINT LLMLEN(REPLY)
LEN
LLMLEFT ( , )
Returns the leftmost tokens/characters of the string up to the specified length.
TITLE = LLMLEFT(REPLY, TWENTY)
LEFT
LLMSUB ( , , )
Extracts a substring from the LLM's reply, starting at a given position for a specific length.
EXTRACT = LLMSUB(REPLY, TEN, FIFTEEN)
MID
LLMFIND ( , )
Returns the starting position of a specific word or phrase inside the string.
POS = LLMFIND(REPLY, "KEYWORD")
INSTR
LLMEXTRACT ( , )
Attempts to parse and return a specific structured data type (e.g., NUMBER, LIST) from the reply.
USERAGE = LLMEXTRACT(REPLY, "NUMBER")
LLMCHECK ( )
Returns 1 for a clean response, 0 if the content is flagged by safety filters.
IF LLMCHECK(REPLY) THEN GOTO PROCESS
LLMCOST ( )
Returns the estimated processing cost (in tokens or arbitrary units) for the text.
PRINT "TOTAL COST: "; LLMCOST(PROMPT)
Example Program: Task Switching
REM --- INITIALIZE PROVIDERS ---
LLMADD "PROVIDER_A", API_KEY_A
LLMADD "PROVIDER_B", API_KEY_B
REM --- TASK 1: FAST, CHEAP QUERY ---
LLMUSE "PROVIDER_A", "MODEL_FAST"
LLMSET "TEMPERATURE", 0.1
PROMPT_1 ="WHAT IS THE CAPITAL OF PERU?"
LLMGET PROMPT_1, FACT_REPLY
PRINT"FAST AI SAYS: "; FACT_REPLY
REM --- TASK 2: HIGH-QUALITY CREATIVE TASK ---
LLMUSE "PROVIDER_B"IF LLMCHECKMODEL("MODEL_CREATIVE") THENGOTO USE_CREATIVE
LLMUSE "MODEL_DEFAULT"GOTO CONTINUE
USE_CREATIVE:
LLMUSE "MODEL_CREATIVE"
LLMSET "TEMPERATURE", 0.9
CONTINUE:
PROMPT_2 ="WRITE A TEN-WORD MOTTO FOR A SPACE EXPLORER"
LLMGET PROMPT_2, MOTTO_REPLY
REM CHECK THE REPLY LENGTH AND CONTENT
TOKEN_L = LLMLEN(MOTTO_REPLY)
IF LLMCHECK(MOTTO_REPLY) =0THENGOTO BAD_CONTENT
ENDIF
PRINT"CREATIVE AI MOTTO ("+ LLMGETMODEL() +"):"PRINT MOTTO_REPLY
PRINT"TOTAL TOKENS: "; TOKEN_L
GOTO END_PROG
BAD_CONTENT:
PRINT"WARNING: LLM REPLY VIOLATED CONTENT POLICY."
LLMRESET
END_PROG:
END
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Idea for discusion.
What about the idea to add a library for the following statements and functions:
I know that yet there is no community to discuss the idea, but still is nice practice to place for discussion :-)
LLM BASIC Programming Reference
This hypothetical programming reference defines the statements and functions for interacting with multiple Large Language Models (LLMs) and providers using a classic BASIC programming style.
1. Core Communication & State
These statements manage the flow of interaction, sending prompts, and receiving replies.
2. Provider & Model Selection
These statements and functions allow for dynamic management and switching between different AI services and models.
3. Text & Data Analysis Functions
These functions inspect the prompt or reply, using LLM-specific analysis and classic BASIC string manipulation style.
Example Program: Task Switching
..
Beta Was this translation helpful? Give feedback.
All reactions