repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
agentscope | src/agentscope/types/_object.py | .py | # -*- coding: utf-8 -*-
"""The object types in agentscope."""
from typing import List
Embedding = List[float]
| 6 | 111 |
agentscope | src/agentscope/types/_json.py | .py | # -*- coding: utf-8 -*-
"""The JSON related types"""
from typing import TypeAlias
JSONPrimitive: TypeAlias = str | int | float | bool | None
JSONSerializableObject: TypeAlias = (
JSONPrimitive
| list["JSONSerializableObject"]
| dict[
str,
"JSONSerializableObject",
]
)
| 15 | 303 |
agentscope | src/agentscope/embedding/__init__.py | .py | # -*- coding: utf-8 -*-
"""The embedding module in agentscope."""
from ._embedding_base import EmbeddingModelBase
from ._embedding_model_card import EmbeddingModelCard
from ._embedding_usage import EmbeddingUsage
from ._embedding_response import EmbeddingResponse
from ._dashscope import DashScopeEmbeddingModel
from ._... | 28 | 809 |
agentscope | src/agentscope/embedding/_embedding_usage.py | .py | # -*- coding: utf-8 -*-
"""The embedding usage class in agentscope."""
from dataclasses import dataclass, field
from typing import Literal
from .._utils._mixin import DictMixin
@dataclass
class EmbeddingUsage(DictMixin):
"""The usage of an embedding model API invocation."""
time: float
"""The time used ... | 21 | 579 |
agentscope | src/agentscope/embedding/_embedding_response.py | .py | # -*- coding: utf-8 -*-
"""The embedding response class."""
from dataclasses import dataclass, field
from typing import Literal, List
from ._embedding_usage import EmbeddingUsage
from .._utils._common import _get_timestamp
from .._utils._mixin import DictMixin
from ..types import Embedding
@dataclass
class Embedding... | 33 | 1,093 |
agentscope | src/agentscope/embedding/_file_cache.py | .py | # -*- coding: utf-8 -*-
"""A file embedding cache implementation for storing and retrieving
embeddings in binary files."""
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,... | 188 | 7,126 |
agentscope | src/agentscope/embedding/_embedding_base.py | .py | # -*- coding: utf-8 -*-
"""The embedding model base class."""
from __future__ import annotations
import asyncio
import inspect
from abc import abstractmethod
from pathlib import Path
from typing import Any, Generic, TypeVar, Type, Union
from pydantic import BaseModel, ConfigDict
from ._embedding_model_card import Em... | 450 | 16,991 |
agentscope | src/agentscope/embedding/_cache_base.py | .py | # -*- coding: utf-8 -*-
"""The embedding cache base class."""
from abc import abstractmethod
from typing import List, Any
from ..types import (
JSONSerializableObject,
Embedding,
)
class EmbeddingCacheBase:
"""Base class for embedding caches, which is responsible for storing and
retrieving embeddings... | 64 | 1,800 |
agentscope | src/agentscope/embedding/_embedding_model_card.py | .py | # -*- coding: utf-8 -*-
"""The embedding model card class."""
from __future__ import annotations
import copy
from typing import Literal, Self, Type
import yaml
from pydantic import BaseModel, Field
class EmbeddingModelCard(BaseModel):
"""A card describing an embedding model's capabilities.
Mirrors :class:`... | 180 | 6,195 |
agentscope | src/agentscope/embedding/_gemini/__init__.py | .py | # -*- coding: utf-8 -*-
"""The Gemini embedding API modules."""
from ._model import GeminiEmbeddingModel
__all__ = [
"GeminiEmbeddingModel",
]
| 9 | 149 |
agentscope | src/agentscope/embedding/_gemini/_model.py | .py | # -*- coding: utf-8 -*-
"""The Google Gemini embedding model.
Handles both text-only and multimodal models under a single class.
``gemini-embedding-001`` accepts ``list[str | TextBlock]``.
``gemini-embedding-2`` additionally accepts
:class:`~agentscope.message.DataBlock` (images, video, audio, PDF).
The model name det... | 486 | 16,346 |
agentscope | src/agentscope/embedding/_openai/__init__.py | .py | # -*- coding: utf-8 -*-
"""The OpenAI embedding API modules."""
from ._model import OpenAIEmbeddingModel
__all__ = [
"OpenAIEmbeddingModel",
]
| 9 | 149 |
agentscope | src/agentscope/embedding/_openai/_model.py | .py | # -*- coding: utf-8 -*-
"""The OpenAI embedding model."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Type
from .._embedding_response import EmbeddingResponse
from .._embedding_usage import EmbeddingUsage
from .._cache_base import EmbeddingCacheBase
from .._embedding_base ... | 180 | 6,512 |
agentscope | src/agentscope/embedding/_dashscope/__init__.py | .py | # -*- coding: utf-8 -*-
"""The DashScope embedding API modules."""
from ._model import DashScopeEmbeddingModel
__all__ = [
"DashScopeEmbeddingModel",
]
| 9 | 158 |
agentscope | src/agentscope/embedding/_dashscope/_model.py | .py | # -*- coding: utf-8 -*-
"""The DashScope embedding model.
Handles both text-only and multimodal models under a single class.
Text models (``text-embedding-v3``, ``text-embedding-v4``) accept
``list[str | TextBlock]``. Multimodal models (``qwen*-vl-embedding``,
``multimodal-embedding-*``, ``tongyi-embedding-vision-*``... | 530 | 18,114 |
agentscope | src/agentscope/embedding/_ollama/__init__.py | .py | # -*- coding: utf-8 -*-
"""The Ollama embedding API modules."""
from ._model import OllamaEmbeddingModel
__all__ = [
"OllamaEmbeddingModel",
]
| 9 | 149 |
agentscope | src/agentscope/embedding/_ollama/_model.py | .py | # -*- coding: utf-8 -*-
"""The Ollama embedding model."""
from datetime import datetime
from typing import Any
from .._embedding_response import EmbeddingResponse
from .._embedding_usage import EmbeddingUsage
from .._cache_base import EmbeddingCacheBase
from .._embedding_base import EmbeddingModelBase
from ...credent... | 133 | 4,681 |
agentscope | src/agentscope/agent/_utils.py | .py | # -*- coding: utf-8 -*-
"""The utility classes used in building the agent class."""
from dataclasses import dataclass
from typing import Literal
from datetime import timezone, tzinfo
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from pydantic import BaseModel
from ..tool import ToolChoice
from ..message import ... | 59 | 1,687 |
agentscope | src/agentscope/agent/_agent.py | .py | # -*- coding: utf-8 -*-
"""The unified agent class in AgentScope library."""
import asyncio
import collections
import inspect
import re
import warnings
from asyncio import Queue
from copy import deepcopy
from fnmatch import fnmatch
from datetime import datetime
from typing import (
Any,
AsyncGenerator,
Seq... | 3,464 | 136,765 |
agentscope | src/agentscope/agent/_config.py | .py | # -*- coding: utf-8 -*-
"""The agent config classes."""
from pydantic import BaseModel, Field, field_validator
from ..model import ChatModelBase
class SummarySchema(BaseModel):
"""The compressed memory model, used to generate summary of old memories"""
task_overview: str = Field(
description=(
... | 363 | 13,890 |
agentscope | src/agentscope/agent/__init__.py | .py | # -*- coding: utf-8 -*-
"""Initialize the agent module."""
from ._agent import Agent
from ._config import ContextConfig, InjectionConfig, ModelConfig, ReActConfig
__all__ = [
"Agent",
"ContextConfig",
"InjectionConfig",
"ModelConfig",
"ReActConfig",
]
| 13 | 273 |
agentscope | src/agentscope/agent/_structured_output_tool.py | .py | # -*- coding: utf-8 -*-
"""The builtin tool used to generate the required structured output."""
from copy import deepcopy
from typing import Any, Generator, List, Type
from jsonschema import Draft202012Validator, validators
from pydantic import BaseModel, ValidationError
from ..permission._context import PermissionCo... | 166 | 6,160 |
agentscope | src/agentscope/_utils/_audio.py | .py | # -*- coding: utf-8 -*-
"""Audio utilities shared across model providers."""
import struct
def _build_streaming_wav_header(
sample_rate: int = 24000,
channels: int = 1,
bits_per_sample: int = 16,
) -> bytes:
"""Build a 44-byte WAV/RIFF header for streaming PCM.
The RIFF and ``data`` chunk sizes a... | 43 | 1,345 |
agentscope | src/agentscope/_utils/_mixin.py | .py | # -*- coding: utf-8 -*-
"""The mixin for agentscope."""
class DictMixin(dict):
"""The dictionary mixin that allows attribute-style access."""
__setattr__ = dict.__setitem__
__getattr__ = dict.__getitem__
| 10 | 219 |
agentscope | src/agentscope/_utils/_common.py | .py | # -*- coding: utf-8 -*-
"""The common utilities for agentscope library."""
import asyncio
import base64
import copy
import functools
import inspect
import json
import os
import types
import uuid
from datetime import datetime
from typing import Any, Callable
from .._logging import logger
from ..exception import ToolJSO... | 390 | 12,066 |
agentscope | src/agentscope/app/__init__.py | .py | # -*- coding: utf-8 -*-
"""The FastAPI based agent service module, which contains all service-related
components and a configurable FastAPI app factory.
"""
from ._app import create_app
from ._types import SubAgentTemplate
__all__ = [
"create_app",
"SubAgentTemplate",
]
| 13 | 281 |
agentscope | src/agentscope/app/_app.py | .py | # -*- coding: utf-8 -*-
"""AgentScope app factory."""
import secrets
from typing import Type, TYPE_CHECKING, Any
from ._lifespan import lifespan
from .access import DenyAllResourceAccessPolicy, ResourceAccessPolicyBase
from .hub import HubBase, HubError, MCPHubBase, SkillHubBase
from .rag.blob_store import BlobStoreBa... | 378 | 16,869 |
agentscope | src/agentscope/app/_bus_ops.py | .py | # -*- coding: utf-8 -*-
"""Business-level operations built on top of MessageBus primitives.
These helpers compose generic bus primitives (``log_append``, ``publish``,
``queue_push``) with domain-specific key layouts from ``MessageBusKeys``.
They live here β between the transport layer (``message_bus``) and the
service... | 412 | 13,907 |
agentscope | src/agentscope/app/deps.py | .py | # -*- coding: utf-8 -*-
"""Shared FastAPI dependencies for the agentscope app."""
from fastapi import Header, HTTPException, Request, status
from .workspace_manager import WorkspaceManagerBase
from .channel import (
ChannelLifecycleDispatcher,
ChannelTypeRegistry,
)
from ._manager import (
BackgroundTaskMa... | 419 | 11,925 |
agentscope | src/agentscope/app/_types.py | .py | # -*- coding: utf-8 -*-
"""Shared type aliases for the agentscope app layer."""
from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING, Protocol
from pydantic import BaseModel, Field
from ..agent import ContextConfig, ReActConfig
from ..event import AgentEvent
from ..middleware import Middle... | 196 | 7,424 |
agentscope | src/agentscope/app/_lifespan.py | .py | # -*- coding: utf-8 -*-
"""The lifespan of the agent service."""
import socket
import uuid
from contextlib import AsyncExitStack, asynccontextmanager
from typing import TYPE_CHECKING, Any, AsyncIterator
from ._manager import (
BackgroundTaskManager,
CancelDispatcher,
ChatRunRegistry,
SchedulerManager,
... | 253 | 10,239 |
agentscope | src/agentscope/app/access/__init__.py | .py | # -*- coding: utf-8 -*-
"""Public resource access policy extension points.
Import from this package when customizing cross-owner resource access:
.. code-block:: python
from agentscope.app.access import (
ResourceAccessPolicyBase,
ResourceKind,
ResourcePermission,
ResourceRef,
... | 31 | 622 |
agentscope | src/agentscope/app/access/_policy.py | .py | # -*- coding: utf-8 -*-
"""Resource access policy primitives for cross-owner resource reads.
This module defines the extension point used by the app service layer to
decide whether a viewer can access resources owned by another user. The
default policy denies all cross-owner access, preserving the historical
owner-iso... | 164 | 5,327 |
agentscope | src/agentscope/app/storage/_utils.py | .py | # -*- coding: utf-8 -*-
"""The utils for storage."""
from typing import TYPE_CHECKING
from pydantic import BaseModel, SecretStr
from ._model import TeamMember
if TYPE_CHECKING:
from ._base import StorageBase
from ._model import TeamRecord
def _dump_with_secrets(model: BaseModel) -> dict:
"""Dump the Ba... | 108 | 3,790 |
agentscope | src/agentscope/app/storage/_base.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-public-methods
"""The storage base class."""
from abc import ABC, abstractmethod
from datetime import datetime, timedelta
from typing import Any, Self
from ._model import (
AgentRecord,
ChannelRecord,
CredentialRecord,
KnowledgeBaseRecord,
Knowled... | 1,259 | 38,817 |
agentscope | src/agentscope/app/storage/_redis_storage.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-public-methods
"""The Redis storage implementation."""
import warnings
from datetime import datetime, timedelta
from typing import Any, TYPE_CHECKING, Self
from pydantic import BaseModel
from ._base import StorageBase
from ._model import (
AgentRecord,
Chann... | 2,318 | 82,331 |
agentscope | src/agentscope/app/storage/__init__.py | .py | # -*- coding: utf-8 -*-
"""The storage module in agentscope."""
from typing import TYPE_CHECKING
from ._base import StorageBase
from ._redis_storage import RedisStorage
from ._model import (
AgentData,
AgentRecord,
ChannelBinding,
ChannelRecord,
RoutingConfig,
SessionScope,
SessionSettings,... | 103 | 2,684 |
agentscope | src/agentscope/app/storage/_model/_schedule.py | .py | # -*- coding: utf-8 -*-
"""The schedule storage model."""
from datetime import datetime
from enum import Enum
from pydantic import BaseModel, Field
from ._base import _RecordBase
from ._session import ChatModelConfig
from ....permission import PermissionMode
class ScheduleSource(str, Enum):
"""The source that c... | 118 | 3,152 |
agentscope | src/agentscope/app/storage/_model/_agent.py | .py | # -*- coding: utf-8 -*-
"""The agent storage class."""
from typing import Literal, Self
from pydantic import Field, BaseModel, model_validator
from pydantic.json_schema import SkipJsonSchema
from ...._utils._common import _generate_id
from ._base import _RecordBase
from ....agent import ContextConfig, ReActConfig
c... | 131 | 4,475 |
agentscope | src/agentscope/app/storage/_model/_base.py | .py | # -*- coding: utf-8 -*-
"""The base attributes used in storage."""
from datetime import datetime
from pydantic import BaseModel, Field
from ...._utils._common import _generate_id
class _RecordBase(BaseModel):
"""The base class for all records."""
id: str = Field(
default_factory=_generate_id,
... | 27 | 596 |
agentscope | src/agentscope/app/storage/_model/_channel.py | .py | # -*- coding: utf-8 -*-
"""The channel storage model. Key points:
- Routing is one concept: an ordered list of :class:`ChannelBinding`.
Each rule matches an inbound event and yields two outputs β which
agent handles it and how the session is grouped.
- ``(agent_id, session_id)`` is derived by a pure function (see
... | 182 | 6,252 |
agentscope | src/agentscope/app/storage/_model/_user.py | .py | # -*- coding: utf-8 -*-
"""The user record for storage."""
from ._base import _RecordBase
class UserRecord(_RecordBase):
"""The user record."""
| 9 | 151 |
agentscope | src/agentscope/app/storage/_model/__init__.py | .py | # -*- coding: utf-8 -*-
"""Storage models for persisted resources."""
from ._agent import AgentRecord, AgentData, InviteConfig
from ._channel import (
ChannelBinding,
ChannelRecord,
RoutingConfig,
SessionScope,
SessionSettings,
)
from ._credential import CredentialRecord
from ._knowledge_base impor... | 66 | 1,552 |
agentscope | src/agentscope/app/storage/_model/_knowledge_document.py | .py | # -*- coding: utf-8 -*-
"""The knowledge document record.
A :class:`KnowledgeDocumentRecord` is the canonical source of truth
for one uploaded file inside a knowledge base. It owns the document's
**lifecycle** (status, error, lease) and **byte handle** (``blob_uri``)
before any chunks reach the vector store, which is... | 203 | 7,648 |
agentscope | src/agentscope/app/storage/_model/_credential.py | .py | # -*- coding: utf-8 -*-
"""The credential record."""
from pydantic import Field
from ...._utils._common import _generate_id
from ._base import _RecordBase
class CredentialRecord(_RecordBase):
"""The credential model used for storing credentials."""
user_id: str = Field(
default_factory=_generate_id,... | 18 | 374 |
agentscope | src/agentscope/app/storage/_model/_session.py | .py | # -*- coding: utf-8 -*-
"""The session data class for storage."""
from datetime import datetime
from enum import Enum
from pydantic import BaseModel, Field
from ._base import _RecordBase
from ....state import AgentState
class SessionSource(str, Enum):
"""The source that created the session."""
USER = "user... | 218 | 7,101 |
agentscope | src/agentscope/app/storage/_model/_skill.py | .py | # -*- coding: utf-8 -*-
"""The installed-skill record."""
from pydantic import Field
from ._base import _RecordBase
class SkillRecord(_RecordBase):
"""One skill a user has installed, at the user level rather than in
any one workspace β the skill counterpart of :class:`MCPRecord`.
Unlike an MCP, whose wh... | 66 | 2,574 |
agentscope | src/agentscope/app/storage/_model/_mcp.py | .py | # -*- coding: utf-8 -*-
"""The installed-MCP record."""
from pydantic import Field, computed_field
from ._base import _RecordBase
from ....mcp import MCPClient
class MCPRecord(_RecordBase):
"""One MCP a user has installed, at the user level rather than in any
one workspace.
This table is the *desired* s... | 89 | 3,504 |
agentscope | src/agentscope/app/storage/_model/_knowledge_base.py | .py | # -*- coding: utf-8 -*-
"""The knowledge base record."""
from typing import Any
from pydantic import BaseModel, Field, model_validator
from ._base import _RecordBase
from ._session import EmbeddingModelConfig
class KnowledgeBaseData(BaseModel):
"""The mutable payload of a knowledge base record.
Groups ever... | 107 | 4,023 |
agentscope | src/agentscope/app/storage/_model/_team.py | .py | # -*- coding: utf-8 -*-
"""The team storage class."""
from typing import Literal
from pydantic import BaseModel, Field
from ._base import _RecordBase
class TeamMember(BaseModel):
"""An entry in a team's member roster.
Unlike the legacy :attr:`TeamData.member_ids`, this carries both the
agent id AND the... | 123 | 4,386 |
agentscope | src/agentscope/app/storage/_sql/_storage.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-public-methods
"""SQLAlchemy 2.0 async implementation of :class:`StorageBase`.
Talks to any dialect supported by SQLAlchemy's async engine
(SQLite / Postgres / MySQL / β¦) β the caller only picks the URL and
installs the matching driver. All schema and query building ... | 1,855 | 66,343 |
agentscope | src/agentscope/app/storage/_sql/__init__.py | .py | # -*- coding: utf-8 -*-
"""Async SQLAlchemy storage backend.
The only public symbol is :class:`AsyncSQLAlchemyStorage`;
every other module in this package is an implementation detail
(tables, mappers, engine helpers, Alembic scaffolding) named
with a leading underscore so :mod:`agentscope.app.storage`
can re-export it... | 13 | 435 |
agentscope | src/agentscope/app/storage/_sql/_tables.py | .py | # -*- coding: utf-8 -*-
"""SQLAlchemy 2.0 declarative tables backing :class:`AsyncSQLAlchemyStorage`.
Every record type maps to one table with the layout:
- ``id`` primary key + ``created_at`` / ``updated_at`` timestamps;
- one column per relational / indexed field promoted from the
record's top level;
- a single `... | 365 | 10,579 |
agentscope | src/agentscope/app/storage/_sql/_mappers.py | .py | # -*- coding: utf-8 -*-
"""Pydantic ``_RecordBase`` β SQLAlchemy row conversion helpers.
Round-trip contract (the "no duplication" invariant enforced here):
- On write (``_from_record``) the record is dumped once with
``model_dump(mode="json")``, the envelope keys (``id`` /
``created_at`` / ``updated_at``) and ev... | 101 | 3,477 |
agentscope | src/agentscope/app/storage/_sql/_alembic/env.py | .py | # -*- coding: utf-8 -*-
"""Alembic environment for :class:`AsyncSQLAlchemyStorage` schema migrations.
Runs migrations in async mode against a SQLAlchemy URL. The URL is
picked up (in order of precedence) from:
1. the ``sqlalchemy.url`` key of the Alembic config (usually set via
``alembic.ini`` or ``-x url=...``);
... | 90 | 3,073 |
agentscope | src/agentscope/app/storage/_sql/_alembic/versions/0002_mcps_skills.py | .py | # -*- coding: utf-8 -*-
"""Installed-MCP and installed-skill tables.
Revision ID: 0002_mcps_skills
Revises: 0001_initial
Create Date: 2026-08-01 09:34:28.407719
Both tables are new, so there is nothing to backfill β the library has
never been stored on SQL. ``(user_id, name)`` is unique on each because
the workspace ... | 59 | 2,099 |
agentscope | src/agentscope/app/storage/_sql/_alembic/versions/0001_initial.py | .py | # -*- coding: utf-8 -*-
"""Initial schema β frozen snapshot of every table in ``_sql/_tables.py``.
Revision ID: 0001_initial
Revises:
Create Date: 2026-07-20 10:24:57.000000
This revision is a *static snapshot*: the ``op.create_table`` calls are
frozen at the schema as it stood when the SQL backend first shipped.
It ... | 385 | 14,115 |
agentscope | src/agentscope/app/_router/_schedule.py | .py | # -*- coding: utf-8 -*-
"""Schedule router β CRUD endpoints for scheduled agent tasks."""
from datetime import datetime
from fastapi import APIRouter, Depends, HTTPException, status
from ..access import ResourceKind
from .._manager import SchedulerManager
from ..deps import (
get_current_user_id,
get_resource... | 254 | 8,300 |
agentscope | src/agentscope/app/_router/_agent.py | .py | # -*- coding: utf-8 -*-
"""Agent router β CRUD endpoints for agent configurations."""
from datetime import datetime
from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import ValidationError
from ...agent import ContextConfig, ReActConfig
from ..._utils._common import _flatten_json_schema
from... | 319 | 11,415 |
agentscope | src/agentscope/app/_router/_health.py | .py | # -*- coding: utf-8 -*-
"""The health router."""
from fastapi import APIRouter, Depends, Request, Response, status
from ._schema import ComponentStatus, HealthResponse
from ..deps import get_current_user_id
health_router = APIRouter(tags=["health"])
# Attached by ``create_app`` before the server starts serving.
_EA... | 90 | 3,324 |
agentscope | src/agentscope/app/_router/_hub.py | .py | # -*- coding: utf-8 -*-
"""Hub router β browse resource hubs and install from them.
The frontend flow is three levels deep: list the hubs, browse one hub's
cards, then install a chosen card into the caller's library. Cards are
never merged across hubs, which keeps ranking a per-hub concern.
Installing is user-level f... | 309 | 9,346 |
agentscope | src/agentscope/app/_router/_channel.py | .py | # -*- coding: utf-8 -*-
"""Channel HTTP API.
GET /channels/types List channel types + schemas
GET /channels/ List the user's channels
POST /channels/ Create a channel
GET /channels/{id} Channel details
PATCH /channels/{id} ... | 281 | 9,354 |
agentscope | src/agentscope/app/_router/__init__.py | .py | # -*- coding: utf-8 -*-
"""App routers."""
from ._agent import agent_router
from ._channel import channel_router
from ._chat import chat_router
from ._credential import credential_router
from ._embedding_model import embedding_model_router
from ._health import health_router
from ._hub import hub_router
from ._knowledge... | 36 | 958 |
agentscope | src/agentscope/app/_router/_workspace.py | .py | # -*- coding: utf-8 -*-
"""Workspace router β manage MCP clients and skills on a workspace."""
import mimetypes
from urllib.parse import quote
from fastapi import (
APIRouter,
Depends,
File,
Form,
Header,
HTTPException,
Query,
UploadFile,
status,
)
from fastapi.responses import Stre... | 612 | 19,606 |
agentscope | src/agentscope/app/_router/_chat.py | .py | # -*- coding: utf-8 -*-
"""Chat router β fire-and-forget trigger for chat runs.
The endpoint no longer returns an SSE stream. Instead, it kicks off a
chat run as a background task and returns immediately. Events produced
by the run are published to the message bus and delivered to the
frontend via the long-lived ``GET... | 161 | 6,226 |
agentscope | src/agentscope/app/_router/_credential.py | .py | # -*- coding: utf-8 -*-
"""Credential router β CRUD endpoints for API key credentials."""
from fastapi import APIRouter, Depends, status
from ..access import ResourceKind
from ..deps import (
get_current_user_id,
get_resource_access_service,
get_storage,
)
from ._schema import (
CreateCredentialRequest... | 196 | 6,654 |
agentscope | src/agentscope/app/_router/_embedding_model.py | .py | # -*- coding: utf-8 -*-
"""The embedding model router."""
from fastapi import APIRouter, Depends, HTTPException, status
from ._schema import ListEmbeddingModelsResponse, ListEmbeddingModelsRequest
from ...credential import CredentialFactory
embedding_model_router = APIRouter(
prefix="/embedding-model",
tags=... | 51 | 1,800 |
agentscope | src/agentscope/app/_router/_session.py | .py | # -*- coding: utf-8 -*-
"""Session router β create, list, update, delete, stream, and get messages."""
import asyncio
import json
from typing import AsyncGenerator
from fastapi import APIRouter, Depends, HTTPException, Query, status
from fastapi.responses import StreamingResponse
from ..._utils._common import _genera... | 921 | 32,551 |
agentscope | src/agentscope/app/_router/_skill.py | .py | # -*- coding: utf-8 -*-
"""Skill router β the user's own library of installed skills.
The skill counterpart of :mod:`._mcp`: this is the user-level collection
an install lands in, distinct from ``/workspace/skill``, which manages
the skills present in one session's workspace.
"""
from fastapi import APIRouter, Depends... | 63 | 2,111 |
agentscope | src/agentscope/app/_router/_mcp.py | .py | # -*- coding: utf-8 -*-
"""MCP router β the user's own library of installed MCPs.
This is the user-level collection an install lands in, distinct from
``/workspace/mcp``, which manages the MCPs of one session's workspace.
Installing from a hub only writes here; putting an MCP into a workspace
stays a separate, explici... | 127 | 4,375 |
agentscope | src/agentscope/app/_router/_knowledge_base.py | .py | # -*- coding: utf-8 -*-
"""Knowledge base router β manage knowledge bases and their documents.
A knowledge base is the user-facing concept; physically each one maps
to a single vector store collection (in the MVP isolation strategy).
The HTTP layer is intentionally thin β every endpoint translates the
request into a s... | 576 | 20,217 |
agentscope | src/agentscope/app/_router/_tts_model.py | .py | # -*- coding: utf-8 -*-
"""The TTS model router."""
from fastapi import APIRouter, Depends, HTTPException, status
from ._schema import ListTTSModelsResponse, ListTTSModelsRequest
from ...credential import CredentialFactory
tts_model_router = APIRouter(
prefix="/tts-model",
tags=["tts-model"],
responses={... | 41 | 1,195 |
agentscope | src/agentscope/app/_router/_model.py | .py | # -*- coding: utf-8 -*-
"""The model router."""
from fastapi import APIRouter, Depends, HTTPException, status
from ._schema import ListModelsResponse, ListModelsRequest
from ...credential import CredentialFactory
model_router = APIRouter(
prefix="/model",
tags=["model"],
responses={404: {"description": "... | 41 | 1,158 |
agentscope | src/agentscope/app/_router/_schema/_schedule.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the schedule router."""
from pydantic import BaseModel, Field
from ...storage import (
ScheduleRecord,
SessionRecord,
ChatModelConfig,
)
from ....permission import PermissionMode
class CreateScheduleRequest(BaseModel):
"""Request body for crea... | 119 | 3,430 |
agentscope | src/agentscope/app/_router/_schema/_agent.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the agent router."""
import warnings
from pydantic import BaseModel, Field
from ....agent import ContextConfig, ReActConfig
from ...storage import InviteConfig
from ..._service import AgentView
class CreateAgentRequest(BaseModel):
"""Request body for cre... | 140 | 4,856 |
agentscope | src/agentscope/app/_router/_schema/_health.py | .py | # -*- coding: utf-8 -*-
"""The service health report, used as DTO layer."""
from typing import Literal
from pydantic import BaseModel, Field
ComponentStatus = Literal["ok", "not_ready", "disabled"]
class HealthResponse(BaseModel):
"""The service health response."""
status: Literal["ok", "not_ready"] = Fie... | 26 | 783 |
agentscope | src/agentscope/app/_router/_schema/_hub.py | .py | # -*- coding: utf-8 -*-
"""Hub schemas shared by the MCP and skill hub routes."""
from pydantic import BaseModel, Field
class HubInfo(BaseModel):
"""One registered hub, as shown in the hub picker."""
hub_id: str = Field(description="The id addressing this hub.")
display_name: str = Field(description="The... | 16 | 550 |
agentscope | src/agentscope/app/_router/_schema/_channel.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the channel router."""
from pydantic import BaseModel, Field
from ...storage import (
RoutingConfig,
SessionRecord,
SessionSettings,
)
class CreateChannelRequest(BaseModel):
"""Request body for creating a channel."""
channel_type: str = F... | 81 | 2,207 |
agentscope | src/agentscope/app/_router/_schema/__init__.py | .py | # -*- coding: utf-8 -*-
"""Schema models for the agent service."""
from ._channel import (
ChannelActionResponse,
ChannelChatId,
ChannelChatIdsResponse,
ChannelResponse,
ChannelSessionsResponse,
CreateChannelRequest,
UpdateChannelRequest,
)
from ._chat import ChatRequest, ChatTriggerRespons... | 174 | 4,557 |
agentscope | src/agentscope/app/_router/_schema/_workspace.py | .py | # -*- coding: utf-8 -*-
"""Schemas for equipping a workspace with MCPs and skills."""
from pydantic import BaseModel, Field
from ....mcp import MCPClient
class AddSkillRequest(BaseModel):
"""The request to add skill."""
skill_path: str
class AddFromLibraryRequest(BaseModel):
"""The request to put libr... | 125 | 3,597 |
agentscope | src/agentscope/app/_router/_schema/_chat.py | .py | # -*- coding: utf-8 -*-
"""The chat endpoint schema."""
from pydantic import BaseModel, Field
from ....message import Msg
from ....event import UserConfirmResultEvent, ExternalExecutionResultEvent
class ChatRequest(BaseModel):
"""Request body for the chat endpoint."""
agent_id: str = Field(
descrip... | 46 | 1,164 |
agentscope | src/agentscope/app/_router/_schema/_credential.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the credential router."""
from pydantic import BaseModel, Field
from ..._service import CredentialView
class CreateCredentialRequest(BaseModel):
"""Request body for creating a new credential."""
data: dict = Field(description="Credential payload (e.g... | 43 | 1,182 |
agentscope | src/agentscope/app/_router/_schema/_embedding_model.py | .py | # -*- coding: utf-8 -*-
"""The embedding model configuration, used as DTO layer."""
from pydantic import BaseModel, Field
from ....embedding import EmbeddingModelCard
class ListEmbeddingModelsResponse(BaseModel):
"""List the candidate embedding models response."""
models: list[EmbeddingModelCard] = Field(
... | 24 | 658 |
agentscope | src/agentscope/app/_router/_schema/_session.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the session router."""
from pydantic import BaseModel, Field
from ....permission import PermissionMode
from ...storage import (
ChatModelConfig,
SessionKnowledgeConfig,
TTSModelConfig,
SessionRecord,
TeamRecord,
)
from ..._service import Age... | 273 | 9,634 |
agentscope | src/agentscope/app/_router/_schema/_hub_skill.py | .py | # -*- coding: utf-8 -*-
"""Schemas for skills installed from a hub."""
from pydantic import BaseModel, Field
from ...storage import SkillRecord
class SkillView(BaseModel):
"""One installed skill, as shown in the user's library."""
id: str = Field(description="The installed-skill record id.")
name: str =... | 80 | 2,456 |
agentscope | src/agentscope/app/_router/_schema/_hub_mcp.py | .py | # -*- coding: utf-8 -*-
"""Schemas for installing and editing MCPs from a hub."""
from pydantic import BaseModel, Field
from ...storage import MCPRecord
class InstallMCPRequest(BaseModel):
"""The body of an MCP install call."""
name: str | None = Field(
default=None,
description=(
... | 128 | 3,970 |
agentscope | src/agentscope/app/_router/_schema/_mcp.py | .py | # -*- coding: utf-8 -*-
"""MCP schemas for API requests and responses."""
from enum import Enum
from pydantic import BaseModel, Field
from ....mcp import StdioMCPConfig, HttpMCPConfig
class ConnectionScope(str, Enum):
"""MCP connection scope and lifecycle strategy.
This determines how MCP connections are m... | 128 | 3,673 |
agentscope | src/agentscope/app/_router/_schema/_knowledge_base.py | .py | # -*- coding: utf-8 -*-
"""Request / response schemas for the knowledge base router."""
from datetime import datetime
from pydantic import BaseModel, Field
from ...storage import (
EmbeddingModelConfig,
KnowledgeDocumentRecord,
KnowledgeDocumentStatus,
)
from ..._service import CredentialView, KnowledgeBa... | 275 | 9,240 |
agentscope | src/agentscope/app/_router/_schema/_tts_model.py | .py | # -*- coding: utf-8 -*-
"""The TTS model configuration, used as DTO layer."""
from pydantic import BaseModel, Field
from ....tts import TTSModelCard
class ListTTSModelsResponse(BaseModel):
"""List the candidate TTS models response."""
models: list[TTSModelCard] = Field(
description="The candidate T... | 24 | 602 |
agentscope | src/agentscope/app/_router/_schema/_model.py | .py | # -*- coding: utf-8 -*-
"""The chat model configuration, used as DTO layer."""
from pydantic import BaseModel, Field
from ....model import ModelCard
class ListModelsResponse(BaseModel):
"""List the candidate models response."""
models: list[ModelCard] = Field(description="The candidate models.")
total:... | 22 | 568 |
agentscope | src/agentscope/app/workspace_manager/_base.py | .py | # -*- coding: utf-8 -*-
"""Workspace manager implementations."""
import hashlib
from abc import ABC, abstractmethod
from enum import StrEnum
from typing import Self
from ..._utils._common import _generate_id
from ...workspace import WorkspaceBase
class IsolationPolicy(StrEnum):
"""Workspace isolation grain for
... | 139 | 4,430 |
agentscope | src/agentscope/app/workspace_manager/_e2b_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""E2BWorkspaceManager β lifecycle manager for :class:`E2BWorkspace`.
Mirrors :class:`DockerWorkspaceManager` 1:1 in its public surface
(``get_workspace`` / ``create_workspace`` / ``close`` / ``close_all``)
so callers β notably :class:`agentscope.app._service.ChatService` β
do not branch on bac... | 409 | 16,094 |
agentscope | src/agentscope/app/workspace_manager/_bubblewrap_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""BubblewrapWorkspaceManager -- lifecycle manager for Bubblewrap."""
from __future__ import annotations
import asyncio
import hashlib
import os
import time
from typing import Self
from typing_extensions import deprecated
from ..._logging import logger
from ..._utils._common import _generate... | 273 | 9,531 |
agentscope | src/agentscope/app/workspace_manager/__init__.py | .py | # -*- coding: utf-8 -*-
"""The workspace manager classes, responsible for managing the resources
and their lifecycles, and filesystem isolation."""
from ._base import IsolationPolicy, WorkspaceManagerBase
from ._local_workspace_manager import LocalWorkspaceManager
from ._docker_workspace_manager import DockerWorkspace... | 29 | 1,050 |
agentscope | src/agentscope/app/workspace_manager/_opensandbox_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""OpenSandboxWorkspaceManager -- lifecycle manager for OpenSandbox.
Mirrors :class:`DockerWorkspaceManager` and :class:`E2BWorkspaceManager`
in its public surface (``get_workspace`` / ``close`` / ``close_all``) so
callers do not branch on backend.
Differences from the Docker manager:
* No ``... | 357 | 14,419 |
agentscope | src/agentscope/app/workspace_manager/_k8s_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""K8sWorkspaceManager β lifecycle manager for :class:`K8sWorkspace`.
Mirrors :class:`E2BWorkspaceManager` 1:1 in its public surface
(``get_workspace`` / ``create_workspace`` / ``close`` / ``close_all``)
so callers do not branch on backend.
Differences from the E2B manager:
* Reattachment use... | 355 | 13,133 |
agentscope | src/agentscope/app/workspace_manager/_local_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""The local workspace manager."""
import asyncio
import os
import time
from typing_extensions import deprecated
from ..._logging import logger
from ...workspace import LocalWorkspace
from ._base import WorkspaceManagerBase, IsolationPolicy
class LocalWorkspaceManager(WorkspaceManagerBase):... | 211 | 7,562 |
agentscope | src/agentscope/app/workspace_manager/_applecontainer_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""AppleContainerWorkspaceManager β lifecycle manager for
:class:`AppleContainerWorkspace`.
Mirrors :class:`DockerWorkspaceManager` 1:1 in its public surface
(``get_workspace`` / ``close`` / ``close_all``) so that callers do not
branch on backend.
Differences from the Docker manager:
* No bin... | 295 | 10,656 |
agentscope | src/agentscope/app/workspace_manager/_docker_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""DockerWorkspaceManager β lifecycle manager for :class:`DockerWorkspace`.
Mirrors :class:`LocalWorkspaceManager` 1:1 in its public surface
(``get_workspace`` / ``create_workspace`` / ``close`` / ``close_all``)
so that callers β notably :class:`agentscope.app._service.ChatService` β
do not bra... | 398 | 15,662 |
agentscope | src/agentscope/app/workspace_manager/_daytona_workspace_manager.py | .py | # -*- coding: utf-8 -*-
"""DaytonaWorkspaceManager β lifecycle manager for Daytona workspaces.
Mirrors :class:`E2BWorkspaceManager` and :class:`DockerWorkspaceManager`
in its public surface (``get_workspace`` / ``close`` / ``close_all``) so
service-layer callers do not branch on backend.
Daytona-specific behavior:
*... | 340 | 13,568 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.