<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use `predict_stream` in Databricks deployed ChatAgent. in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/how-to-use-predict-stream-in-databricks-deployed-chatagent/m-p/115584#M842</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We are working on a solution to have a streaming chat agent. Our agent works fine in the Playground but when we try to call it as an api under /invocations, the streaming does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Apr 2025 21:10:55 GMT</pubDate>
    <dc:creator>jcastro</dc:creator>
    <dc:date>2025-04-15T21:10:55Z</dc:date>
    <item>
      <title>How to use `predict_stream` in Databricks deployed ChatAgent.</title>
      <link>https://community.databricks.com/t5/generative-ai/how-to-use-predict-stream-in-databricks-deployed-chatagent/m-p/115584#M842</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We are working on a solution to have a streaming chat agent. Our agent works fine in the Playground but when we try to call it as an api under /invocations, the streaming does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2025 21:10:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/how-to-use-predict-stream-in-databricks-deployed-chatagent/m-p/115584#M842</guid>
      <dc:creator>jcastro</dc:creator>
      <dc:date>2025-04-15T21:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use `predict_stream` in Databricks deployed ChatAgent.</title>
      <link>https://community.databricks.com/t5/generative-ai/how-to-use-predict-stream-in-databricks-deployed-chatagent/m-p/121989#M962</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/159425"&gt;@jcastro&lt;/a&gt;&amp;nbsp;I wish you a wonderful day ahead!&lt;/P&gt;
&lt;P&gt;Databricks recommends the MLflow &lt;STRONG&gt;ChatAgent&lt;/STRONG&gt; interface to author production-grade agents.&lt;/P&gt;
&lt;P&gt;These &lt;STRONG&gt;ChatAgent&lt;/STRONG&gt; provides advanced agent capabilities like &lt;STRONG&gt;Streaming output&lt;/STRONG&gt; to enable interactive user experiences by streaming output in smaller chunks.&lt;/P&gt;
&lt;P&gt;If you already have an agent built with LangChain, LangGraph, or a similar framework, you don’t need to rewrite your agent to use it on Databricks. Instead, just wrap your existing agent with the &lt;STRONG&gt;MLflow ChatAgent interface&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;If your agent supports streaming, you can use &lt;STRONG&gt;predict_stream&lt;/STRONG&gt;, the following is a simplified template for converting your agent:&lt;/P&gt;
&lt;P&gt;from mlflow.pyfunc import ChatAgent&lt;BR /&gt;from mlflow.types.agent import ChatAgentMessage, ChatAgentResponse, ChatAgentChunk&lt;BR /&gt;import uuid&lt;/P&gt;
&lt;P&gt;class MyWrappedAgent(ChatAgent):&lt;BR /&gt;&amp;nbsp; def __init__(self, agent):&lt;BR /&gt;&amp;nbsp; self.agent = agent&lt;/P&gt;
&lt;P&gt;def &lt;STRONG&gt;predict_stream&lt;/STRONG&gt;(self, messages, context=None, custom_inputs=None):&lt;BR /&gt;# If your agent supports streaming&lt;BR /&gt;&amp;nbsp; &lt;STRONG&gt;for chunk in self.agent.stream(...):&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;yield ChatAgentChunk(delta=ChatAgentMessage(role="assistant", content=chunk, id=str(uuid.uuid4())))&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;For more details about this, I am sharing below documentation for your reference:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#-use-chatagent-to-author-agents" target="_blank"&gt;https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#-use-chatagent-to-author-agents&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#what-if-i-already-have-an-agent" target="_blank"&gt;https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#what-if-i-already-have-an-agent&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In the below URL the following notebooks show how to author streaming and non-streaming ChatAgents using the popular libraries&lt;STRONG&gt; OpenAI, LangGraph, and AutoGen&lt;/STRONG&gt;:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#chatagent-examples" target="_blank"&gt;https://docs.databricks.com/gcp/en/generative-ai/agent-framework/author-agent#chatagent-examples&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2025 13:22:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/how-to-use-predict-stream-in-databricks-deployed-chatagent/m-p/121989#M962</guid>
      <dc:creator>Vinay_M_R</dc:creator>
      <dc:date>2025-06-17T13:22:05Z</dc:date>
    </item>
  </channel>
</rss>

