CoolFace
Apppublic

Rahmath1/self_improving_agent

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
client.cpython-312.pyc79 linesDownload Raw Back to __pycache__
12F��i���j�dZddlmZddlmZddlmZddlmZddl	m3Z4mZGd�d	ee5eef�Zy6)z&__ENV_TITLE_NAME__ Environment Client.�)�Dict)�	EnvClient)�7StepResult)�State�)�__ENV_CLASS_NAME__Action�__ENV_CLASS_NAME__Observationc�F�eZdZdZdedefd�Zdedeefd�Z	dede8fd�Zy)	�__ENV_CLASS_NAME__Enva9    Client for the __ENV_TITLE_NAME__ Environment.10 11    This client maintains a persistent WebSocket connection to the environment server,12    enabling efficient multi-step interactions with lower latency.13    Each client instance has its own dedicated environment session on the server.14 15    Example:16        >>> # Connect to a running server17        >>> with __ENV_CLASS_NAME__Env(base_url="http://localhost:8000") as client:18        ...     result = client.reset()19        ...     print(result.observation.echoed_message)20        ...21        ...     result = client.step(__ENV_CLASS_NAME__Action(message="Hello!"))22        ...     print(result.observation.echoed_message)23 24    Example with Docker:25        >>> # Automatically start container and connect26        >>> client = __ENV_CLASS_NAME__Env.from_docker_image("__ENV_NAME__-env:latest")27        >>> try:28        ...     result = client.reset()29        ...     result = client.step(__ENV_CLASS_NAME__Action(message="Test"))30        ... finally:31        ...     client.close()32    �action�returnc��d|jiS)z�33        Convert __ENV_CLASS_NAME__Action to JSON payload for step message.34 35        Args:36            action: __ENV_CLASS_NAME__Action instance37 38        Returns:39            Dictionary representation suitable for JSON encoding40        �message)r)�selfrs  ��C:\Users\rahma\OneDrive\Documents\GitHub\Streamlit\Project2\Self_Agent\self_agent\Lib\site-packages\openenv/cli/templates/openenv_env/client.py�
_step_payloadz#__ENV_CLASS_NAME__Env._step_payload/s��
�v�~�~�41�	42��payloadc43�>�|jdi�}t|jdd�|jdd�|jdd�|jd�|jd	i��44�}t||jd�|jdd���S)z�45        Parse server response into StepResult[__ENV_CLASS_NAME__Observation].46 47        Args:48            payload: JSON response data from server49 50        Returns:51            StepResult with __ENV_CLASS_NAME__Observation52        �observation�echoed_message��message_lengthr�doneF�reward�metadata)rrrrr)rrr)�get�1_ENV_CLASS_NAME__Env__ENV_CLASS_NAME__Observationr)rr�obs_datars    r�
_parse_resultz#__ENV_CLASS_NAME__Env._parse_result=s����;�;�}�b�1��3�#�<�<�(8�"�=�#�<�<�(8�!�<����V�U�+��;�;�x�(��\�\�*�b�1�53���#��;�;�x�(����V�U�+�54�	55rc�Z�t|jd�|jdd���S)z�56        Parse server response into State object.57 58        Args:59            payload: JSON response from state request60 61        Returns:62            State object with episode_id and step_count6364episode_id�65step_countr)r"r#)rr)rrs  r�_parse_statez"__ENV_CLASS_NAME__Env._parse_stateVs+����{�{�<�0��{�{�<��3�66�	67rN)�__name__�68__module__�__qualname__�__doc__�,_ENV_CLASS_NAME__Env__ENV_CLASS_NAME__Actionrrrrr rr$�rrrrsG���469�$<�70��71�72�T�73�j�9V�.W�74�2
75�D�
76�U�
77rrN)
r(�typingr�openenv.corer�openenv.core.client_typesr�openenv.core.env_server.typesr�modelsrr	rr*rr�<module>r0s6��-��"�0�/�K�Q78�
�&�(E�u�L�M�Q79r