<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dapr Conversation JavaScript SDK on Dapr Docs</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/</link><description>Recent content in Dapr Conversation JavaScript SDK on Dapr Docs</description><generator>Hugo</generator><language>en</language><atom:link href="https://docs.dapr.io/developing-applications/sdks/js/js-conversation/index.xml" rel="self" type="application/rss+xml"/><item><title>How to: Converse with an LLM using the Dapr JavaScript SDK</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-howto/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-howto/</guid><description>&lt;p>Use &lt;code>client.conversation.converse(request)&lt;/code> to send role-based messages to a configured conversation component. You do not need a &lt;code>DaprServer&lt;/code> or a provider-specific JavaScript SDK.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://docs.dapr.io/getting-started/install-dapr-cli/">Dapr CLI&lt;/a>&lt;/li>
&lt;li>An initialized &lt;a href="https://docs.dapr.io/getting-started/install-dapr-selfhost/">Dapr environment&lt;/a> with &lt;strong>Dapr runtime 1.16 or later&lt;/strong>&lt;/li>
&lt;li>&lt;a href="https://nodejs.org/">Node.js&lt;/a> 18 or later&lt;/li>
&lt;li>The &lt;a href="https://www.npmjs.com/package/@dapr/dapr">&lt;code>@dapr/dapr&lt;/code>&lt;/a> package, &lt;strong>version 3.19.0 or later&lt;/strong>&lt;/li>
&lt;/ul>
&lt;h2 id="installation">Installation&lt;/h2>
&lt;p>In your application directory, initialize an npm project if you do not already have one, then install the SDK:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sh" data-lang="sh">&lt;span class="line">&lt;span class="cl">npm init -y
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm install @dapr/dapr@3.19.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The examples use JavaScript ES modules and run as &lt;code>.mjs&lt;/code> files without a TypeScript compiler. The same APIs are available in TypeScript, with request and response types exported from &lt;code>@dapr/dapr&lt;/code>.&lt;/p></description></item><item><title>Dapr Conversation JavaScript client usage</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-client-usage/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-client-usage/</guid><description>&lt;p>&lt;code>DaprClient.conversation&lt;/code> exposes one asynchronous method:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="nx">converse&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">request&lt;/span>: &lt;span class="kt">ConversationRequestAlpha2&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">Promise&lt;/span>&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">ConversationResponseAlpha2&lt;/span>&lt;span class="p">&amp;gt;;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Import these types, and the other &lt;code>Conversation*&lt;/code> types used below, from &lt;code>@dapr/dapr&lt;/code>. This guidance targets &lt;strong>3.19.0 or later&lt;/strong>.&lt;/p>
&lt;h2 id="runtime-and-provider-support">Runtime and provider support&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Capability&lt;/th>
 &lt;th>Minimum Dapr runtime&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Alpha2 messages, tool calling, temperature, and PII scrubbing&lt;/td>
 &lt;td>1.16&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>responseFormat&lt;/code>, &lt;code>promptCacheRetention&lt;/code>, and token usage statistics&lt;/td>
 &lt;td>1.17&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Model name in the response&lt;/td>
 &lt;td>1.18&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>maxTokens&lt;/code>&lt;/td>
 &lt;td>1.19&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>Availability also depends on the conversation component and model. An SDK option does not make an unsupported provider feature available. See the &lt;a href="https://docs.dapr.io/reference/api/conversation_api/">Conversation API reference&lt;/a> and your &lt;a href="https://docs.dapr.io/reference/components-reference/supported-conversation/">component reference&lt;/a>.&lt;/p></description></item><item><title>How to: Call tools with the Dapr Conversation JavaScript SDK</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-tools-howto/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-tools-howto/</guid><description>&lt;p>Tool calling lets a model request an application-defined function. Dapr and the JavaScript SDK transport tool definitions and calls; &lt;strong>your application validates arguments, authorizes and executes the function, and sends the result back&lt;/strong>.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;p>Complete the &lt;a href="https://docs.dapr.io/developing-applications/sdks/js/js-conversation/js-conversation-howto/">conversation setup guide&lt;/a> using &lt;code>@dapr/dapr&lt;/code> &lt;strong>3.19.0 or later&lt;/strong>, Dapr runtime &lt;strong>1.16 or later&lt;/strong>, and a component/model that supports tool calling. The echo component is not sufficient.&lt;/p>
&lt;h2 id="define-a-tool-and-handle-its-result">Define a tool and handle its result&lt;/h2>
&lt;p>The following example uses the &lt;code>llm&lt;/code> component configured in the setup guide. Save it as &lt;code>tools.mjs&lt;/code> and run it with the same &lt;code>dapr run&lt;/code> command, replacing &lt;code>app.mjs&lt;/code> with &lt;code>tools.mjs&lt;/code>.&lt;/p></description></item></channel></rss>