File tree 3 files changed +5
-23
lines changed 3 files changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { ChatOpenAI } from "@langchain/openai";
2
2
import {
3
3
task ,
4
4
entrypoint ,
5
- interrupt ,
6
5
addMessages ,
7
6
getPreviousState ,
8
7
} from "@langchain/langgraph" ;
@@ -13,7 +12,7 @@ import {
13
12
} from "@langchain/core/messages" ;
14
13
import { initializeTools } from "./tools.js" ;
15
14
import { createCheckpointer } from "./checkpointer.js" ;
16
- import { AGENT_PROMPT , HELP_PHRASE } from "./prompts.js" ;
15
+ import { AGENT_PROMPT } from "./prompts.js" ;
17
16
import { ToolCall } from "@langchain/core/messages/tool" ;
18
17
19
18
// Create workflow
@@ -73,17 +72,6 @@ export const agent = entrypoint(
73
72
74
73
while ( true ) {
75
74
if ( ! llmResponse . tool_calls ?. length ) {
76
- if ( llmResponse . content . toString ( ) . includes ( HELP_PHRASE ) ) {
77
- const humanResponse = interrupt ( {
78
- current_response : llmResponse . content ,
79
- action : "Please provide guidance on how to answer this question." ,
80
- } ) ;
81
- currentMessages = addMessages ( currentMessages , [
82
- llmResponse ,
83
- humanResponse ,
84
- ] ) ;
85
- continue ;
86
- }
87
75
break ;
88
76
}
89
77
Original file line number Diff line number Diff line change 1
1
// Define default prompts
2
2
3
- export const HELP_PHRASE = `I am calling my supervisor for assistance.` ;
4
-
5
3
export const AGENT_PROMPT = `You are an HR Support Assistant. Your role is to help employees with questions about company policies.
6
4
You have access to a database of HR policies through the searchPolicies tool.
7
5
@@ -21,6 +19,4 @@ Think through this step by step:
21
19
1. What specific policy information is needed?
22
20
2. Do I have this information in the current policies?
23
21
3. Should I search for more policies or request human help?
24
- 4. How should I format my response?
25
-
26
- If you get stuck, you can always respond directly with a message containing the following: "${ HELP_PHRASE } "` ;
22
+ 4. How should I format my response?`
Original file line number Diff line number Diff line change 1
- import { LangGraphRunnableConfig } from "@langchain/langgraph" ;
1
+ import { LangGraphRunnableConfig , interrupt } from "@langchain/langgraph" ;
2
2
import { tool } from "@langchain/core/tools" ;
3
3
import { z } from "zod" ;
4
4
import { MongoDBAtlasVectorSearch } from "@langchain/mongodb" ;
5
5
import { OpenAIEmbeddings } from "@langchain/openai" ;
6
6
import { Document } from "@langchain/core/documents" ;
7
7
import { MongoClient } from "mongodb" ;
8
- import { HELP_PHRASE } from "./prompts.js" ;
9
8
10
9
/**
11
10
* Initialize tools within a function so that they have access to the current
@@ -77,9 +76,8 @@ export function initializeTools(config?: LangGraphRunnableConfig) {
77
76
*/
78
77
async function humanAssistance ( opts : { query : string } ) : Promise < string > {
79
78
const { query } = opts ;
80
-
81
- // This will be intercepted by the interrupt handler
82
- return `Be sure to include the following in your response: "${ HELP_PHRASE } ${ query } "` ;
79
+ const humanResponse = await interrupt ( { query} ) ;
80
+ return humanResponse . content . toString ( ) ;
83
81
}
84
82
85
83
const humanAssistanceTool = tool ( humanAssistance , {
You can’t perform that action at this time.
0 commit comments