Loading video player...
Hello everyone and thank you for joining
our live session today. My name is
Larissa. I'm an event planner at Reactor
joining you from S. Paulo in Brazil.
Before we start, I have some quick
housekeeping. Please take a moment to
read our code conduct. We seek to
provide a respectful environment for
both our audience and presenters. While
we absolutely encourage engagement in
the chat, we ask that you please be
mindful of your commentary, remain
professional and on topic.
The session is being recorded and will
be available to view on demand here on
the Reactor YouTube channel within 48
hours. Keep an eye on the chat. We'll be
dropping helpful links and checking for
questions so our presenters can answer.
I'll now turn it over to our speakers
for today. So, let's welcome here Johan
and Merlin.
Thank you, Lissa.
>> Thank you. Hey, everyone.
>> Hi, everyone. How are you doing? Uh,
welcome to the stream about Lang Chain.
Hey, Gwen. I see Gwen in the chat. Hi,
Alfredo. Nice to see you. Um, but yeah,
today Johan and I are on the stream.
We're going to be talking about Land
Chain V1. It just came out recently. I
think they published both the JavaScript
and Python packages.
And uh at Microsoft, we're really
excited about Langchain. Um yesterday as
well, they announced their their raise.
So Zang Chain is now a unicorn, which
I'm excited about. Johan, what what do
you think about that? About the race?
>> I I think it's awesome. I've always like
followed and used longchain since like
the the first versions. So I'm glad for
them that uh they got through through
this new stage and yeah seeing the new
things uh I think we had a really
exciting times and we'll see this during
this session.
>> Yeah absolutely. I think uh maybe we'll
get started by just introducing
ourselves as well and kind of how we got
into Lchain and what we're doing at
Microsoft with it. So uh yeah so I'll
get started. I'm Marlene. I'm a senior
developer advocate. I'm on the Python on
Azure team and uh I have been the Python
I've been doing a lot of the Langchain
work on the Python team. I've been the
lead for our advocate team for Langchain
and have really enjoyed working on it.
And actually before I joined Microsoft I
actually think really close to when they
actually first created it. I was at a
startup called Voltron Data and
Langchain at the time was the only way
that I really found to quickly be able
to use LLMs with pandas data and so I
think I've almost been using it for at
least two and a half years. So I feel
like I'm a real OG with D chain. Um but
go ahead Johan.
>> Sure. So yeah, as for me I'm Yan. I'm a
principal advocate at Microsoft and I
work on the JavaScript side of Azure and
uh yeah my story is quite similar to to
yours Marlin. uh I was always deep
involved in the open source committees
and uh when we made like the the switch
to go full AI uh at Microsoft I was
always like struggling to switch between
okay I want to use like try local AI
switch to Azure switch like to test with
a different provider and I was
struggling with like the different uh
ways and providers SDK and I think
that's at about at the point uh where I
discovered longchain and uh yeah I was
glad to discover that basically they
abstracted all that complexity away
making me switch like from like local
models using like all yama to cloud
models very easily and that's basically
how I I basically uh started using that
on all the code uh I'm doing all the
application and stuff even like my
personal projects and uh yeah uh I've
been with longchain ever since and uh
yeah trying hard to to push it even
internally here as you may
Exactly. Um, yeah. So, Johan and I have
been working on sort of different lang
chain on the different teams, language
teams. So, Johan's been doing a bunch
with JavaScript and I've been doing a
bunch with Python. So, in this stream
today, we're going to show you both and
how you can kind of make the switch over
to V1 um with both of the languages. So,
uh yeah, let's go. Maybe let's going to
start out excited about B1. We're
excited about the unicorn status and
we're also going to be telling you a
little bit about what lang chain is. So
just to get started maybe um for those
of you who aren't aware of what lang
chain is it is so I will say there is
lang chain the company and the company
has created two sort of open-source
projects. The first project is LAN chain
and the second project is LAN graph
which is a bit of a lower level
abstraction and so if you are wanting to
do very quick building of agents uh lang
chain is probably going to be the best
solution for you but if you're wanting
to do more deterministic uh workflows
that you're going to use in production
that need a lot of customization
langraph is a great option and actually
in v1 lang chain is built on top of lang
graph. So a lot of the things that you
used to be able to do with just pure
lang graph you can now do with lang
chain. Um Johan I'm not sure if there's
anything else you want to highlight
between those two in terms of the
differences.
>> Uh yeah just uh like for anyone
discovering this framework at this time
there's like no bad way to to discover
and jump in the this wagon. So yeah uh
longchain you may have catched this from
later uh from earlier but is an open
source framework for building like uh
anything centered around like large
language models and uh yeah it provides
all sorts of high level abstraction. uh
I said that earlier since the beginning
it provides like way to abstract like
the models uh but nowadays also to do uh
lot of stuff very easily around agents
uh like also give some memory to the LLM
because yeah LLM don't have some
long-term and short-term memories uh
also they provides like tons of helpers
to integrate like your own data and API
so you can just focus on building like
uh on your business use case on what you
want to build and not like oh to like
get this specific SDK because there's
tons of uh integration from the
community and uh I know this because
I've provided some and I think Marlin
you too also uh because the framework is
open source like anyone can try to
integrate with it and that's one of the
great thing with longchain uh there's
basically like a huge community around
that so you will always find someone uh
to help you if you get stuck uh there's
like a community slack that you can join
and get some help. There's tons of
examples online and yeah, we will see uh
also a bit during this session, but
we'll dive into the documentation and
you'll find like great way to get
started from there. And uh yeah, I think
that's about it. Uh do you have anything
else Marina?
My mic is muted. Oh my gosh. Um, so
something maybe let me share as well my
screen because I do think this was
helpful for me. So I'm going to share my
screen and uh and show just the
documentation page or can we switch to
my screen?
Uh yeah, I was on mute. I'm sorry. Uh
okay, we're going to switch to my
screen. Can we see my screen? Hopefully
we can um and and if we can So the thing
that I wanted to point out as well from
what uh Johan was saying was that
there's oftentimes some confusion
between what lang chain is versus
Langraph. So I'm just going to show you
this is a newer documentation from them
that I think looks great and they have a
tab for Langchain and they have a tab
for Langraph. So if you just go to
docs.langchain.com langchain.com.
This is something that's going to be
helpful for you to open up even right
now to follow along with us on the
stream. And I will say that here they
they they talk about how LAN chain is
the easiest way to start building AI
agents. So we're going to see what that
looks like in a second, what that looks
like in the code. And then if you're
just wanting to write in as little code
as possible, if you want to build an
agent in as little code as possible,
Langchain is going to be your go-to
langraph. They say we recommend you use
Langchain if you want to quickly build
agents. um use LAN graph our low-level
agent orchestration framework and
runtime when you have more advanced
needs that require deterministic agentic
workflows customization and and control
of latency. So I would say one thing
that I I like to or two ways that I'd
like to think about this is maybe chain
is great for quick um agents that you
already need sort of pre-built and easy
to make in a few lines of code. That
graph is awesome for maybe multi- aent
scenarios where you need to orchestrate
between two agents. So say you have a
research agent and you have uh I don't
know an agent for calculating things and
you want to orchestrate those agents so
they work together. Lang graph is a
great option for that. And so I would
recommend going to the docs as well to
read a little bit more about that. So
I'm going to switch back. Uh I don't
know Yan if you if we had any other
slides to show before diving in as well.
>> Yeah, I think we just have one just to
get an idea of the kind of components
that you can find in the framework.
>> Yes. Um maybe let's switch back. Sorry,
we're switching back and forth between
screen. But um yeah, go let's go ahead.
Yeah. Uh Johan. So yeah, this is just
like a a short overview of some of the
main components that you have in
longchain and long graph because right
now the two are kind of tied together.
Marlin, I think you framed both of them
uh very greatly as from when to use one
or the other. But yeah, you'll see that
the documentation kind of mixes the the
two because you always start with
longchain. But when you dive into like a
more complex use case, that's where you
you can integrate with some of the long
graph components. Uh but yeah, starting
from the core, you have like the models
that's whole you basically abstract your
calls to uh the LLMs mainly. The
messages is where you can like format
and uh the content that you send to the
LM uh being text, images, audio and also
the content that you get back from the
LLMs. Uh these days since we're mostly
doing agents uh you have tools uh which
is basically functions uh that the
agents can calls to like get data
perform some action on behalf of the
users. And then we have the agents and
we'll we'll dive a bit more into that.
Uh but very quickly uh an agent if
you've never heard about that uh is
basically you loop in a model with a set
of tools uh toward like doing some
goals. Uh the the model will like uh
call the tools when needed uh like
transform the unsw the the result from
the tool coding and basically uh unswear
you with uh some formatting back at the
end if if it succeed. And uh where
things start to get interesting is all
the addition uh that you get when you
want to do more complex scenarios like
hook into the agent execution steps. So
longchain especially V1 we'll see that
uh provides new helpers to do that uh
and to do like scenarios like human in
the loop for validation for example also
uh to store your interaction that's chat
history but not only because in the
agentic world uh we call that
checkpoints uh to store like every
action that the agent uh did all the
steps and you can do things like travel
back in time for example or retry if
something goes wrong. And of course,
because you want things to be
responsive, you want to make like nice
UI for the user. Uh we'll talk also a
bit about streaming.
>> Do you have anything else around that?
Marina,
>> sorry Marlene, you're mute.
>> I'm muted. I'm so I'm so sorry. I'm
trying to type and answer people. Uh
yeah, I was muted but I just wanted to
say these are definitely the core
components and this is mainly what we're
going to be using to build out our
applications um when we're using Lancane
particularly I would say for building
out AI agents. Um so maybe let's now
dive into V1 and some of the core things
about what's changed in V1. So if you
were using lang chain before something
to that's really important to know is
that it is not a drop in replacement. So
you cannot use you know take the old l
the new land chain package and just swap
it out for the new one um and have
everything work super smoothly because
the API has changed quite a lot
significantly like we can see on this
screen um agents are the new focus for
lang chain v1. So the API has changed so
that now in the past you would be able
to use Zchain with actual chains where
you used to be able to chain together
different integrations tools and things
like that and now those chains are
depreciated. So if you try to use a
chain and lang chain it's not going to
work. So the ch the name I don't know if
we should be now lang agents or
something but the chains are out uh and
that's going to be dep that's already
depreciated. Um and something to note as
well is that if you do want to take your
time in terms of transitioning over um
they do still they're going to still
make available the old package for lang.
But this is going to be called lang
chain classic. So if you're going on
Pippi and you still want to use the old
version of Langchain, you can still do
that, but you have to pip install
Langchain classic or you know npm
install uh lang chain classic instead of
the newer lang chain packages. Um I
think we are going to go ahead and look
at two examples of what it actually
looks like to build agents. So what used
to be in the past you would have to use
langraph to be able to create something
called a react agent. That was one of
the most popular workflows that we would
see in lang in lang and lang graph was
to use this create react agent and so
now lang has kind of moved that
abstraction into lang chain the main
package um and this is how we would
quickly build out an agent and and
that's something we want to show you in
just a second
uh yan do you want to start sort of
sharing your screen and showing how to
create the agents or or should I
>> uh I can start if you want. Um, usually
we start with Python, but um, I'm fine
with starting with JavaScript once.
>> So, yeah, just for echoing what what you
said about like deprecating like the the
the old chain thing. Uh, this is what we
used to do with longchain like basically
instantiating a model uh having a set of
prompt and then chaining uh a few stuff.
So this one is very simple just sending
like a prompt and getting the results
and yeah right now we are more focused
on doing things with agents. So let's
move on
to this example. So yeah for this one uh
I've set up uh a very simple tool uh to
get some jokes using the chat nor API.
Something I I like I enjoy using from
time to time when doing demos like this.
So yeah, basically uh I'm calling this
tool get jokes. Uh giving it a
description. Okay. Uh you just give it a
keyword. So here I'm specifying a schema
using zod. If you not used zod before,
it's basically a way to define uh both
JSON schema and typings automatically
using JavaScript. So I'm just saying
that uh okay this tool will just take a
single argument that's called keyword
and I'll use that to like fetch uh make
a search using the check API. So very
simple tool and now doing the agent
which used to be something complex I can
now do that with like this new create
agent uh function. I don't even need to
like instantiate the model. Instead I
can use this new helper saying okay I'm
want to use like this provider. So here
I'm using a penai say the model name. So
I've set up like uh some environment
variable uh that I'm loading with the
tool uh just to get this setup but I
don't have like to like run the the the
old like way of you instantiating like a
new class set up everything basically
just this helper is enough. So we can
quickly switch for example to using a
different provider to using like if I
want to to try things locally. Uh I'm
just setting which set of tool I want to
be available for for my agent. And it's
even optional but uh you can like
customize uh the the system prompt that
you want the agent. So here I'm just
saying okay I want my agent to be like a
humor assistant to use tools to just
provide jokes uh based on what I want
and then I invoke my agent saying okay
my message is just okay I want to have a
good love uh with something about cats
so let's just try to run this code and
see what happens
so uh I don't have like a pretty
formatting So here you can see like uh
this was my request. So okay this was
the human message that was sent to the
model. The first uh answer was uh
basically tool calling uh to to to call
the get jokes functions that was made. I
think if we scroll down we can see okay
uh this is the function that the model
we call uh you can even see the keyword
that was used. So about cat that was
extracted from my request. You can see
the on this is the row JSON returned by
the API. So this is the result of my
tool. So let's scroll down a bit and
then at the end yeah we should see like
the answer from the model and this is
basically the answer say okay here's a
funny cat Chuck Norris joke for you. Uh
they say curiosity killed the cat. This
is false Chuck Norris killed the cat.
Every single one of them. Okay not very
funny this one but yeah you get the
idea. So that's how easy uh it is to
create like uh an agent using this new
longchain v1 API. Uh maybe now we can
switch to Python to see how you do that
with Python.
>> Yes, let's definitely switch over to
Python. Thank you Johan uh for that. We
love JavaScript as well. Uh both
JavaScript and Python. So I'm going to
show you how what it looks like to
create uh you know these basic agents in
in the Python code.
So like Johan mentioned, one of the main
things that has changed with Denchin is
this focus on AI agents. And with
agents, there's a number of different
definitions out there, but I would say
that a standard definition that people
have sort of coalesed around is the
definition that an agent is an LLM that
runs tools in a loop to achieve a goal.
So you want to provide your your your
alol with a tool access to a tool and a
model so that it's able to achieve a
certain goal. So here in lang chain
python I want to show you there's two
options for you to use if you're using
python and lang chain. The first is
you're going to have this option to use
azure ai. So we have a lang azure aai
package. You can download it using pip
install langrain Azure AI and then the
second option is that you can actually
directly use the open AAI uh client as
well or chat Azure OpenAI for example
and I'll show you what that looks like
in just a second. So when we're using
the first op you know one that I'll show
you is this langchain Azure AI option
and once you've installed that and you
also want to pip install lang chain as
well then you're going to set your
credentials so you can go to Azure AI
foundry get an endpoint get a an API key
and you want to set this to the
environment variables so you want to
have it be Azure AI endpoint and Azure
AI credential and That's going to make
it so that instead of creating a new
chat uh writing all this code to get the
chat together, you can just use this
Azure AI and then choose your model and
place it here and it will recognize and
just create a an LLM instance for you.
And then something I want to point out
here is that I've created a simple tool
called get weather when you've when
you're given a city. So, we're going to
pass through the LM is going to get uh a
query from the user saying, can I get
the weather in this city? And then it's
going to take that city and return a
response. This is just a dummy tool. So,
so it's going to say it's always sunny
in this city. And then what we also have
here is this is the main abstraction.
So, for langain v1, we're going to say
from lang chain agents import create
agent. That is the main abstraction
we're going to use and we're going to
take that create agent here. We're going
to set the model. Uh we're using GPT5
mini like uh I pointed out before going
to put the tools. So we have the tools
is just a Python function here that we
create. I'm going to pass the name of
the tool or the function that we have
into a list. Uh, and so you can have
multiple tools that you can pass into
this list and that will all be available
for the llim to then decide which tool
to use. It's going to read the
description here and then make a
decision from there. And then we're
going to put a a system prompt through
which at the moment is just your helpful
assistant. So when I run this, I'm going
to just uh do this for the first option
here for Azure AI
and save that. And then when I run this
command, I've already put in to say the
user is asking what's the weather in SF.
And so I just need to run the file. So
I'm going to say Python uh basic
agent.py.
And when I run that, it should print out
to me that basic response to say it's
always sunny in San Francisco. Hopefully
if
yes, which says the weather report I
got, it's always sunny in San Francisco.
So it's going to look at the answer that
the tool sent it, which is this tool
that we gave it. And then the LM will
take the the response from the tool and
give us uh another response there as
well.
The second thing I want to show you as
well is that we can now in V1 which is
pretty exciting use directly the open AI
uh client and we can use this as well
with an Azure AI endpoint using the new
OpenAI v1 API. Um and I am also going to
show you how to do this. We're using
default Azure credential which is the
best practice if you're going to be
using if you're doing something that
needs high security if you don't want to
keep your tokens your API keys in your
code Azure credentials is one of the
ways uh to do things securely. So this
is in this case we're just going to open
uh import from langra openai we're
importing chat openai and we want to in
install pip install langra openai and
then when we do that we will get a
resource name from Azure AI foundry put
that in here and we're going to
specifically use this endpoint to say we
want to use the openai v1 API and then
we're going to pass through we're going
to create a token provider which will
take instead of using an API key, it's
going to encrypt that and give us a
token instead. And then we're going to
give it this addition tool as well to
use and we're going to ask it a question
from there. This time I'm going to ask
it the question to say add these two
numbers and I'm also showing how to
stream here. So just this code here uh
is is a new way that we can stream. They
have something called content blocks
which I'll show in just a second as
well. So to be able to run this, let's
go ahead and comment this out and
we'll run the second function to see
using the OpenAI um client instead. And
it's going to also use streaming. So
hopefully here we should see the output
which when we ran that function there's
several things we can see. We can see
I'm I'm using streaming. So I am just
returning the messages from the stream.
It made a tool call to the addition tool
and I had asked the question can you add
2 plus2 so it took the the question
there and turned it into inputs that it
can pass through to this tool and then
we can see land chain now in v1 returns
these content blocks which show you the
type of response that you're getting and
what the actual value is. So that's
something that's new. It hasn't always
been there. We get a final response to
say 2 plus 2 is 4 using this addition
tool. So those are some things that are
new is is really the most important
thing to note that's new is this
langchain.agents
um thischain.agents abstraction where
you can import this create agent and it
will work from there. And then for
streaming, we do get these content
blocks, which is kind of different from
what we had in the past as well. But
it's a great way, say for example, if
you want to note if it's text that's
coming back or reasoning, sometimes they
they identify reasoning tokens versus
just normal text. And so this is helpful
for that as well. So, um, yeah, maybe
let me switch over to Johan now for for
him to show the JS side for, uh, a more
complex example with MCP.
>> Yeah. Uh, thanks, Malin. So, uh, yeah, I
think we we may have skipped a bit on on
a few things also that that were with
V1. So, you talked a bit about like the
the content blocks. Uh, there's also
like the middleares. uh if we switch for
example um let's me show uh the
documentation from longchain so the idea
so this is the basic uh agent loops that
Marlin told basically you looping over
an LLM with tools until you you get your
results so the definition of agents uh
but sometimes uh you want to hook in to
the different stage uh to the different
step of this agent like before coding a
tool or after or before calling the
model uh to have better control on on
what your agent is doing. And one of the
new thing that was introduced with
longchain v1 is uh first a few built-in
middleware that are really helpful uh
for like some of the common scenarios
like uh when you have like too much
messages in your context at some point
you may want to summarize like the
message story. So there's like a
middleware that takes care of doing that
for you now. Or maybe sometimes you want
to uh to put the human in the loop to
validate for example before calling some
tools like for example if you want to
send an email or stuff like that. Uh you
have this middleware that you can
configure uh to put human interaction
that will basically interrupt uh the
agentic flow to ask the human if you
want to continue with whatever is going
on at the moment. So this is the the
kind of new things also that that were
uh pushed into longchain v1.
>> Yes, absolutely.
Um yeah, I I did want to show quickly
what an interrupt could look like as
well in middle with middleware. Um so
I'll also just go ahead and share
quickly what that looks like in lang
chain. So for example uh Johan pointed
out inter uh the middleware one of the
examples I'm going to show is human in
the loop middleware. So this is a great
way to have that highle abstraction
where you don't have to write code from
scratch. That's one of the things that I
think if you have things that you're
doing over and over again you want an
abstraction to make this easier. So
Johan talked about how you can have the
send email. You might be sending an
email to someone and you or or you might
be talking to an agent and that agent
has tools to be able to send an email
and you don't want that agent to just
send an email whenever it wants. You
wanted to get approval before it does
that. And so for example, you would use
something like the human in the loop
middleware to be able to do that. And in
Python for examp in this case you would
want to access it using this again the
abstraction we use agents and then we
use middleware and then you import
whichever middleware you want to use. So
in this example here I'm going to have
this human in the loop middleware
um and and in this option in this uh
version you want to pass through an
interrupt on. So you want to say if the
agent is about to use the send email
tool, it should stop. I you should
interrupt the flow of what's happening
and you should ask the human to approve,
edit or reject. And and it doesn't have
to be a human. It could be another agent
that decides to do that or not. And uh
then this will show this will cause an
interrupt and and you'll be able to ask
for a response from the human. So this
is pretty much again we're using that
create agent abstraction we saw earlier.
We're setting that model to GPT5. We're
passing in the tools like we did before.
We have this list of tools. These are
dummy uh functions here. And then you
also need to send through a configurable
for a thread so that you can note which
thread or conversation thread is
happening here. So I'm going to show you
an example uh of running this. So let's
just run Python and let's say
middleware.py.
And when we run this, it should be
asking this question. I just want to
show us what the interrupt will look
like. So here um the user as a user we
ask the question please send an email to
Alice with the example meeting and body
let's meet at 10:00 a.m. And so before
you notice that the tool to be used is
the send email tool and it immediately
saw that we need to interrupt. So it's
going to create this interrupt here and
it's going to have some options for us
to use. And the action request would be
should the user approve, edit or reject
this action. And here we could put in
some Python code to be able to allow the
user to decide what to do from there.
But this is basically what you would how
you would use in Python code and
interrupt to be able to do something
like that. And in V1, it's really easy
to do that using this new middleware. uh
and and like Johan says there's other
custom middleware like summarization for
example too. So that is is middleware I
think it's really exciting really
helpful uh to do as well. So um maybe
Johan we can move to the next example as
well.
>> Yes. Uh let's switch back to to see some
JavaScript.
>> Yes.
>> Okay. uh ju just showing quickly uh the
equivalent JavaScript for what you've
shown. So I won't go too much in depth
because like the concepts are exactly
the same but just to show you what it
looks uh as a change to to the earlier
agent code that I've shown you uh like
calling still calling the check API. uh
imagine this is like uh some kind of uh
external API and if you're like in an
enterprise context you may want to get
like uh some control whether you want or
not to to call that API in an agency
context. So uh we still have the create
agent from earlier uh you see the same
uh model tools and setup and basically
we added two things to be able to to do
just the same thing as Marlin shown in
Python. uh we needed like a check checkp
pointer to basically uh have a way to
save uh we just use the simple memory
saver. So basically just save
temporarily in memory all the different
steps uh that the agent went through. So
we're able to continue uh from where uh
from where we were at the point in the
context where we got the interruption
and then I'm setting up the middleware.
So I'm using the the same human in the
loop middleware and just say okay I want
approval before calling this get jokes
API and uh you also have the control to
say which decision uh the user is
allowed to make. So in this case I'm
just allowing uh to approve or reject uh
the call and yeah uh when you're running
uh the same agentic loop as before uh
you will will skip the first result but
we'll end up at the same points that
Marlin said. basically uh we get
interrupted before coding uh the the
tool uh because we awaiting the human
response at this point. So I've not like
uh coded what uh what happens next but
it's basically the same as Python uh you
can approve or reject and then you
continue uh based on where we were at
thanks to to the checkpointter that that
saved the context before the
interruption.
And uh yeah, something also that that we
skipped very briefly uh basically the
content blocks uh is the way that
longchain added in top of the previous
API uh to like manipulate different the
different kind of contents because like
models are multimodel these days they do
not manipulate only text but also audio
images or any kind of other content and
uh either for for impute or output uh
usually
you have like a format that is native to
each provider like for example openai
anthropic or yama uh when you need to
provide like this uh kind of different
content like for example here we're
mixing text uh with an image but now
with longchain uh you have like a
provider agnostic way of specifying the
different kind of contents so in this
case a text of an image you see it's
very similar but this one will work
whatever provider is used uh whereas if
I was using something like this, it will
only work with the OpenAI provider. So
this is a very welcome addition when you
want like to to use different kind of
contents and switch provider on the fly
uh for for different context.
And uh something else that's very
interesting that you've shown uh in your
last example is the streaming. So I made
that two different sample uh again going
through the the agent uh use case
calling the the jokes the choric jokes.
Uh but this time uh I wanted to to see
what happens if instead of just getting
the end results where you get like all
the the different steps uh with the
intermediate tool calling and the final
results I want to see the results coming
uh as they appear. So uh we have with
longchain v1 it's actually calling from
the underlying long graph but you don't
need to to know about that as you see
I've only imported longchain in there.
Uh basically you have this stream mode
option and instead of using invoke I'm
using stream and you can have a few
different way to streams. Uh here I'm
just streaming like the tool uh and llm
calls update. So it's calling me uh with
a new event every time uh this kind of
step has ended. So for example I'm just
catching here uh the either the result
of a model request of a tool calling. If
we run the same agent as before you will
see like this appear uh as the model as
the agent is currently running. So first
uh we have the model on say hey we need
to call get jokes. Uh we get the get
jokes response and then we have the
final answer of the model. So thanks to
to streaming uh the events like this,
you can even like combine multiple
streaming modes for example to also
stream the final token token by token
the final answer. Uh basically you can
get very responsive UI do not have to
wait like especially if you have like a
a long running agent that does multiple
in between steps. you can provide
feedback to your user uh thanks to this
new streaming API.
>> Amazing. So I um okay uh maybe before we
do the MCP demo I will quickly go ahead
and share my screen to show uh something
else that's very cool with the changes
in Lchain. So one thing that they've
really done a great job with for
langrain v in v1 is to update the
documentation. So uh this is something
that I think the docs have improved
significantly and if you want to learn
something new it's it's a really great
way to do that. Something I would point
I will point out is that they have an
MCP server that they've created for the
documentation. So if you want if you are
using something like GitHub copilot in
VS Code um and you want to be able to
have the latest information on what's
the best way to do something you can
just go to the copy page and you can say
connect to VS Code uh on that page and
that will install the MCP server for
you. So I did an example of that earlier
today where I clicked that and it just
brings it up here and we can see it. It
installs the docs by langchain MCP
server in VS Code. This is just where I
am here. And you'll see on that list of
installed MCP uh servers, the Langra MCP
server comes up and then you can ask it
questions like for example I said use
the langrain docs to show me the latest
way to build agents in Python. And once
you have that server installed, it's not
going to have to, you know, rely on old
information that it was trained on prev1
to give you bad information on how to
build agents with lang chain. you can
just go ahead and plug in this MCP
server and then it's going to give you
that latest information uh to be able to
so this is an example of all the
searching it did through uh the
documentation to give me uh an example
of actually how to then build out
agents. So we can see in this example
it's giving me multiple uh options and
and we see it's using the latest example
from uh V1. So that's something I think
is a little tip. If you use Copilot uh
and VS Code, this is a great way to to
jump ahead. So go ahead, Johan and and
show your uh your MCP demo as well.
Yeah, this is also awesome if you want
to to learn about this new API, how to
want to m migrate like using AI agents
and having this like MCP server built in
to access the the new ducks I think is a
really good use case of using agents in
your coding workflow because it's really
helping especially as when the API like
this changes you're not expected to
catch like all of these changes at once.
So having some help sometimes is good as
>> 100%. I do want to say one more thing.
Sorry, I will point out that we will
share all of the links. We're so sorry
the links are not in the description. We
will share the links at the end and uh
please join the Azure AI Foundry uh
discord channel. We'll be sharing the
links there. I'll also send the links as
well in the comments after the stream.
So please yes we we are aware this the
the the links are not uh online some of
them but yeah go ahead Johan
>> and uh yeah just to show you like a more
complex uh example we shown you like
code snippets on how to do things uh
I've literally just completed this new
sample yesterday. So I will show you
just a quick overview of this. So it's
all built using uh longchain v1 API uh
the new streaming API that we've just
shown uh the OpenAI Azure OpenAI v1 API
using the response API that Marlin
talked about also earlier. So yeah just
let me switch. So this is the I've put
the link uh in the previous slides. We
you will also get it in the chat and uh
in the video description when we'll
update it. Uh basically you get this
GitHub repo uh where we took the uh use
case of like a restaurant wanting like
to accept uh being able to accept and
help customers do some orders uh for
burgers. Uh basically exposing a
business API that was already existing.
So uh let me switch here to to the
swagger just to show you like the the
overview. So we had this bugger API
that's provided uh by the company where
you can uh like interact with the orders
like get your existing orders console
one place new one and get access to the
menu to get the list of burgers toppings
and made some like specific filtering on
that. So what we did in this sample is
basically uh we connected uh this burger
API. We created an MCP uh server uh that
connects to this burger API and uh we
built a longchain GS agent that connects
to that MCP server uh to uh talk to the
API. So uh yeah, basically this is uh
like the the simplified flow. So we have
like a web app uh where you can interact
like uh in a chat mode ask some question
for for the the agent. So we have here
uh the agent is hosted as an API. So we
have the the long chain called the LLM
and our burger MCP server and the MCP
server is basically exposing uh some
parts of the API as tools to the LLM. So
we can do like interesting stuff. So
let's just see a demo of what it looks
like in practice. So uh here I have like
my chat UI.
So let's say for example
uh I I want I'm feeling uh great today.
Let's say uh I want to order
something very spicy.
A very uh spicy one.
And I say surprise uh surprise me
and go. I just want the agent to do it
stuff. So we will see the streaming of
the different steps going on. So you see
that first it's retrieving like the
burger list from the menu then the
toppings list uh from the menu and maybe
at some point uh it will like place a
new order and then we should get an
answer at the end maybe.
And here uh we get the results. So yeah
looks yummy. So let's just see what it
order. So I haven't have like my order
ID. So yeah it selected for me. I just
said I wanted something spicy. So it
looked from the menu something that
match what match what I wanted. I did
some extra okay extra jalapenños. This
will be extra spicy and I get some
information about like when my order
will be ready. And uh we can also this
is just like for debugging and for the
developers out there. But we can also
see what happened. So uh we can get the
details of like the different calls uh
that happened under the hood. uh like
the first one uh resulting okay we want
to get the burgers so we get the burgers
we can even see like the output uh then
uh we wanted to get the toppings and you
get the output and then finally it took
like the results of these two API call
uh to place an order like with the
correct uh like ids for the burgers
toppings and etc and finally uh the
final response you you see the result in
there So that's at a glance what this
sample is doing. So connecting a lot of
different things in there. Uh but just
wanted to show you what in practice uh
what you can do uh like as a business
use case uh doing with like the newest
longchain v1 API uh doing building a
simple agent uh if we dive a bit into
the code. So it's this one. So yeah, I
I've wrapped the agents both in API and
as a CLI. I will just show you the CLI.
It works exactly the same way, but
because the code is simpler, you don't
have like the HTTP call stuff, it will
be easier to to show you. So we get like
this system prompt to say, okay, we are
a restaurant, you manage orders and
stuff like that and how you want to
format the answer. So I'll just skip to
the most interesting parts and you will
see that it's not more complicated uh to
what we set up earlier. So here for the
model um I'm using the new Azure OpenAI
v1 API and we still have like to improve
the uh the integration with the latest
longchain. So I still have a few PR to
to do uh for for the rest of the week.
uh but uh because we're using managed
identity and not API keys uh I had to do
uh this extension so hopefully it will
go away when we'll improve the
integration uh but what I wanted to show
is that I'm using I I've seen a question
in the chat about that I'm using the
latest open AI response API to do uh the
this agent I'm I've enabled streaming
for the the token by token uh streaming
and here's how I connect like the MCP uh
server to this agent. So here's uh
basically the client and streamable HTTP
client comes from the uh anobic uh MCP
SDK. So the TypeScript one, it doesn't
comes from longchain. So I'm just
connecting uh basically through HTTP to
my MCP server. And then to use MCP uh to
import the MCP tools into longchain, I
just have this one line MCP helper to
say okay uh this is my client that
connects to to my MCP server and I'm
importing that as tools uh into uh
longchain for use with my agents just
using this load MCP tool helper and you
have further option if you want to only
import some of the tools but in my case
I wanted to import everything and next
uh the create agent is exactly the same
that you've seen. before like uh I'm
just adding the model, the tools and the
prompt. Uh here I'm just saving the chat
history just using a flat JSON file and
uh to get the result as it comes. Uh I'm
using a different streaming API because
I wanted to have every single event. Uh
this is another one that is available in
longchain and long graph is the stream
events API and it will give you like
basically every single events of
everything that's happening like before
calling the model after calling the
model and then you can filter out to
just get the information you want. So
that's the basic flow and uh yeah we've
shown you that you using the very same
abstraction that works in snippets it
also works uh into a more complex
project
and uh yeah oh we just changed the order
but uh that's basically it. Uh anything
you wanted to add Marlin?
>> Um I did want to add that I am in the
process maybe let me share my screen as
well. Uh just really quick and I did
want to add that I'm also working on a
similar sort of project that will let
you deploy an app a lang chain chat
assistant app that also uses the
responses API in the background and
should be able to allow you to use
things like MCP as well. I'm a little
bit behind on on that at the moment, but
I will have a link to that soon uh that
I will share and it just looks like this
um to be able to chat to um a Langchain
assistant. Another thing I wanted to add
is that Langchain also has something
called deep agents which they've
recently announced and this is a
fantastic package. If you've used uh if
you used coding agents like copilot um
the the copilot coding agent or claude
code for example a lot of these agents
use patterns where uh they're they're
iterating on tasks for longer period of
time. So maybe they'll do multiple tool
calls, maybe 50 tool calls in instead of
two tool calls. And so in those
processes, you need a lot of uh things
like context engineering. You need to be
able to store uh a lot of context for
the agents. You need to have the agents
create to-do list tasks and things like
that. And I think this is a really cool
project. It's updated with V1 as well.
And I have some examples on how to use
this project in a repo uh online as
well. And I will share the link to that.
The repo is going to be aka uh ambient
agents uh and and you should be able to
find that re repo at the end. I'll I'll
put a link to it as well. So I think
that's all we wanted to share. Um the
last point that we will put up is just
all of some of the links that we have
available. We'll probably have some
more. Please join the Azure AI foundry
discord chat. There is a lang chain
discord in Azure AI foundry and we will
put more links there in the coming days
as well. And then right after this
there's a Python stream that you can
join if you want to know more about
agents as well. Um but yeah, I think I I
nothing else from me. Y the only other
thing is probably to share our slide,
the last slide with the resources.
Um yeah.
>> Yeah. Just in case if you want like to
continue like the discussion uh we have
like uh on discord uh you can just reach
out to us, ping us or ask question about
like anything if you're stuck or
anything about AI. we're here like to to
help and also if you have like any
product feedback or errors while trying
to build and using like one of our API
you can also reach out uh we have like a
GitHub forum discussion space to ask
anything about AI and also get some
help. So yeah the discord is more
informal and if you have like issues you
might get more help uh onto GitHub. So
that's two ways to also connect with us
and uh like continue building and maybe
ask some questions and yeah Marlin
mentioned that but some of the links uh
from the the samples that we've shared
so you you see some on these slides
we'll share also them uh update the
video description after that and some of
the code snippets are not yet on GitHub
for me it was very last minute so we'll
take some times to put that into a repo
and we'll put everything in the video
description so if come back later. We'll
you'll get everything.
>> Yes, absolutely.
Um yeah, I think that's all we have time
for today. Thank you so much for joining
the stream. We are very excited about
Lang Chain. Very excited about B1. If
you have any questions that we didn't
answer already, please put them in the
chat and we will go around. We will come
into the chat and and answer them even
after this stream. But thanks so much
for joining us everyone. Um yeah, see
you again next time. Bye.
>> Thank you Johan. Thank you Marlene for
the session today. Thank you all for
joining us. Uh at the reactor we seek we
always we are always looking to improve
our sessions and our experience. So if
you have any feedback for us, we would
love to hear what you have to say. You
can find the link in the chat in the
chat or on the screen and we'll see you
on the next one.
Join Marlene Mhangami and Yohan Larosa in this livestream to celebrate the launch of LangChain v1! JS links: https://aka.ms/lcjs/agent-mcp : LangChain.js Agent + MCP sample https://aka.ms/lcjs/agent-mcp/blog - walkthrough post for the sample above https://github.com/sinedied/langchainjs-playground/ - JS snippets Python links: https://aka.ms/ambient-deep-agents - LangChain Deep Agents Sample https://aka.ms/langchain-chat - LangChain Chat sample https://github.com/marlenezw/langchain-playground - Python snippets Chapters: 00:06 – Welcome & Housekeeping 00:56 – Meet the Speakers: Johan & Marlene 02:04 – How We Got Started with LangChain 04:44 – LangChain vs LangGraph Explained 06:00 – What is LangChain? Core Concepts 07:42 – LangChain V1: Major Changes & Agent Focus 16:00 – Demo: Building Agents with LangChain V1 in JavaScript 20:00 – Demo: Building Agents with LangChain V1 in Python 28:00 – Middleware in LangChain V1: Human-in-the-Loop & More 36:56 – Streaming with LangChain V1 39:03 – Using LangChain MCP Server with VS Code 42:20 – Full Demo: LangChain Agent for Burger Ordering 50:01 – Deep Agents & Final Resources 53:42 – Wrap-Up & Feedback Invitation #microsoftreactor #learnconnectbuild [eventID:26481]