mirror of
https://github.com/langgenius/dify.git
synced 2026-06-01 22:01:06 -04:00
22 lines
709 B
Python
22 lines
709 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any, Protocol
|
|
|
|
from core.model_manager import ModelInstance
|
|
|
|
|
|
class CredentialsProvider(Protocol):
|
|
"""Workflow-layer port for loading runtime credentials for a provider/model pair."""
|
|
|
|
def fetch(self, provider_name: str, model_name: str) -> dict[str, Any]:
|
|
"""Return credentials for the target provider/model or raise a domain error."""
|
|
...
|
|
|
|
|
|
class ModelFactory(Protocol):
|
|
"""Workflow-layer port for creating mutable ModelInstance objects."""
|
|
|
|
def init_model_instance(self, provider_name: str, model_name: str) -> ModelInstance:
|
|
"""Create a model instance that is ready for workflow-side hydration."""
|
|
...
|