instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Add docstrings for internal functions
# -*- coding: utf-8 -*- import json import os from json import JSONDecodeError from typing import Any, Callable from ._evaluator_storage_base import EvaluatorStorageBase from .._solution import SolutionOutput from .._metric_base import MetricResult from ...agent import AgentBase from ...message import Msg from ...type...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""A file system based evaluator storage.""" import json import os from json import JSONDecodeError @@ -13,6 +14,20 @@ class FileEvaluatorStorage(EvaluatorStorageBase): + """File system based evaluator storage, providing methods to save and + retrieve evalua...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/evaluate/_evaluator_storage/_file_evaluator_storage.py
Add professional docstrings to my codebase
# -*- coding: utf-8 -*- from datetime import datetime from typing import Any, List, Literal from ._cache_base import EmbeddingCacheBase from ._embedding_response import EmbeddingResponse from ._embedding_usage import EmbeddingUsage from ._embedding_base import EmbeddingModelBase from .._logging import logger from ..me...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The dashscope embedding module in agentscope.""" from datetime import datetime from typing import Any, List, Literal @@ -11,6 +12,18 @@ class DashScopeTextEmbedding(EmbeddingModelBase): + """DashScope text embedding API class. + + .. note:: From the `off...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_dashscope_embedding.py
Add docstrings that explain logic
# -*- coding: utf-8 -*- import mimetypes import uuid from typing import Literal, TYPE_CHECKING from .._logging import logger from ._formatter_base import FormatterBase from ..message import ( Msg, TextBlock, URLSource, Base64Source, ContentBlock, ) if TYPE_CHECKING: from a2a.types import ( ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The A2A message formatter class.""" import mimetypes import uuid from typing import Literal, TYPE_CHECKING @@ -28,8 +29,26 @@ class A2AChatFormatter(FormatterBase): + """A2A message formatter class, which convert AgentScope messages into + A2A message for...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_a2a_formatter.py
Auto-generate documentation strings for this file
# -*- coding: utf-8 -*- from ._exception_base import AgentOrientedExceptionBase class ToolNotFoundError(AgentOrientedExceptionBase): class ToolInterruptedError(AgentOrientedExceptionBase): class ToolInvalidArgumentsError(AgentOrientedExceptionBase):
--- +++ @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- +"""The tool-related exceptions in agentscope.""" from ._exception_base import AgentOrientedExceptionBase class ToolNotFoundError(AgentOrientedExceptionBase): + """Exception raised when a tool was not found.""" class ToolInterruptedError(AgentOrientedExc...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/exception/_tool.py
Add docstrings to incomplete code
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches from typing import Any from ._truncated_formatter_base import TruncatedFormatterBase from .._logging import logger from ..message import Msg, TextBlock, ImageBlock, ToolUseBlock, ToolResultBlock from ..token import TokenCounterBase class AnthropicChatForma...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""The Anthropic formatter module.""" from typing import Any @@ -10,6 +11,10 @@ class AnthropicChatFormatter(TruncatedFormatterBase): + """The Anthropic formatter class for chatbot scenario, where only a user + and an a...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_anthropic_formatter.py
Help me comply with documentation standards
# -*- coding: utf-8 -*- from abc import ABC, abstractmethod from dataclasses import dataclass, field from enum import Enum from typing import Any from .._utils._common import _get_timestamp from .._utils._mixin import DictMixin from ..types import JSONSerializableObject @dataclass class MetricResult(DictMixin): ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The base class for _metric in evaluation.""" from abc import ABC, abstractmethod from dataclasses import dataclass, field @@ -12,6 +13,7 @@ @dataclass class MetricResult(DictMixin): + """The result of a _metric.""" name: str """The metric name.""...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/evaluate/_metric_base.py
Add missing documentation to my Python functions
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches import json import os.path from typing import Any from ._truncated_formatter_base import TruncatedFormatterBase from .._logging import logger from .._utils._common import _is_accessible_local_file from ..message import ( Msg, TextBlock, ImageBloc...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""The dashscope formatter module.""" import json import os.path @@ -24,6 +25,21 @@ def _format_dashscope_media_block( block: ImageBlock | AudioBlock, ) -> dict[str, str]: + """Format an image or audio block for DashScope...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_dashscope_formatter.py
Add docstrings to improve collaboration
# -*- coding: utf-8 -*- class AgentOrientedExceptionBase(Exception): def __init__(self, message: str): super().__init__(message) self.message = message def __str__(self) -> str: return f"{self.__class__.__name__}: {self.message}"
--- +++ @@ -1,11 +1,18 @@ # -*- coding: utf-8 -*- +"""The base exception class in agentscope.""" class AgentOrientedExceptionBase(Exception): + """The base class for all agent-oriented exceptions. These exceptions are + expect to the captured and exposed to the agent during runtime, so that + agents can h...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/exception/_exception_base.py
Add missing documentation to my Python functions
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches import json from typing import Any from ._truncated_formatter_base import TruncatedFormatterBase from .._logging import logger from ..message import Msg, TextBlock, ToolUseBlock, ToolResultBlock from ..token import TokenCounterBase class DeepSeekChatFormatt...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""The DeepSeek formatter module.""" import json from typing import Any @@ -10,6 +11,10 @@ class DeepSeekChatFormatter(TruncatedFormatterBase): + """The DeepSeek formatter class for chatbot scenario, where only a user + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_deepseek_formatter.py
Add docstrings explaining edge cases
# -*- coding: utf-8 -*- import asyncio import json import fakeredis from sqlalchemy.ext.asyncio import create_async_engine from agentscope.memory import ( InMemoryMemory, AsyncSQLAlchemyMemory, RedisMemory, ) from agentscope.message import Msg # %% # In-Memory Memory # ~~~~~~~~~~~~~~~~~~~~~~~~ # # The i...
--- +++ @@ -1,4 +1,83 @@ # -*- coding: utf-8 -*- +""" +.. _memory: + +Memory +======================== + +The memory module in AgentScope is responsible for + +- storing the messages and +- managing them with specific marks +in different storage implementations. + +The **mark** is a string label associated with each me...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/docs/tutorial/en/src/task_memory.py
Document this module using docstrings
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches import base64 import os from typing import Any from urllib.parse import urlparse from ._truncated_formatter_base import TruncatedFormatterBase from .._logging import logger from .._utils._common import _get_bytes_from_web_url from ..message import ( Msg, ...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""The Ollama formatter module.""" import base64 import os from typing import Any @@ -22,6 +23,20 @@ def _format_ollama_image_block( image_block: ImageBlock, ) -> str: + """Format an image block for Ollama API. + + Args...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_ollama_formatter.py
Generate documentation strings for clarity
# -*- coding: utf-8 -*- import collections import json from abc import abstractmethod from dataclasses import asdict from typing import Callable, Coroutine, Any from collections import defaultdict from .._solution import SolutionOutput from .._task import Task from .._benchmark_base import BenchmarkBase from .._evalua...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The base class for evaluator in evaluation.""" import collections import json from abc import abstractmethod @@ -15,6 +16,7 @@ class EvaluatorBase: + """The class that runs the evaluation process.""" def __init__( self, @@ -23,6 +25,21 @@ ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/evaluate/_evaluator/_evaluator_base.py
Add docstrings to improve readability
# -*- coding: utf-8 -*- import inspect from copy import deepcopy from functools import wraps from typing import ( Any, Dict, TYPE_CHECKING, Callable, ) from .._utils._common import _execute_async_or_sync_func if TYPE_CHECKING: from ._agent_base import AgentBase else: AgentBase = "AgentBase" ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The metaclass for agents in agentscope.""" import inspect from copy import deepcopy from functools import wraps @@ -23,6 +24,8 @@ *args: Any, **kwargs: Any, ) -> dict: + """Normalize the provided positional and keyword arguments into a + keyword arg...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_agent_meta.py
Write docstrings for this repository
# -*- coding: utf-8 -*- from abc import ABC from copy import deepcopy from typing import ( Any, Tuple, Literal, AsyncGenerator, ) from ._formatter_base import FormatterBase from ..message import Msg from ..token import TokenCounterBase from ..tracing import trace_format class TruncatedFormatterBase(F...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The truncated formatter base class, which allows to truncate the input +messages.""" from abc import ABC from copy import deepcopy from typing import ( @@ -15,12 +17,26 @@ class TruncatedFormatterBase(FormatterBase, ABC): + """Base class for truncated format...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_truncated_formatter_base.py
Add verbose docstrings with examples
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches, too-many-nested-blocks import base64 import json import os from typing import Any from urllib.parse import urlparse import requests from ._truncated_formatter_base import TruncatedFormatterBase from .._logging import logger from ..message import ( Msg, ...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches, too-many-nested-blocks +"""The OpenAI formatter for agentscope.""" import base64 import json import os @@ -26,6 +27,20 @@ def _format_openai_image_block( image_block: ImageBlock, ) -> dict[str, Any]: + """Format an image b...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_openai_formatter.py
Help me write clear docstrings
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches import base64 import os from typing import Any from urllib.parse import urlparse from ._truncated_formatter_base import TruncatedFormatterBase from .._utils._common import _get_bytes_from_web_url from ..message import ( Msg, TextBlock, ImageBlock,...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""Google gemini API formatter in agentscope.""" import base64 import os from typing import Any @@ -24,6 +25,20 @@ def _format_gemini_media_block( media_block: ImageBlock | AudioBlock | VideoBlock, ) -> dict[str, Any]: + "...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_gemini_formatter.py
Document classes and their methods
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import Callable, List import mcp.types from .._logging import logger from ..message import ( ImageBlock, Base64Source, AudioBlock, TextBlock, VideoBlock, ) class MCPClientBase: def __init__(self, name: str) -> None: ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The base class for MCP clients in AgentScope.""" from abc import abstractmethod from typing import Callable, List @@ -15,8 +16,16 @@ class MCPClientBase: + """Base class for MCP clients.""" def __init__(self, name: str) -> None: + """Initializ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_client_base.py
Provide clean and structured docstrings
# -*- coding: utf-8 -*- from functools import partial from ._studio_hooks import ( as_studio_forward_message_pre_print_hook, ) from .. import _config from ..agent import AgentBase __all__ = [ "as_studio_forward_message_pre_print_hook", ] def _equip_as_studio_hooks( studio_url: str, ) -> None: Agent...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The built-in hook functions in agentscope.""" from functools import partial from ._studio_hooks import ( @@ -16,6 +17,7 @@ def _equip_as_studio_hooks( studio_url: str, ) -> None: + """Connect to the agentscope studio.""" AgentBase.register_class_hook...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/hooks/__init__.py
Document this script properly
# -*- coding: utf-8 -*- from contextlib import _AsyncGeneratorContextManager from datetime import timedelta from typing import Any, Callable import mcp from mcp import ClientSession from ._client_base import MCPClientBase from .._utils._common import _extract_json_schema_from_mcp_tool from ..tool import ToolResponse ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The MCP tool function class in AgentScope.""" from contextlib import _AsyncGeneratorContextManager from datetime import timedelta from typing import Any, Callable @@ -12,6 +13,7 @@ class MCPToolFunction: + """An MCP tool function class that can be called dir...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_mcp_function.py
Write docstrings that follow conventions
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import Any, List, Tuple, Sequence from .._utils._common import _save_base64_data from ..message import Msg, AudioBlock, ImageBlock, TextBlock, VideoBlock class FormatterBase: @abstractmethod async def format(self, *args: Any, **kwargs: Any)...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The formatter module.""" from abc import abstractmethod from typing import Any, List, Tuple, Sequence @@ -8,12 +9,21 @@ class FormatterBase: + """The base class for formatters.""" @abstractmethod async def format(self, *args: Any, **kwargs: Any)...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/formatter/_formatter_base.py
Insert docstrings into my code
# -*- coding: utf-8 -*- from typing import Any import requests import shortuuid from ..agent import AgentBase, UserAgent from .._logging import logger def as_studio_forward_message_pre_print_hook( self: AgentBase, kwargs: dict[str, Any], studio_url: str, run_id: str, ) -> None: msg = kwargs["ms...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The studio related hook functions in agentscope.""" from typing import Any import requests @@ -14,6 +15,7 @@ studio_url: str, run_id: str, ) -> None: + """The pre-speak hook to forward messages to the studio.""" msg = kwargs["msg"] @@ -53,4 +...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/hooks/_studio_hooks.py
Generate docstrings with parameter types
# -*- coding: utf-8 -*- import asyncio import atexit import threading from typing import Any, Coroutine, Dict, List, Literal from mem0.configs.embeddings.base import BaseEmbedderConfig from mem0.configs.llms.base import BaseLlmConfig from mem0.embeddings.base import EmbeddingBase from mem0.llms.base import LLMBase fr...
--- +++ @@ -1,4 +1,9 @@ # -*- coding: utf-8 -*- +"""Utility classes for integrating AgentScope with mem0 library. + +This module provides wrapper classes that allow AgentScope models to be used +with the mem0 library for long-term memory functionality. +""" import asyncio import atexit import threading @@ -14,10 +19...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_mem0/_mem0_utils.py
Insert docstrings into my code
# -*- coding: utf-8 -*- from abc import ABC from contextlib import AsyncExitStack from typing import List import mcp from mcp import ClientSession from ._client_base import MCPClientBase from ._mcp_function import MCPToolFunction from .._logging import logger class StatefulClientBase(MCPClientBase, ABC): is_co...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The base MCP stateful client class in AgentScope, that provides basic + functionality for stateful MCP clients.""" from abc import ABC from contextlib import AsyncExitStack from typing import List @@ -12,11 +14,24 @@ class StatefulClientBase(MCPClientBase, ABC)...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_stateful_client_base.py
Fill in missing docstrings in my code
# -*- coding: utf-8 -*- from contextlib import _AsyncGeneratorContextManager from typing import Any, Callable, Awaitable, Literal, List import mcp.types from mcp import ClientSession from mcp.client.sse import sse_client from mcp.client.streamable_http import streamablehttp_client from . import MCPToolFunction from ....
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The MCP streamable HTTP server.""" from contextlib import _AsyncGeneratorContextManager from typing import Any, Callable, Awaitable, Literal, List @@ -13,6 +14,13 @@ class HttpStatelessClient(MCPClientBase): + """The sse/streamable HTTP MCP client implement...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_http_stateless_client.py
Add docstrings to improve code quality
# -*- coding: utf-8 -*- from typing import TYPE_CHECKING from urllib.parse import urlparse from ._base import AgentCardResolverBase from .._logging import logger if TYPE_CHECKING: from a2a.types import AgentCard else: AgentCard = "a2a.types.AgentCard" class WellKnownAgentCardResolver(AgentCardResolverBase):...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The A2A well-known agent card resolver.""" from typing import TYPE_CHECKING from urllib.parse import urlparse @@ -12,16 +13,32 @@ class WellKnownAgentCardResolver(AgentCardResolverBase): + """Agent card resolver that loads AgentCard from a well-known URL.""...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/a2a/_well_known_resolver.py
Add docstrings including usage examples
# -*- coding: utf-8 -*- from typing import Literal from mcp import stdio_client, StdioServerParameters from ._stateful_client_base import StatefulClientBase class StdIOStatefulClient(StatefulClientBase): def __init__( self, name: str, command: str, args: list[str] | None = None,...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The StdIO MCP server implementation in AgentScope, which provides +function-level fine-grained control over the MCP servers using standard IO.""" from typing import Literal from mcp import stdio_client, StdioServerParameters @@ -7,6 +9,24 @@ class StdIOStatefu...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_stdio_stateful_client.py
Add docstrings that explain logic
# -*- coding: utf-8 -*- from abc import ABCMeta from typing import Any from .._long_term_memory_base import LongTermMemoryBase from ....embedding import DashScopeTextEmbedding, OpenAITextEmbedding from ....model import DashScopeChatModel, OpenAIChatModel class ReMeLongTermMemoryBase(LongTermMemoryBase, metaclass=ABC...
--- +++ @@ -1,4 +1,71 @@ # -*- coding: utf-8 -*- +"""Base long-term memory implementation using ReMe library. + +This module provides a base class for long-term memory implementations +that integrate with the ReMe library. ReMe enables agents to maintain +persistent, searchable memories across sessions and contexts. + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_reme/_reme_long_term_memory_base.py
Document my Python code with docstrings
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import Any from ...message import Msg from ...module import StateModule class MemoryBase(StateModule): def __init__(self) -> None: super().__init__() self._compressed_summary: str = "" self.register_state("_compressed_...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The memory base class.""" from abc import abstractmethod from typing import Any @@ -8,8 +9,10 @@ class MemoryBase(StateModule): + """The base class for memory in agentscope.""" def __init__(self) -> None: + """Initialize the memory base.""" ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_working_memory/_base.py
Create simple docstrings for beginners
# -*- coding: utf-8 -*- from typing import Any from ._reme_long_term_memory_base import ReMeLongTermMemoryBase from ...._logging import logger from ....message import Msg, TextBlock from ....tool import ToolResponse class ReMeTaskLongTermMemory(ReMeLongTermMemoryBase): async def record_to_memory( self, ...
--- +++ @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*- +"""Task memory implementation using ReMe library. + +This module provides a task memory implementation that integrates +with the ReMe library to learn from execution trajectories and +retrieve relevant task experiences. + +""" from typing import Any from ._reme_long...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_reme/_reme_task_long_term_memory.py
Write beginner-friendly docstrings
# -*- coding: utf-8 -*- from copy import deepcopy from typing import Any from ...message import Msg from ._base import MemoryBase class InMemoryMemory(MemoryBase): def __init__(self) -> None: super().__init__() # Use a list of tuples to store messages along with their marks self.content:...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The in-memory storage module for memory storage.""" from copy import deepcopy from typing import Any @@ -7,8 +8,10 @@ class InMemoryMemory(MemoryBase): + """The in-memory implementation of memory storage.""" def __init__(self) -> None: + """In...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_working_memory/_in_memory_memory.py
Generate helpful docstrings for debugging
# -*- coding: utf-8 -*- import asyncio from asyncio import Queue import shortuuid from .._logging import logger from .._utils._common import _resample_pcm_delta from ..message import ( AudioBlock, Base64Source, TextBlock, ImageBlock, ToolUseBlock, ToolResultBlock, ) from ..module import StateM...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The realtime agent class.""" import asyncio from asyncio import Queue @@ -25,6 +26,41 @@ class RealtimeAgent(StateModule): + """The realtime agent class. Different from the `AgentBase` class, + this class is designed for real-time interaction scenarios, ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_realtime_agent.py
Write documentation strings for class attributes
# -*- coding: utf-8 -*- from typing import Any from ._reme_long_term_memory_base import ReMeLongTermMemoryBase from ...._logging import logger from ....message import Msg, TextBlock from ....tool import ToolResponse class ReMePersonalLongTermMemory(ReMeLongTermMemoryBase): async def record_to_memory( se...
--- +++ @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*- +"""Personal memory implementation using ReMe library. + +This module provides a personal memory implementation that integrates +with the ReMe library to provide persistent personal memory storage and +retrieval capabilities for AgentScope agents. + +""" from typing imp...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_reme/_reme_personal_long_term_memory.py
Generate docstrings with examples
# -*- coding: utf-8 -*- from typing import Any from sqlalchemy import ( Column, String, JSON, BigInteger, ForeignKey, select, delete, update, func, ) from sqlalchemy.ext.asyncio import ( AsyncEngine, AsyncSession, async_sessionmaker, ) from sqlalchemy.orm import declarat...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The SQLAlchemy database storage module, which supports storing messages in +a SQL database using SQLAlchemy ORM (e.g., SQLite, PostgreSQL, MySQL).""" from typing import Any from sqlalchemy import ( @@ -26,8 +28,19 @@ class AsyncSQLAlchemyMemory(MemoryBase): + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_working_memory/_sqlalchemy_memory.py
Add verbose docstrings with examples
# -*- coding: utf-8 -*- import json from typing import Any, TYPE_CHECKING from ._base import MemoryBase from ...message import Msg if TYPE_CHECKING: from redis.asyncio import ConnectionPool, Redis else: ConnectionPool = Any Redis = Any class RedisMemory(MemoryBase): SESSION_KEY = "user_id:{user_id}...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The redis based memory storage implementation.""" import json from typing import Any, TYPE_CHECKING @@ -13,6 +14,31 @@ class RedisMemory(MemoryBase): + """Redis memory storage implementation, which supports session and user + context. + + .. note:: Al...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_working_memory/_redis_memory.py
Add minimal docstrings for each function
# -*- coding: utf-8 -*- from abc import abstractmethod from collections import OrderedDict from typing import Callable, Any from ._agent_base import AgentBase from ._agent_meta import _ReActAgentMeta from ..message import Msg class ReActAgentBase(AgentBase, metaclass=_ReActAgentMeta): supported_hook_types: list...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The base class for ReAct agent in agentscope.""" from abc import abstractmethod from collections import OrderedDict from typing import Callable, Any @@ -9,6 +10,13 @@ class ReActAgentBase(AgentBase, metaclass=_ReActAgentMeta): + """The ReAct agent base class...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_react_agent_base.py
Write clean docstrings for readability
# -*- coding: utf-8 -*- from datetime import datetime from typing import Literal, List, overload, Sequence import shortuuid from ._message_block import ( TextBlock, ToolUseBlock, ImageBlock, AudioBlock, ContentBlock, VideoBlock, ToolResultBlock, ContentBlockTypes, ) from ..types import...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The message class in agentscope.""" from datetime import datetime from typing import Literal, List, overload, Sequence @@ -18,6 +19,7 @@ class Msg: + """The message class in agentscope.""" def __init__( self, @@ -28,6 +30,24 @@ times...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/message/_message_base.py
Add docstrings to meet PEP guidelines
# -*- coding: utf-8 -*- import asyncio import json from typing import Any, TYPE_CHECKING from importlib import metadata from pydantic import field_validator from ....embedding import EmbeddingModelBase from .._long_term_memory_base import LongTermMemoryBase from ....message import Msg, TextBlock from ....model import...
--- +++ @@ -1,4 +1,10 @@ # -*- coding: utf-8 -*- +"""Long-term memory implementation using mem0 library. + +This module provides a long-term memory implementation that integrates +with the mem0 library to provide persistent memory storage and retrieval +capabilities for AgentScope agents. +""" import asyncio import j...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_mem0/_mem0_long_term_memory.py
Add missing documentation to my Python functions
# -*- coding: utf-8 -*- from typing import Type, Any from pydantic import BaseModel from ._agent_base import AgentBase from ._user_input import UserInputBase, TerminalUserInput from ..message import Msg class UserAgent(AgentBase): _input_method: UserInputBase = TerminalUserInput() """The user input method,...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The user agent class.""" from typing import Type, Any from pydantic import BaseModel @@ -9,6 +10,9 @@ class UserAgent(AgentBase): + """The class for user interaction, allowing developers to handle the user + input from different sources, such as web UI, ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_user_agent.py
Add docstrings for better understanding
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches, too-many-statements import copy import json import warnings from datetime import datetime from typing import ( Any, AsyncGenerator, TYPE_CHECKING, List, Literal, Type, ) from collections import OrderedDict from pydantic import BaseMod...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches, too-many-statements +"""The Anthropic API model classes.""" import copy import json import warnings @@ -37,6 +38,7 @@ class AnthropicChatModel(ChatModelBase): + """The Anthropic model wrapper for AgentScope.""" def __...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_anthropic_model.py
Fill in missing docstrings in my code
# -*- coding: utf-8 -*- # mypy: disable-error-code="dict-item" import base64 import copy import warnings from datetime import datetime import json from typing import ( AsyncGenerator, Any, TYPE_CHECKING, AsyncIterator, Literal, Type, List, ) from pydantic import BaseModel from .._logging i...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # mypy: disable-error-code="dict-item" +"""The Google Gemini model in agentscope.""" import base64 import copy import warnings @@ -33,6 +34,22 @@ def _flatten_json_schema(schema: dict) -> dict: + """Flatten a JSON schema by resolving all $ref references. + + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_gemini_model.py
Write docstrings that follow conventions
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import AsyncGenerator, Any from ._model_response import ChatResponse _TOOL_CHOICE_MODES = ["auto", "none", "required"] class ChatModelBase: model_name: str """The model name""" stream: bool """Is the model output streaming or not...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The chat model base class.""" from abc import abstractmethod from typing import AsyncGenerator, Any @@ -10,6 +11,7 @@ class ChatModelBase: + """Base class for chat models.""" model_name: str """The model name""" @@ -22,6 +24,14 @@ model_...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_model_base.py
Create docstrings for all classes and functions
# -*- coding: utf-8 -*- import json.decoder import time from abc import abstractmethod from dataclasses import dataclass from queue import Queue from threading import Event from typing import Any, Type, List import jsonschema import requests import shortuuid import socketio from pydantic import BaseModel import json5 ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The user input related classes.""" import json.decoder import time from abc import abstractmethod @@ -26,6 +27,7 @@ @dataclass class UserInputData: + """The user input data.""" blocks_input: List[TextBlock | ImageBlock | AudioBlock | VideoBlock] = None...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_user_input.py
Create documentation for each function signature
# -*- coding: utf-8 -*- from dataclasses import dataclass, field from typing import Literal, Any from .._utils._mixin import DictMixin @dataclass class ChatUsage(DictMixin): input_tokens: int """The number of input tokens.""" output_tokens: int """The number of output tokens.""" time: float ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The model usage class in agentscope.""" from dataclasses import dataclass, field from typing import Literal, Any @@ -7,6 +8,7 @@ @dataclass class ChatUsage(DictMixin): + """The usage of a chat model API invocation.""" input_tokens: int """The num...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_model_usage.py
Add docstrings explaining edge cases
# -*- coding: utf-8 -*- import json from datetime import datetime from typing import ( Any, TYPE_CHECKING, List, AsyncGenerator, AsyncIterator, Literal, Type, ) from collections import OrderedDict from pydantic import BaseModel from . import ChatResponse from ._model_base import ChatModelB...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Model wrapper for Ollama models.""" import json from datetime import datetime from typing import ( @@ -30,6 +31,7 @@ class OllamaChatModel(ChatModelBase): + """The Ollama chat model class in agentscope.""" def __init__( self, @@ -43,6 +45,37 ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_ollama_model.py
Document this script properly
# -*- coding: utf-8 -*- # pylint: disable=too-many-branches import copy import json import warnings from datetime import datetime from typing import ( Any, TYPE_CHECKING, List, AsyncGenerator, Literal, Type, ) from collections import OrderedDict from pydantic import BaseModel from . import Cha...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=too-many-branches +"""OpenAI Chat model class.""" import copy import json import warnings @@ -40,6 +41,16 @@ def _format_audio_data_for_qwen_omni(messages: list[dict]) -> None: + """Qwen-omni uses OpenAI-compatible API but requires different a...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_openai_model.py
Add concise docstrings to each method
# -*- coding: utf-8 -*- # TODO: simplify the ReActAgent class # pylint: disable=not-an-iterable, too-many-lines # mypy: disable-error-code="list-item" import asyncio from enum import Enum from typing import Type, Any, AsyncGenerator, Literal from pydantic import BaseModel, ValidationError, Field from ._utils import _...
--- +++ @@ -2,6 +2,7 @@ # TODO: simplify the ReActAgent class # pylint: disable=not-an-iterable, too-many-lines # mypy: disable-error-code="list-item" +"""ReAct agent class in agentscope.""" import asyncio from enum import Enum from typing import Type, Any, AsyncGenerator, Literal @@ -30,6 +31,7 @@ class _Quer...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/agent/_react_agent.py
Add documentation for all methods
# -*- coding: utf-8 -*- from collections.abc import Sequence from typing import Any import shortuuid from .._logging import logger from ..agent import AgentBase from ..message import Msg class MsgHub: def __init__( self, participants: Sequence[AgentBase], announcement: list[Msg] | Msg ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""MsgHub is designed to share messages among a group of agents.""" from collections.abc import Sequence from typing import Any @@ -11,6 +12,32 @@ class MsgHub: + """MsgHub class that controls the subscription of the participated agents. + + Example: + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/pipeline/_msghub.py
Can you add docstrings to this Python file?
# -*- coding: utf-8 -*- from typing import ( Optional, TYPE_CHECKING, ) from typing_extensions import deprecated from ._openai_model import OpenAIChatModel from ..types import JSONSerializableObject if TYPE_CHECKING: from openai import AsyncOpenAI else: AsyncOpenAI = "openai.AsyncOpenAI" @deprecated...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""A model class for RL Training with Trinity-RFT.""" from typing import ( Optional, TYPE_CHECKING, @@ -18,6 +19,7 @@ "TrinityChatModel is deprecated. Please use OpenAIChatModel directly.", ) class TrinityChatModel(OpenAIChatModel): + """A model class...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_trinity_model.py
Generate docstrings for script automation
# -*- coding: utf-8 -*- from typing import Literal import shortuuid from pydantic import BaseModel, Field from .._utils._common import _get_timestamp class SubTask(BaseModel): name: str = Field( description=( "The subtask name, should be concise, descriptive and not" "exceed 10 ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The models used in the plan module.""" from typing import Literal import shortuuid @@ -8,6 +9,7 @@ class SubTask(BaseModel): + """The subtask model used in the plan module.""" name: str = Field( description=( @@ -48,11 +50,13 @@ ) ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/plan/_plan_model.py
Generate docstrings with parameter types
# -*- coding: utf-8 -*- from abc import abstractmethod from agentscope.module import StateModule from agentscope.plan._plan_model import Plan class PlanStorageBase(StateModule): @abstractmethod async def add_plan(self, plan: Plan) -> None: @abstractmethod async def delete_plan(self, plan_id: str) -...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The base class for plan storage.""" from abc import abstractmethod from agentscope.module import StateModule @@ -6,15 +7,20 @@ class PlanStorageBase(StateModule): + """The base class for plan storage.""" @abstractmethod async def add_plan(self, ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/plan/_storage_base.py
Please document this code using docstrings
# -*- coding: utf-8 -*- from collections import OrderedDict from ._plan_model import Plan from ._storage_base import PlanStorageBase class InMemoryPlanStorage(PlanStorageBase): def __init__(self) -> None: super().__init__() self.plans = OrderedDict() # Support historical plan serializat...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The in-memory plan storage class.""" from collections import OrderedDict from ._plan_model import Plan @@ -6,8 +7,10 @@ class InMemoryPlanStorage(PlanStorageBase): + """In-memory plan storage.""" def __init__(self) -> None: + """Initialize the...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/plan/_in_memory_storage.py
Write docstrings that follow conventions
# -*- coding: utf-8 -*- from typing import Any from ._functional import sequential_pipeline, fanout_pipeline from ..agent import AgentBase from ..message import Msg class SequentialPipeline: def __init__( self, agents: list[AgentBase], ) -> None: self.agents = agents async def _...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Pipeline classes.""" from typing import Any from ._functional import sequential_pipeline, fanout_pipeline @@ -7,17 +8,32 @@ class SequentialPipeline: + """An async sequential pipeline class, which executes a sequence of + agents sequentially. Compared wi...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/pipeline/_class.py
Add docstrings that explain inputs and outputs
# -*- coding: utf-8 -*- import asyncio from copy import deepcopy from typing import Any, AsyncGenerator, Tuple, Coroutine from ..agent import AgentBase from ..message import Msg, AudioBlock async def sequential_pipeline( agents: list[AgentBase], msg: Msg | list[Msg] | None = None, ) -> Msg | list[Msg] | None:...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Functional counterpart for Pipeline""" import asyncio from copy import deepcopy from typing import Any, AsyncGenerator, Tuple, Coroutine @@ -10,6 +11,34 @@ agents: list[AgentBase], msg: Msg | list[Msg] | None = None, ) -> Msg | list[Msg] | None: + """A...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/pipeline/_functional.py
Document functions with detailed explanations
# -*- coding: utf-8 -*- import asyncio from asyncio import Queue from ..agent import RealtimeAgent from ..realtime import ClientEvents, ServerEvents class ChatRoom: def __init__(self, agents: list[RealtimeAgent]) -> None: self.agents = agents # The queue used to gather messages from all agents ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The Voice chat room""" import asyncio from asyncio import Queue @@ -7,8 +8,17 @@ class ChatRoom: + """The chat room abstraction to broadcast messages among multiple realtime + agents, and handle the messages from the frontend. + """ def __init_...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/pipeline/_chat_room.py
Add docstrings for utility scripts
# -*- coding: utf-8 -*- from dataclasses import dataclass, field from typing import Literal from .._utils._mixin import DictMixin @dataclass class EmbeddingUsage(DictMixin): time: float """The time used in seconds.""" tokens: int | None = field(default_factory=lambda: None) """The number of tokens ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The embedding usage class in agentscope.""" from dataclasses import dataclass, field from typing import Literal @@ -7,6 +8,7 @@ @dataclass class EmbeddingUsage(DictMixin): + """The usage of an embedding model API invocation.""" time: float """The...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_embedding_usage.py
Generate descriptive docstrings automatically
# -*- coding: utf-8 -*- import json def _get_media_type_from_data(data: bytes) -> str: # Image signature mapping signatures = { b"\x89PNG\r\n\x1a\n": "image/png", b"\xff\xd8": "image/jpeg", b"GIF87a": "image/gif", b"GIF89a": "image/gif", b"BM": "image/bmp", } #...
--- +++ @@ -1,8 +1,19 @@ # -*- coding: utf-8 -*- +"""Utility functions for RAG readers.""" import json def _get_media_type_from_data(data: bytes) -> str: + """Determine media type from image data. + + Args: + data (`bytes`): + The raw image data. + + Returns: + `str`: + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_utils.py
Document this code for team use
# -*- coding: utf-8 -*- import hashlib import os from typing import Literal from ._reader_base import ReaderBase, Document from .._document import DocMetadata from ..._logging import logger from ...message import TextBlock class TextReader(ReaderBase): def __init__( self, chunk_size: int = 512, ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The text reader that reads text into vector records.""" import hashlib import os from typing import Literal @@ -10,12 +11,25 @@ class TextReader(ReaderBase): + """The text reader that splits text into chunks by a fixed chunk size + and chunk overlap.""" ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_text_reader.py
Create documentation for each function signature
# -*- coding: utf-8 -*- from collections import OrderedDict from typing import Callable, Literal, Coroutine, Any, Awaitable from ._in_memory_storage import InMemoryPlanStorage from ._plan_model import SubTask, Plan from ._storage_base import PlanStorageBase from .._utils._common import _execute_async_or_sync_func from...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The plan notebook class, used to manage the plan, providing hints and +tool functions to the agent.""" from collections import OrderedDict from typing import Callable, Literal, Coroutine, Any, Awaitable @@ -12,6 +14,8 @@ class DefaultPlanToHint: + """The de...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/plan/_plan_notebook.py
Create structured documentation for my script
# -*- coding: utf-8 -*- import base64 import hashlib from typing import Any, Literal from ._reader_base import ReaderBase from ._text_reader import TextReader from ._utils import ( _get_media_type_from_data, _table_to_json, _table_to_markdown, ) from .._document import Document, DocMetadata from ...message...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The PowerPoint reader to read and chunk PowerPoint presentations.""" import base64 import hashlib from typing import Any, Literal @@ -16,6 +17,17 @@ def _extract_table_data(table: Any) -> list[list[str]]: + """Extract table data from a PowerPoint table. + + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_ppt_reader.py
Write docstrings for data processing functions
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import Any from ._reader import Document from ..embedding import EmbeddingModelBase from ._store import VDBStoreBase from ..message import TextBlock from ..tool import ToolResponse class KnowledgeBase: embedding_store: VDBStoreBase """The em...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The knowledge base abstraction for retrieval-augmented generation (RAG).""" from abc import abstractmethod from typing import Any @@ -10,6 +11,13 @@ class KnowledgeBase: + """The knowledge base abstraction for retrieval-augmented generation + (RAG). + + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_knowledge_base.py
Add docstrings for internal functions
# -*- coding: utf-8 -*- import hashlib from .. import DocMetadata from ...message import ImageBlock, URLSource from .._reader import ReaderBase, Document class ImageReader(ReaderBase): async def __call__(self, image_url: str | list[str]) -> list[Document]: # Read the image data and wrap it into a Docume...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The Image reader modules""" import hashlib from .. import DocMetadata @@ -7,8 +8,22 @@ class ImageReader(ReaderBase): + """A simple image reader that wraps the image into a Document object. + + This class is only a simple implementation to support multim...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_image_reader.py
Add docstrings explaining edge cases
# -*- coding: utf-8 -*- from typing import Any from ._reader import Document from ..message import TextBlock from ._knowledge_base import KnowledgeBase class SimpleKnowledge(KnowledgeBase): async def retrieve( self, query: str, limit: int = 5, score_threshold: float | None = None...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""A general implementation of the knowledge class in AgentScope RAG module.""" from typing import Any from ._reader import Document @@ -7,6 +8,7 @@ class SimpleKnowledge(KnowledgeBase): + """A simple knowledge base implementation.""" async def retrieve...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_simple_knowledge.py
Create docstrings for each class method
# -*- coding: utf-8 -*- import hashlib from typing import Literal from ._reader_base import ReaderBase from ._text_reader import TextReader from .._document import Document class PDFReader(ReaderBase): def __init__( self, chunk_size: int = 512, split_by: Literal["char", "sentence", "para...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The PDF reader to read and chunk PDF files.""" import hashlib from typing import Literal @@ -8,12 +9,24 @@ class PDFReader(ReaderBase): + """The PDF reader that splits text into chunks by a fixed chunk size.""" def __init__( self, c...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_pdf_reader.py
Help me document legacy Python code
# -*- coding: utf-8 -*- import json from typing import Any, Literal, TYPE_CHECKING from .._reader import Document from ._store_base import VDBStoreBase from .._document import DocMetadata from ..._utils._common import _map_text_to_uuid from ...types import Embedding if TYPE_CHECKING: from mysql.connector import ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The AlibabaCloud MySQL vector store implementation.""" import json from typing import Any, Literal, TYPE_CHECKING @@ -16,6 +17,22 @@ class AlibabaCloudMySQLStore(VDBStoreBase): + """The AlibabaCloud MySQL vector store implementation, supporting vector + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_store/_alibabacloud_mysql_store.py
Create documentation strings for testing functions
# -*- coding: utf-8 -*- from datetime import datetime from typing import List, Any from ._embedding_response import EmbeddingResponse from ._embedding_usage import EmbeddingUsage from ._cache_base import EmbeddingCacheBase from ..embedding import EmbeddingModelBase from ..message import TextBlock class OllamaTextEmb...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The ollama text embedding model class.""" from datetime import datetime from typing import List, Any @@ -10,6 +11,7 @@ class OllamaTextEmbedding(EmbeddingModelBase): + """The Ollama embedding model.""" supported_modalities: list[str] = ["text"] ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_ollama_embedding.py
Add return value explanations in docstrings
# -*- coding: utf-8 -*- # pylint: disable=W0212 import base64 import hashlib from typing import Literal, TYPE_CHECKING from ._reader_base import ReaderBase from ._text_reader import TextReader from ._utils import _table_to_json, _table_to_markdown from .._document import Document, DocMetadata from ..._logging import ...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=W0212 +"""The Word reader to read and chunk Word documents.""" import base64 import hashlib from typing import Literal, TYPE_CHECKING @@ -26,6 +27,17 @@ def _extract_text_from_paragraph(para: DocxParagraph) -> str: + """Extract text from a par...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_reader/_word_reader.py
Document this script properly
# -*- coding: utf-8 -*- import asyncio import json from typing import Any, Callable, Literal, TYPE_CHECKING from .._reader import Document from ._store_base import VDBStoreBase from .._document import DocMetadata from ..._utils._common import _map_text_to_uuid from ...message import TextBlock from ...types import Embe...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The OceanBase vector store implementation.""" import asyncio import json from typing import Any, Callable, Literal, TYPE_CHECKING @@ -35,6 +36,8 @@ class OceanBaseStore(VDBStoreBase): + """The OceanBase vector store implementation, supporting OceanBase and +...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_store/_oceanbase_store.py
Add docstrings for better understanding
# -*- coding: utf-8 -*- import json from typing import Any, Literal, TYPE_CHECKING from .._reader import Document from ._store_base import VDBStoreBase from .._document import DocMetadata from ..._utils._common import _map_text_to_uuid from ...types import Embedding if TYPE_CHECKING: from pymilvus import MilvusC...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The Milvus Lite vector store implementation.""" import json from typing import Any, Literal, TYPE_CHECKING @@ -16,6 +17,16 @@ class MilvusLiteStore(VDBStoreBase): + """The Milvus Lite vector store implementation, supporting both local and + remote Milvus...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_store/_milvuslite_store.py
Help me document legacy Python code
# -*- coding: utf-8 -*- import hashlib import json import os from typing import Any, List import numpy as np from ._cache_base import EmbeddingCacheBase from .._logging import logger from ..types import ( Embedding, JSONSerializableObject, ) class FileEmbeddingCache(EmbeddingCacheBase): def __init__( ...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""A file embedding cache implementation for storing and retrieving +embeddings in binary files.""" import hashlib import json import os @@ -15,6 +17,8 @@ class FileEmbeddingCache(EmbeddingCacheBase): + """The embedding cache class that stores each embeddings v...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_file_cache.py
Write proper docstrings for these functions
# -*- coding: utf-8 -*- import json from typing import Literal, Any import shortuuid from ._events import ModelEvents from ._base import RealtimeModelBase from .._logging import logger from .._utils._common import _get_bytes_from_web_url from ..message import AudioBlock, TextBlock, ImageBlock, ToolResultBlock class...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The dashscope realtime model class.""" import json from typing import Literal, Any @@ -12,6 +13,12 @@ class DashScopeRealtimeModel(RealtimeModelBase): + """The DashScope realtime model class. + + TODO: + - Support non-VAD mode + - Support update ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/realtime/_dashscope_realtime_model.py
Add docstrings to my Python code
# -*- coding: utf-8 -*- from datetime import datetime from typing import Any, List from ._embedding_response import EmbeddingResponse from ._embedding_usage import EmbeddingUsage from ._cache_base import EmbeddingCacheBase from ._embedding_base import EmbeddingModelBase from ..message import TextBlock class GeminiTe...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The gemini text embedding model class.""" from datetime import datetime from typing import Any, List @@ -10,6 +11,7 @@ class GeminiTextEmbedding(EmbeddingModelBase): + """The Gemini text embedding model.""" supported_modalities: list[str] = ["text"] ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_gemini_embedding.py
Add docstrings for better understanding
# -*- coding: utf-8 -*- import asyncio import time from typing import Any, Literal, TYPE_CHECKING from .._reader import Document from ._store_base import VDBStoreBase from .._document import DocMetadata from ...types import Embedding if TYPE_CHECKING: from pymongo import AsyncMongoClient else: AsyncMongoClie...
--- +++ @@ -1,4 +1,10 @@ # -*- coding: utf-8 -*- +"""The MongoDB vector store implementation using MongoDB Vector Search. + +This implementation provides a vector database store using MongoDB's vector + search capabilities. It requires MongoDB with vector search support and + automatically creates vector search indexes...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/rag/_store/_mongodb_store.py
Improve documentation using docstrings
# -*- coding: utf-8 -*- from datetime import datetime from typing import Any, List from ._embedding_response import EmbeddingResponse from ._embedding_usage import EmbeddingUsage from ._cache_base import EmbeddingCacheBase from ._embedding_base import EmbeddingModelBase from ..message import TextBlock class OpenAITe...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The OpenAI text embedding model class.""" from datetime import datetime from typing import Any, List @@ -10,6 +11,7 @@ class OpenAITextEmbedding(EmbeddingModelBase): + """OpenAI text embedding model class.""" supported_modalities: list[str] = ["text"...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/embedding/_openai_embedding.py
Fully document this Python code with docstrings
# -*- coding: utf-8 -*- import asyncio import json from abc import abstractmethod from asyncio import Queue from typing import Any from ._events import ModelEvents from ..message import AudioBlock, TextBlock, ImageBlock, ToolResultBlock class RealtimeModelBase: model_name: str """The model name""" supp...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The realtime model base class.""" import asyncio import json from abc import abstractmethod @@ -10,6 +11,7 @@ class RealtimeModelBase: + """The realtime model base class.""" model_name: str """The model name""" @@ -33,6 +35,12 @@ self, ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/realtime/_base.py
Auto-generate documentation strings for this file
# -*- coding: utf-8 -*- import json from typing import Literal, Any import shortuuid from ._events import ModelEvents from ._base import RealtimeModelBase from .._logging import logger from .._utils._common import _get_bytes_from_web_url from ..message import ( AudioBlock, ImageBlock, TextBlock, ToolR...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The Gemini realtime model class.""" import json from typing import Literal, Any @@ -18,6 +19,7 @@ class GeminiRealtimeModel(RealtimeModelBase): + """The Gemini realtime model class.""" support_input_modalities: list[str] = [ "audio", @@ -52,...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/realtime/_gemini_realtime_model.py
Add detailed documentation for each class
# -*- coding: utf-8 -*- from typing import Any from agentscope.token._token_base import TokenCounterBase class GeminiTokenCounter(TokenCounterBase): def __init__(self, model_name: str, api_key: str, **kwargs: Any) -> None: from google import genai self.client = genai.Client( api_key...
--- +++ @@ -1,12 +1,25 @@ # -*- coding: utf-8 -*- +"""The gemini token counter class in agentscope.""" from typing import Any from agentscope.token._token_base import TokenCounterBase class GeminiTokenCounter(TokenCounterBase): + """The Gemini token counter class.""" def __init__(self, model_name: st...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/token/_gemini_token_counter.py
Add documentation for all methods
# -*- coding: utf-8 -*- from datetime import datetime from ._shared_state import SharedState class ReminderApi(SharedState): tool_functions: list[str] = [ "view_reminder_by_title", "add_reminder", "delete_reminder", "view_all_reminders", "mark_as_notified", "searc...
--- +++ @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- +"""The reminder API in ACEBench simulation tools.""" from datetime import datetime from ._shared_state import SharedState class ReminderApi(SharedState): + """The reminder Api in the ACEBench evaluation.""" tool_functions: list[str] = [ "vie...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/evaluate/_ace_benchmark/_ace_tools_api/_reminder_api.py
Help me comply with documentation standards
# -*- coding: utf-8 -*- import json import os import aiofiles from ._session_base import SessionBase from .._logging import logger from ..module import StateModule class JSONSession(SessionBase): def __init__( self, save_dir: str = "./", ) -> None: self.save_dir = save_dir def _...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The JSON session class.""" import json import os import aiofiles @@ -9,14 +10,33 @@ class JSONSession(SessionBase): + """The JSON session class.""" def __init__( self, save_dir: str = "./", ) -> None: + """Initialize the ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/session/_json_session.py
Fully document this Python code with docstrings
# -*- coding: utf-8 -*- from abc import abstractmethod from typing import Any class TokenCounterBase: @abstractmethod async def count( self, messages: list[dict], **kwargs: Any, ) -> int:
--- +++ @@ -1,13 +1,16 @@ # -*- coding: utf-8 -*- +"""The token base class in agentscope.""" from abc import abstractmethod from typing import Any class TokenCounterBase: + """The base class for token counting.""" @abstractmethod async def count( self, messages: list[dict], ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/token/_token_base.py
Add minimal docstrings for each function
# -*- coding: utf-8 -*- from typing import Any from ._token_base import TokenCounterBase class AnthropicTokenCounter(TokenCounterBase): def __init__(self, model_name: str, api_key: str, **kwargs: Any) -> None: import anthropic self.client = anthropic.AsyncAnthropic(api_key=api_key, **kwargs) ...
--- +++ @@ -1,11 +1,21 @@ # -*- coding: utf-8 -*- +"""The Anthropic token counter class.""" from typing import Any from ._token_base import TokenCounterBase class AnthropicTokenCounter(TokenCounterBase): + """The Anthropic token counter class.""" def __init__(self, model_name: str, api_key: str, **kwar...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/token/_anthropic_token_counter.py
Insert docstrings into my code
# -*- coding: utf-8 -*- from typing import Any from ._token_base import TokenCounterBase class CharTokenCounter(TokenCounterBase): async def count( self, messages: list[dict], tools: list[dict] | None = None, **kwargs: Any, ) -> int: texts = [] for msg in mess...
--- +++ @@ -1,10 +1,18 @@ # -*- coding: utf-8 -*- +"""A simple character-based token counter implementation.""" from typing import Any from ._token_base import TokenCounterBase class CharTokenCounter(TokenCounterBase): + """A very simple implementation that counts tokens based on character + length. + + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/token/_char_token_counter.py
Add docstrings including usage examples
# -*- coding: utf-8 -*- import json from typing import Literal, Any from ._events import ModelEvents from ._base import RealtimeModelBase from .._logging import logger from .._utils._common import _get_bytes_from_web_url, _json_loads_with_repair from ..message import ( AudioBlock, TextBlock, ImageBlock, ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The OpenAI realtime model class.""" import json from typing import Literal, Any @@ -16,6 +17,7 @@ class OpenAIRealtimeModel(RealtimeModelBase): + """The OpenAI realtime model class.""" support_input_modalities: list[str] = ["audio", "text", "tool_res...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/realtime/_openai_realtime_model.py
Add docstrings including usage examples
# -*- coding: utf-8 -*- from enum import Enum from typing import List from pydantic import BaseModel from ._utils import AudioFormat from ...message import TextBlock, AudioBlock, ImageBlock, VideoBlock class ClientEventType(str, Enum): # ============== Session control ================ CLIENT_SESSION_CREATE...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The client events for web-to-backend communication.""" from enum import Enum from typing import List @@ -9,6 +10,7 @@ class ClientEventType(str, Enum): + """Types of client events for web-to-backend communication.""" # ============== Session control ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/realtime/_events/_client_event.py
Generate missing documentation strings
# -*- coding: utf-8 -*- from typing import Any from agentscope.message import Msg from agentscope.module import StateModule from agentscope.tool import ToolResponse class LongTermMemoryBase(StateModule): async def record( self, msgs: list[Msg | None], **kwargs: Any, ) -> Any: ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The long-term memory base class.""" from typing import Any @@ -8,12 +9,25 @@ class LongTermMemoryBase(StateModule): + """The long-term memory base class, which should be a time-series + memory management system. + + The `record_to_memory` and `retrie...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/memory/_long_term_memory/_long_term_memory_base.py
Create structured documentation for my script
# -*- coding: utf-8 -*- import asyncio from typing import AsyncGenerator, Generator, Callable, Awaitable from ._response import ToolResponse from ..message import TextBlock from .._utils._common import _execute_async_or_sync_func async def _postprocess_tool_response( tool_response: ToolResponse, postprocess_...
--- +++ @@ -1,4 +1,10 @@ # -*- coding: utf-8 -*- +"""The functions that wrap object, sync generator, and async generator +into async generators. + +TODO: handle the exception raised when yielding from async generator + into a normal ToolResponse instance. +""" import asyncio from typing import AsyncGenerator, Generat...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_async_wrapper.py
Provide docstrings following PEP 257
# -*- coding: utf-8 -*- import base64 import io import json import math from http import HTTPStatus from typing import Any import requests from ._token_base import TokenCounterBase def _calculate_tokens_for_high_quality_image( base_tokens: int, tile_tokens: int, width: int, height: int, ) -> int: ...
--- +++ @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +"""The OpenAI token counting class. The token calculation of vision models +follows +https://platform.openai.com/docs/guides/images-vision?api-mode=chat#calculating-costs +""" import base64 import io import json @@ -17,6 +21,9 @@ width: int, height: int, ) -...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/token/_openai_token_counter.py
Create documentation strings for testing functions
# -*- coding: utf-8 -*- # pylint: disable=unused-argument import asyncio import os import sys import tempfile from typing import Any import shortuuid from ...message import TextBlock from .._response import ToolResponse async def execute_python_code( code: str, timeout: float = 300, **kwargs: Any, ) ->...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=unused-argument +"""The Python code execution tool in agentscope.""" import asyncio import os @@ -18,6 +19,21 @@ timeout: float = 300, **kwargs: Any, ) -> ToolResponse: + """Execute the given python code in a temp file and capture the r...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_coding/_python.py
Improve documentation using docstrings
# -*- coding: utf-8 -*- import base64 from typing import Literal, Sequence import os from ..._utils._common import _get_bytes_from_web_url from ...message import ImageBlock, TextBlock, AudioBlock from ...tool import ToolResponse def dashscope_text_to_image( prompt: str, api_key: str, n: int = 1, si...
--- +++ @@ -1,4 +1,9 @@ # -*- coding: utf-8 -*- +"""Use DashScope API to generate images, +convert text to audio, and convert images to text. +Please refer to the `official documentation <https://dashscope.aliyun.com/>`_ + for more details. +""" import base64 from typing import Literal, Sequence @@ -18,6 +23,31 @@ ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_multi_modality/_dashscope_tools.py
Create docstrings for each class method
# -*- coding: utf-8 -*- class SharedState: def __init__(self, shared_state: dict) -> None: self._shared_state = shared_state @property def wifi(self) -> bool: return self._shared_state["wifi"] @property def logged_in(self) -> bool: return self._shared_state["logged_in"]
--- +++ @@ -1,15 +1,20 @@ # -*- coding: utf-8 -*- +"""The shared state class for ACEBench simulation tools.""" class SharedState: + """The sharing state class for ACEBench simulation tools.""" def __init__(self, shared_state: dict) -> None: + """Initialize the shared state""" self._shared...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/evaluate/_ace_benchmark/_ace_tools_api/_shared_state.py
Add docstrings to incomplete code
# -*- coding: utf-8 -*- from typing import Any, Literal from mcp.client.sse import sse_client from mcp.client.streamable_http import streamablehttp_client from ._stateful_client_base import StatefulClientBase class HttpStatefulClient(StatefulClientBase): def __init__( self, name: str, t...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The MCP stateful HTTP client module in AgentScope.""" from typing import Any, Literal from mcp.client.sse import sse_client @@ -8,6 +9,24 @@ class HttpStatefulClient(StatefulClientBase): + """The stateful sse/streamable HTTP MCP client implementation in + ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/mcp/_http_stateful_client.py
Annotate my code with docstrings
# -*- coding: utf-8 -*- # pylint: disable=too-many-lines import asyncio import inspect import os from copy import deepcopy from functools import partial, wraps from typing import ( AsyncGenerator, Literal, Any, Type, Generator, Callable, Awaitable, Coroutine, ) import mcp import shortuu...
--- +++ @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +"""The toolkit class for tool calls in agentscope. + +TODO: We should consider to split this `Toolkit` class in the future. +""" # pylint: disable=too-many-lines import asyncio import inspect @@ -56,12 +60,21 @@ Coroutine[Any, Any, AsyncGenerator[ToolResponse,...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_toolkit.py
Document my Python code with docstrings
# -*- coding: utf-8 -*- import base64 from io import BytesIO import os from typing import Literal, IO import requests from .. import ToolResponse from ...formatter._openai_formatter import _to_openai_image_url from ...message import ( ImageBlock, TextBlock, Base64Source, URLSource, AudioBlock, ) ...
--- +++ @@ -1,4 +1,9 @@ # -*- coding: utf-8 -*- +""" +Wrap OpenAI API calls as tools. Refer the official +`OpenAI API documentation <https://platform.openai.com/docs/overview>`_ for +more details. +""" import base64 from io import BytesIO import os @@ -17,6 +22,10 @@ def _parse_url(url: str) -> BytesIO | IO[byte...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_multi_modality/_openai_tools.py
Add structured docstrings to improve clarity
# -*- coding: utf-8 -*- import base64 from typing import Any, Literal, AsyncGenerator from ._tts_base import TTSModelBase from ._tts_response import TTSResponse from ._utils import _get_cosyvoice_callback_class from ..message import Msg, AudioBlock, Base64Source from ..types import JSONSerializableObject class Dash...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""DashScope CosyVoice TTS model implementation.""" import base64 from typing import Any, Literal, AsyncGenerator @@ -11,6 +12,16 @@ class DashScopeCosyVoiceTTSModel(TTSModelBase): + """TTS implementation for DashScope CosyVoice TTS API. + The supported mod...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tts/_dashscope_cosyvoice_tts_model.py
Add docstrings to improve collaboration
# -*- coding: utf-8 -*- from typing import TYPE_CHECKING if TYPE_CHECKING: from opentelemetry.trace import Tracer else: Tracer = "Tracer" def setup_tracing(endpoint: str) -> None: # Lazy import from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemet...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The tracing interface class in agentscope.""" from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -8,6 +9,12 @@ def setup_tracing(endpoint: str) -> None: + """Set up the AgentScope tracing by configuring the endpoint URL. + + Args: + endpoint (`...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tracing/_setup.py
Generate NumPy-style docstrings
# -*- coding: utf-8 -*- from copy import deepcopy from dataclasses import dataclass, field from typing import TypedDict, Literal, Type, Callable, Awaitable from pydantic import BaseModel from . import ToolResponse from .._utils._common import _remove_title_field from ..message import ToolUseBlock from ..types import ...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The types for the tool module in AgentScope.""" from copy import deepcopy from dataclasses import dataclass, field from typing import TypedDict, Literal, Type, Callable, Awaitable @@ -13,6 +14,7 @@ @dataclass class RegisteredToolFunction: + """The registered ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_types.py
Add docstrings with type hints explained
# -*- coding: utf-8 -*- import copy import collections import json import os import warnings from datetime import datetime from http import HTTPStatus from typing import ( Any, AsyncGenerator, Generator, Union, TYPE_CHECKING, List, Literal, Type, ) from pydantic import BaseModel from aio...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""The dashscope API model classes.""" import copy import collections import json @@ -47,6 +48,26 @@ class DashScopeChatModel(ChatModelBase): + """The DashScope chat model class, which unifies the Generation and + MultimodalConversation APIs into one method....
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/model/_dashscope_model.py
Can you add docstrings to this Python file?
# -*- coding: utf-8 -*- import inspect from functools import wraps from typing import ( Generator, AsyncGenerator, Callable, Any, Coroutine, TypeVar, TYPE_CHECKING, ) import aioitertools from .. import _config from ..embedding import EmbeddingModelBase, EmbeddingResponse from .._logging im...
--- +++ @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +"""The tracing decorators for agent, formatter, toolkit, chat and embedding +models.""" import inspect from functools import wraps from typing import ( @@ -65,10 +67,22 @@ def _check_tracing_enabled() -> bool: + """Check if the OpenTelemetry tracer is initializ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tracing/_trace.py
Write docstrings for data processing functions
# -*- coding: utf-8 -*- # pylint: disable=unused-argument import asyncio from typing import Any from .._response import ToolResponse from ...message import TextBlock async def execute_shell_command( command: str, timeout: int = 300, **kwargs: Any, ) -> ToolResponse: proc = await asyncio.create_subp...
--- +++ @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # pylint: disable=unused-argument +"""The shell command tool in agentscope.""" import asyncio from typing import Any @@ -13,6 +14,21 @@ timeout: int = 300, **kwargs: Any, ) -> ToolResponse: + """Execute given command and return the return code, standard ...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_coding/_shell.py
Expand my code with proper documentation strings
# -*- coding: utf-8 -*- # flake8: noqa: E501 # pylint: disable=line-too-long import os from ._utils import _calculate_view_ranges, _view_text_file from .._response import ToolResponse from ...message import TextBlock async def insert_text_file( file_path: str, content: str, line_number: int, ) -> ToolRes...
--- +++ @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # flake8: noqa: E501 # pylint: disable=line-too-long +"""The text file tools in agentscope.""" import os from ._utils import _calculate_view_ranges, _view_text_file @@ -13,6 +14,22 @@ content: str, line_number: int, ) -> ToolResponse: + """Insert the co...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tool/_text_file/_write_text_file.py
Add structured docstrings to improve clarity
# -*- coding: utf-8 -*- from typing import Any, Literal, AsyncGenerator from ._tts_base import TTSModelBase from ._tts_response import TTSResponse from ._utils import _get_cosyvoice_callback_class from ..message import Msg from ..types import JSONSerializableObject class DashScopeCosyVoiceRealtimeTTSModel(TTSModelB...
--- +++ @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""DashScope CosyVoice Realtime TTS model implementation.""" from typing import Any, Literal, AsyncGenerator @@ -10,6 +11,19 @@ class DashScopeCosyVoiceRealtimeTTSModel(TTSModelBase): + """TTS implementation for DashScope CosyVoice Realtime TTS API, + whic...
https://raw.githubusercontent.com/agentscope-ai/agentscope/HEAD/src/agentscope/tts/_dashscope_cosyvoice_realtime_tts_model.py