§
    šŠtjã  ã                   ó–   — 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dS )é    N)ÚAny)ÚRunnableConfig)Úvar_child_runnable_config)Ú	BaseStore)ÚCONFÚCONFIG_KEY_RUNTIME)ÚStreamWriterÚcÚreturnc                 ó   — d S )N© )r
   s    úN/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph/config.pyÚ_no_op_stream_writerr      s   € Ø€Dó    c                  óÖ   — t           j        dk     r4	 t          j        ¦   «         rt	          d¦  «        ‚n# t          $ r Y nw xY wt          j        ¦   «         x} r| S t	          d¦  «        ‚)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      sŽ   € Ý
Ô˜'Ò!Ð!ð	ÝÔ#Ñ%Ô%ð Ý"ØSñô ð ðøõ ð 	ð 	ð 	ØˆDð	øøøå.Ô2Ñ4Ô4Ð4€zð NØÐåÐLÑMÔMÐMs   ’"5 µ
AÁAc                  óT   — 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Ð7r   c                  óX   — 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Œ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Ð 3Ð 3Ð 3Ð 3Ð 3Ø EÐ EÐ EÐ EÐ EÐ EØ *Ð *Ð *Ð *Ð *Ð *à CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ (Ð (Ð (Ð (Ð (Ð (ð	˜Cð 	 Dð 	ð 	ð 	ð 	ðN�Nð Nð Nð Nð Nð[8�9ð [8ð [8ð [8ð [8ð|F!˜<ð F!ð F!ð F!ð F!ð F!ð F!r   