@graphty/graphty-element / ai / MockLlmProvider
Class: MockLlmProvider ​
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:15
Mock LLM provider for deterministic testing. Allows configuring specific responses for specific inputs.
Implements ​
Constructors ​
Constructor ​
new MockLlmProvider():
MockLlmProvider
Returns ​
MockLlmProvider
Properties ​
name ​
readonlyname:"mock"="mock"
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:16
Name of the provider
Implementation of ​
supportsStreaming ​
readonlysupportsStreaming:true=true
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:17
Whether this provider supports streaming responses
Implementation of ​
supportsTools ​
readonlysupportsTools:true=true
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:18
Whether this provider supports tool/function calling
Implementation of ​
Methods ​
clearCallHistory() ​
clearCallHistory():
void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:88
Clear the call history.
Returns ​
void
clearError() ​
clearError():
void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:65
Clear any configured error.
Returns ​
void
configure() ​
configure(
_options):void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:33
Configure the provider (no-op for mock, but implements interface).
Parameters ​
_options ​
Provider configuration options (unused)
Returns ​
void
Implementation of ​
generate() ​
generate(
messages,tools,options?):Promise<LlmResponse>
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:124
Generate a response (non-streaming).
Parameters ​
messages ​
Message[]
Conversation messages
tools ​
Available tools for the LLM
options? ​
Generation options
signal? ​
AbortSignal
Optional abort signal
Returns ​
Promise<LlmResponse>
Promise resolving to LLM response
Implementation of ​
generateStream() ​
generateStream(
messages,tools,callbacks,signal?):Promise<void>
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:168
Generate a streaming response. Simulates streaming by emitting text character by character.
Parameters ​
messages ​
Message[]
Conversation messages
tools ​
Available tools for the LLM
callbacks ​
Streaming callbacks for text and tool calls
signal? ​
AbortSignal
Optional abort signal
Returns ​
Promise<void>
Implementation of ​
getCallHistory() ​
getCallHistory():
CallRecord[]
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:81
Get the history of all calls made to this provider.
Returns ​
CallRecord[]
Array of call records
setDefaultResponse() ​
setDefaultResponse(
response):void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:50
Set the default response to return when no pattern matches.
Parameters ​
response ​
Default response
Returns ​
void
setDelay() ​
setDelay(
ms):void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:73
Set a delay (in ms) before returning responses.
Parameters ​
ms ​
number
Delay in milliseconds
Returns ​
void
setError() ​
setError(
error):void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:58
Set an error to throw on next generate/generateStream call.
Parameters ​
error ​
Error
Error to throw
Returns ​
void
setResponse() ​
setResponse(
pattern,response):void
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:42
Set a response to return when the user message contains the given pattern.
Parameters ​
pattern ​
string
String to match in user messages
response ​
Response to return
Returns ​
void
validateApiKey() ​
validateApiKey():
Promise<boolean>
Defined in: graphty-element/src/ai/providers/MockLlmProvider.ts:228
Validate the API key. For the mock provider, this always returns true unless an error is configured.
Returns ​
Promise<boolean>
Promise resolving to true if valid, false if invalid