feat(agent): Add signal support for cancellation in agent workflows
This commit is contained in:
parent
765d084b44
commit
74c3934aa5
2 changed files with 4 additions and 1 deletions
|
|
@ -99,6 +99,7 @@ export class AgentSearch {
|
||||||
const result = await workflow.invoke(initialState, {
|
const result = await workflow.invoke(initialState, {
|
||||||
configurable: { thread_id: `agent_search_${Date.now()}` },
|
configurable: { thread_id: `agent_search_${Date.now()}` },
|
||||||
recursionLimit: 20,
|
recursionLimit: 20,
|
||||||
|
signal: this.signal,
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||||
llm: BaseChatModel,
|
llm: BaseChatModel,
|
||||||
systemInstructions: string,
|
systemInstructions: string,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
|
signal: AbortSignal,
|
||||||
) {
|
) {
|
||||||
(llm as unknown as ChatOpenAI).temperature = 0;
|
(llm as unknown as ChatOpenAI).temperature = 0;
|
||||||
|
|
||||||
|
|
@ -238,7 +239,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
Make sure to answer the query in the summary.
|
Make sure to answer the query in the summary.
|
||||||
`); //TODO: Pass signal for cancellation
|
`, { signal });
|
||||||
|
|
||||||
const document = new Document({
|
const document = new Document({
|
||||||
pageContent: res.content as string,
|
pageContent: res.content as string,
|
||||||
|
|
@ -340,6 +341,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||||
llm,
|
llm,
|
||||||
systemInstructions,
|
systemInstructions,
|
||||||
emitter,
|
emitter,
|
||||||
|
signal,
|
||||||
);
|
);
|
||||||
var date = formatDateForLLM();
|
var date = formatDateForLLM();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue