mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 23:18:05 +08:00
integrate model provider with plugin daemon
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import logging
|
||||
from collections.abc import Callable, Generator
|
||||
from typing import Optional, TypeVar
|
||||
|
||||
@ -21,6 +22,8 @@ plugin_daemon_inner_api_key = dify_config.PLUGIN_API_KEY
|
||||
|
||||
T = TypeVar("T", bound=(BaseModel | dict | list | bool | str))
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BasePluginManager:
|
||||
def _request(
|
||||
@ -44,9 +47,14 @@ class BasePluginManager:
|
||||
if headers.get("Content-Type") == "application/json" and isinstance(data, dict):
|
||||
data = json.dumps(data)
|
||||
|
||||
response = requests.request(
|
||||
method=method, url=str(url), headers=headers, data=data, params=params, stream=stream, files=files
|
||||
)
|
||||
try:
|
||||
response = requests.request(
|
||||
method=method, url=str(url), headers=headers, data=data, params=params, stream=stream, files=files
|
||||
)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
logger.exception(f"Request to Plugin Daemon Service failed: {e}")
|
||||
raise ValueError("Request to Plugin Daemon Service failed")
|
||||
|
||||
return response
|
||||
|
||||
def _stream_request(
|
||||
|
||||
Reference in New Issue
Block a user