diff --git a/conversation/javascript/http/README.md b/conversation/javascript/http/README.md index 3fbd2f6a..1802db5f 100644 --- a/conversation/javascript/http/README.md +++ b/conversation/javascript/http/README.md @@ -38,7 +38,7 @@ expected_stdout_lines: - '== APP - conversation == Output response: What is dapr?' - '== APP - conversation == Tool calling input sent: What is the weather like in San Francisco in celsius?' - '== APP - conversation == Output message: What is the weather like in San Francisco in celsius?' - - '== APP - conversation == No tool calls in response' + - '== APP - conversation == Tool calls detected: [{"id":"0","function":{"name":"get_weather","arguments":"location,unit"}}]' expected_stderr_lines: output_match_mode: substring match_order: none @@ -63,12 +63,12 @@ The terminal console output should look similar to this, where: - The app then sends an input `What is the weather like in San Francisco in celsius?` to the `echo` Component mock LLM. - The mock LLM echoes `What is the weather like in San Francisco in celsius?` and calls the `get_weather` tool. -- Since we are using the `echo` Component mock LLM, the tool call is not executed and the LLM returns `No tool calls in response`. +- The echo Component returns the tool call information.s ```text == APP == Tool calling input sent: What is the weather like in San Francisco in celsius? == APP == Output message: What is the weather like in San Francisco in celsius? -== APP == No tool calls in response +== APP == Tool calls detected: [{"id":"0","function":{"name":"get_weather","arguments":"location,unit"}}] ``` @@ -106,12 +106,12 @@ The terminal console output should look similar to this, where: - The app first sends an input `What is dapr?` to the `echo` Component mock LLM. - The mock LLM echoes `What is dapr?`. - The app then sends an input `What is the weather like in San Francisco in celsius?` to the `echo` Component mock LLM. -- The mock LLM echoes `What is the weather like in San Francisco in celsius?` +- The echo Component returns the tool call information. ```text == APP - conversation == Conversation input sent: What is dapr? == APP - conversation == Output response: What is dapr? == APP - conversation == Tool calling input sent: What is the weather like in San Francisco in celsius? == APP - conversation == Output message: What is the weather like in San Francisco in celsius? -== APP - conversation == No tool calls in response +== APP == Tool calls detected: [{"id":"0","function":{"name":"get_weather","arguments":"location,unit"}}] ``` diff --git a/conversation/javascript/http/conversation/index.js b/conversation/javascript/http/conversation/index.js index f4a90a66..fe41d840 100644 --- a/conversation/javascript/http/conversation/index.js +++ b/conversation/javascript/http/conversation/index.js @@ -114,10 +114,10 @@ async function main() { const result = data?.outputs?.[0]?.choices?.[0]?.message?.content; console.log("Output message:", result); - if (data?.outputs?.[1]?.choices?.[0]?.message?.toolCalls) { + if (data?.outputs?.[0]?.choices?.[0]?.message?.toolCalls) { console.log( - "Output message:", - JSON.stringify(data.outputs[1].choices[0].message?.toolCalls, null, 2) + "Tool calls detected:", + JSON.stringify(data.outputs[0].choices[0].message?.toolCalls) ); } else { console.log("No tool calls in response");