Ë
    fœiã  ã                   ó”   — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZ d dlmZ ded	dfd
„Zd	efd„Zd	e	fd„Zd	efd„Zy)é    N)ÚAny)ÚRunnableConfig)Úvar_child_runnable_config)Ú	BaseStore)ÚCONFÚCONFIG_KEY_RUNTIME)ÚStreamWriterÚcÚreturnc                  ó   — y )N© )r
   s    úe/var/www/html/Whatsapp_Customer_Support_Chatbot/venv/lib/python3.12/site-packages/langgraph/config.pyÚ_no_op_stream_writerr      s   € Øó    c                  óÎ   — t         j                  dk  r!	 t        j                  «       rt	        d«      ‚	 t        j                  «       x} r| S t	        d«      ‚# t        $ r Y Œ.w xY w)N)é   é   z=Python 3.11 or later required to use this in an async contextz/Called get_config outside of a runnable context)ÚsysÚversion_infoÚasyncioÚcurrent_taskÚRuntimeErrorr   Úget)Ú
var_configs    r   Ú
get_configr      sr   € Ü
×Ñ˜'Ò!ð	Ü×#Ñ#Ô%Ü"ØSóð ð &ô /×2Ñ2Ó4Ð4€zÐ4ØÐäÐLÓMÐMøô ò 	Ùð	ús   •A Á	A$Á#A$c                  óF   — t        «       t           t           j                  S )a™	  Access LangGraph store from inside a graph node or entrypoint task at runtime.

    Can be called from inside any [`StateGraph`][langgraph.graph.StateGraph] node or
    functional API [`task`][langgraph.func.task], as long as the `StateGraph` or the [`entrypoint`][langgraph.func.entrypoint]
    was initialized with a store, e.g.:

    ```python
    # with StateGraph
    graph = (
        StateGraph(...)
        ...
        .compile(store=store)
    )

    # or with entrypoint
    @entrypoint(store=store)
    def workflow(inputs):
        ...
    ```

    !!! warning "Async with Python < 3.11"

        If you are using Python < 3.11 and are running LangGraph asynchronously,
        `get_store()` won't work since it uses [`contextvar`](https://docs.python.org/3/library/contextvars.html) propagation (only available in [Python >= 3.11](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task)).


    Example: Using with `StateGraph`
        ```python
        from typing_extensions import TypedDict
        from langgraph.graph import StateGraph, START
        from langgraph.store.memory import InMemoryStore
        from langgraph.config import get_store

        store = InMemoryStore()
        store.put(("values",), "foo", {"bar": 2})


        class State(TypedDict):
            foo: int


        def my_node(state: State):
            my_store = get_store()
            stored_value = my_store.get(("values",), "foo").value["bar"]
            return {"foo": stored_value + 1}


        graph = (
            StateGraph(State)
            .add_node(my_node)
            .add_edge(START, "my_node")
            .compile(store=store)
        )

        graph.invoke({"foo": 1})
        ```

        ```pycon
        {"foo": 3}
        ```

    Example: Using with functional API
        ```python
        from langgraph.func import entrypoint, task
        from langgraph.store.memory import InMemoryStore
        from langgraph.config import get_store

        store = InMemoryStore()
        store.put(("values",), "foo", {"bar": 2})


        @task
        def my_task(value: int):
            my_store = get_store()
            stored_value = my_store.get(("values",), "foo").value["bar"]
            return stored_value + 1


        @entrypoint(store=store)
        def workflow(value: int):
            return my_task(value).result()


        workflow.invoke(1)
        ```

        ```pycon
        3
        ```
    )r   r   r   Ústorer   r   r   Ú	get_storer       s   € ôv ‹<œÑÔ0Ñ1×7Ñ7Ð7r   c                  óJ   — t        «       t           t           } | j                  S )a  Access LangGraph [`StreamWriter`][langgraph.types.StreamWriter] from inside a graph node or entrypoint task at runtime.

    Can be called from inside any [`StateGraph`][langgraph.graph.StateGraph] node or
    functional API [`task`][langgraph.func.task].

    !!! warning "Async with Python < 3.11"

        If you are using Python < 3.11 and are running LangGraph asynchronously,
        `get_stream_writer()` won't work since it uses [`contextvar`](https://docs.python.org/3/library/contextvars.html) propagation (only available in [Python >= 3.11](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task)).

    Example: Using with `StateGraph`
        ```python
        from typing_extensions import TypedDict
        from langgraph.graph import StateGraph, START
        from langgraph.config import get_stream_writer


        class State(TypedDict):
            foo: int


        def my_node(state: State):
            my_stream_writer = get_stream_writer()
            my_stream_writer({"custom_data": "Hello!"})
            return {"foo": state["foo"] + 1}


        graph = (
            StateGraph(State)
            .add_node(my_node)
            .add_edge(START, "my_node")
            .compile(store=store)
        )

        for chunk in graph.stream({"foo": 1}, stream_mode="custom"):
            print(chunk)
        ```

        ```pycon
        {"custom_data": "Hello!"}
        ```

    Example: Using with functional API
        ```python
        from langgraph.func import entrypoint, task
        from langgraph.config import get_stream_writer


        @task
        def my_task(value: int):
            my_stream_writer = get_stream_writer()
            my_stream_writer({"custom_data": "Hello!"})
            return value + 1


        @entrypoint(store=store)
        def workflow(value: int):
            return my_task(value).result()


        for chunk in workflow.stream(1, stream_mode="custom"):
            print(chunk)
        ```

        ```pycon
        {"custom_data": "Hello!"}
        ```
    )r   r   r   Ústream_writer)Úruntimes    r   Úget_stream_writerr"   ~   s#   € ôJ ‹lœ4Ñ Ô!3Ñ4€GØ× Ñ Ð r   )r   r   Útypingr   Úlangchain_core.runnablesr   Úlangchain_core.runnables.configr   Úlanggraph.store.baser   Úlanggraph._internal._constantsr   r   Úlanggraph.typesr	   r   r   r   r"   r   r   r   ú<module>r)      s[   ðÛ Û 
Ý å 3Ý EÝ *ç CÝ (ð	˜Cð 	 Dó 	ðN�Nó Nð[8�9ó [8ð|F!˜<ô F!r   