-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Support features requiring async local storage (interrupt, functional API, etc) in web environment #879
Comments
I have bumped into the same issue while experimenting with using Functional API in web environment. @rothnic do you know whether there are any downsides of not using task() wrapper? Any updates on this issue? |
No idea. It feels like the whole langchain API is rather hard to follow and there are so few examples of langchainjs already, then of the functional API there are fewer, then using it in a web environment are even fewer, so we are in a narrow use case. |
I'm in the process of releasing it (should go out within an hour), but #933 should address this for you. I'll also aim to improve the docs around this particular case (will add a howto). Preemptive link to the API reference for |
Ahh, my apologies - I missed that this was specific to the web environment. Unfortunately unless you're shimming |
@benjamincburns I was unable to find an actively maintained shim for async_hooks. For context, I was using langgraph within a chrome extension, where having an always running external server seemed like overkill. Having a hard dependency on async hooks feels like it will make development for the web forever difficult |
@rothnic Just a heads up that we are actively looking into how we can better support environments that don't have ALS. Unfortunately I don't have any conclusive details to share just yet, as we're still in the exploratory phase. cc @littledivy |
I am building a graph that is focused on iterative extraction of unstructured data (extraction agent), then when ready, I wanted to transfer to my cms agent to get the content into my CMS. I was building this out so it could run in a web environment and the combination of using the web functionality and the newer functional API caused me to run into issues.
Context
Summary
I followed this multi-agent functional API example, but used the task function exported from web like this cannot be used in the web environment that i can tell:
Task
Agent
Error
However, when i got to the point of calling extractionAgent.invoke within my test within the jsdom environment using jest, I ran into an error that traced back to this code within
pregel/call.cjs
The config returned from
getRunnableConfig()
was undefined, so the if statement blew up atconfig.configurable
since config was undefined.TypeError: Cannot read properties of undefined (reading 'configurable')
Workaround
To fix this issue, I knew I needed to pass the config through as defined here. However, the
task()
api doesn't allow passing through the configfrom what I can tell. So, I had to move away from using a
task()
and instead just used a function instead with the signaturecallExtractionAgent(messages, config)
. Then I updated my function to transfer to the agent like this:Original
Updated
Also Tried (Still Fails)
I did circle back and try passing through the config in the task, but ended up with the same error
Issue:
task()
api doesn't allow passing through the config (I tried passing it through and still ended up with the same error)The text was updated successfully, but these errors were encountered: