LLM - LLMBuilder
LLM.LLMBuilderConstruct a multi-modal LLM agent from a purpose, prompt, functions and streams.
Example
const price = new SourceBuilder("price")
.value({ value: 5 });
const message = new SourceBuilder("message",)
.writeable(AssistantInputStateType);
const sales = new SourceBuilder("sales")
.writeable(DictType(
StringType,
StructType({
date: DateTimeType,
item: StringType,
qty: IntegerType,
inventory: IntegerType,
price: FloatType,
amount: FloatType,
}))
)
const model = new SourceBuilder("model",)
.value({ value: variant('gpt-3.5-turbo-1106', null), type: LLMModelType });
const assistant = new LLMBuilder("assistant")
.input({ name: "sales", stream: sales.outputStream() })
.input({ name: "message", stream: message.outputStream() })
.input({ name: "model", stream: model.outputStream() })
.input({ name: "price", stream: price.outputStream() })
.assistant({
api_key: "...",
purpose: "You are a business analyst assistant",
prompt: (inputs) => inputs.message,
model: (inputs) => inputs.model,
})
.write(
"change_price",
"Change the value of the price.",
price.outputStream(),
)
Type parameters
Name | Type |
---|---|
Inputs | extends Record = |
LLM
assistant
▸ assistant(args
):
LLMAssistantBuilder
<Inputs
, , , VariantType
<{ message
: LLMMessage
} & >>
Construct an Agent that produces any EastType
Stream, based on a purpose, requests and other streams.Parameters
Name | Type | Description |
---|---|---|
args | Object | - |
args.api_key | string | (inputs : Inputs ) => EastFunction | the OpenAI api key |
args.model? | OpenAiModel | (inputs : Inputs ) => EastFunction | the open ai model to use |
args.prompt? | string | (inputs : Inputs ) => EastFunction <Nullable > | the assistant state, a message or thread |
args.purpose? | string | (inputs : Inputs ) => EastFunction | the purpose of the assistant |
Returns
LLMAssistantBuilder
<Inputs
, , , VariantType
<{ message
: LLMMessage
} & >>
a new
LLMAssistantBuilderExample
const price = new SourceBuilder("price")
.value({ value: 5 });
const message = new SourceBuilder("message",)
.writeable(AssistantInputStateType);
const sales = new SourceBuilder("sales")
.writeable(DictType(
StringType,
StructType({
date: DateTimeType,
item: StringType,
qty: IntegerType,
inventory: IntegerType,
price: FloatType,
amount: FloatType,
}))
)
const model = new SourceBuilder("model",)
.value({ value: variant('gpt-3.5-turbo-1106', null), type: LLMModelType });
const assistant = new LLMBuilder("assistant")
.input({ name: "sales", stream: sales.outputStream() })
.input({ name: "message", stream: message.outputStream() })
.input({ name: "model", stream: model.outputStream() })
.input({ name: "price", stream: price.outputStream() })
.assistant({
api_key: "...",
purpose: "You are a business analyst assistant",
prompt: (inputs) => inputs.message,
model: (inputs) => inputs.model,
})
.write(
"change_price",
"Change the value of the price.",
price.outputStream(),
)
input
▸ input(config
):
LLMBuilder
<Inputs
& { [K in string]: Variable }>
Add an additional named input
Stream to the LLMBuilder.Type parameters
Name | Type |
---|---|
Name | extends string |
I | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
config | Object | the input stream and the resulting variable name |
config.name | Name extends "input" | keyof Inputs ? never : Name | The name of the input. * |
config.stream | Stream | The Stream to input. * |
Returns
LLMBuilder
<Inputs
& { [K in string]: Variable }>
a new
LLMBuilderExample
// use a stream that is a collection of pdf documents per customer
const price = new SourceBuilder("price")
.value({ value: 5 });
const message = new SourceBuilder("message",)
.writeable(AssistantInputStateType);
const model = new SourceBuilder("model",)
.value({ value: variant('gpt-3.5-turbo-1106', null), type: LLMModelType });
const assistant = new LLMBuilder("assistant")
.input({ name: "message", stream: message.outputStream() })
.input({ name: "model", stream: model.outputStream() })
.input({ name: "price", stream: price.outputStream() })
.assistant({
api_key: "...",
purpose: "You are a business analyst assistant",
prompt: (inputs) => inputs.message,
model: (inputs) => inputs.model,
})
.input({ name: "price", stream: price.outputStream() })
.write(
"change_price",
"Change the value of the price.",
price.outputStream(),
)
Other
constructor
• new LLMBuilder(name
, module?
, inputs?
, input_streams?
):
LLMBuilder
Construct a multi-modal LLM agent from a purpose, prompt, functions and streams.
Type parameters
Name | Type |
---|---|
Inputs | extends Record = |
Parameters
Name | Type |
---|---|
name | string |
module? | ModulePath | ModuleBuilder |
inputs | Inputs |
input_streams | Record |
Returns
LLMBuilder
Example
const price = new SourceBuilder("price")
.value({ value: 5 });
const message = new SourceBuilder("message",)
.writeable(AssistantInputStateType);
const sales = new SourceBuilder("sales")
.writeable(DictType(
StringType,
StructType({
date: DateTimeType,
item: StringType,
qty: IntegerType,
inventory: IntegerType,
price: FloatType,
amount: FloatType,
}))
)
const model = new SourceBuilder("model",)
.value({ value: variant('gpt-3.5-turbo-1106', null), type: LLMModelType });
const assistant = new LLMBuilder("assistant")
.input({ name: "sales", stream: sales.outputStream() })
.input({ name: "message", stream: message.outputStream() })
.input({ name: "model", stream: model.outputStream() })
.input({ name: "price", stream: price.outputStream() })
.assistant({
api_key: "...",
purpose: "You are a business analyst assistant",
prompt: (inputs) => inputs.message,
model: (inputs) => inputs.model,
})
.write(
"change_price",
"Change the value of the price.",
price.outputStream(),
)