mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
bump version to 0.5.3 (#2306)
This commit is contained in:
parent
b521aafd26
commit
9f637ead38
|
@ -30,7 +30,7 @@ from flask import Flask, Response, request
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from libs.passport import PassportService
|
from libs.passport import PassportService
|
||||||
# DO NOT REMOVE BELOW
|
# DO NOT REMOVE BELOW
|
||||||
from models import account, dataset, model, source, task, tool, web, tools
|
from models import account, dataset, model, source, task, tool, tools, web
|
||||||
from services.account_service import AccountService
|
from services.account_service import AccountService
|
||||||
|
|
||||||
# DO NOT REMOVE ABOVE
|
# DO NOT REMOVE ABOVE
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Config:
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# General Configurations.
|
# General Configurations.
|
||||||
# ------------------------
|
# ------------------------
|
||||||
self.CURRENT_VERSION = "0.5.2"
|
self.CURRENT_VERSION = "0.5.3"
|
||||||
self.COMMIT_SHA = get_env('COMMIT_SHA')
|
self.COMMIT_SHA = get_env('COMMIT_SHA')
|
||||||
self.EDITION = "SELF_HOSTED"
|
self.EDITION = "SELF_HOSTED"
|
||||||
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
|
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from models.model import AppModelConfig
|
from models.model import AppModelConfig
|
||||||
|
|
||||||
languages = ['en-US', 'zh-Hans', 'pt-BR', 'es-ES', 'fr-FR', 'de-DE', 'ja-JP', 'ko-KR', 'ru-RU', 'it-IT']
|
languages = ['en-US', 'zh-Hans', 'pt-BR', 'es-ES', 'fr-FR', 'de-DE', 'ja-JP', 'ko-KR', 'ru-RU', 'it-IT']
|
||||||
|
|
|
@ -11,11 +11,11 @@ from .app import (advanced_prompt_template, annotation, app, audio, completion,
|
||||||
model_config, site, statistic)
|
model_config, site, statistic)
|
||||||
# Import auth controllers
|
# Import auth controllers
|
||||||
from .auth import activate, data_source_oauth, login, oauth
|
from .auth import activate, data_source_oauth, login, oauth
|
||||||
|
# Import billing controllers
|
||||||
|
from .billing import billing
|
||||||
# Import datasets controllers
|
# Import datasets controllers
|
||||||
from .datasets import data_source, datasets, datasets_document, datasets_segments, file, hit_testing
|
from .datasets import data_source, datasets, datasets_document, datasets_segments, file, hit_testing
|
||||||
# Import explore controllers
|
# Import explore controllers
|
||||||
from .explore import audio, completion, conversation, installed_app, message, parameter, recommended_app, saved_message
|
from .explore import audio, completion, conversation, installed_app, message, parameter, recommended_app, saved_message
|
||||||
# Import workspace controllers
|
# Import workspace controllers
|
||||||
from .workspace import account, members, model_providers, models, tool_providers, workspace
|
from .workspace import account, members, model_providers, models, tool_providers, workspace
|
||||||
# Import billing controllers
|
|
||||||
from .billing import billing
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import os
|
import os
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from constants.languages import supported_language
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.wraps import only_edition_cloud
|
from controllers.console.wraps import only_edition_cloud
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import Resource, reqparse
|
from flask_restful import Resource, reqparse
|
||||||
from constants.languages import supported_language
|
|
||||||
from models.model import App, InstalledApp, RecommendedApp
|
from models.model import App, InstalledApp, RecommendedApp
|
||||||
from werkzeug.exceptions import NotFound, Unauthorized
|
from werkzeug.exceptions import NotFound, Unauthorized
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from constants.model_template import model_templates
|
|
||||||
from constants.languages import demo_model_templates, languages
|
from constants.languages import demo_model_templates, languages
|
||||||
|
from constants.model_template import model_templates
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import AppNotFoundError, ProviderNotInitializeError
|
from controllers.console.app.error import AppNotFoundError, ProviderNotInitializeError
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.setup import setup_required
|
||||||
|
@ -26,6 +26,7 @@ from models.tools import ApiToolProvider
|
||||||
from services.app_model_config_service import AppModelConfigService
|
from services.app_model_config_service import AppModelConfigService
|
||||||
from werkzeug.exceptions import Forbidden
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
def _get_app(app_id, tenant_id):
|
def _get_app(app_id, tenant_id):
|
||||||
app = db.session.query(App).filter(App.id == app_id, App.tenant_id == tenant_id).first()
|
app = db.session.query(App).filter(App.id == app_id, App.tenant_id == tenant_id).first()
|
||||||
if not app:
|
if not app:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
from constants.languages import supported_language
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app import _get_app
|
from controllers.console.app import _get_app
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.setup import setup_required
|
||||||
|
@ -7,7 +8,6 @@ from extensions.ext_database import db
|
||||||
from fields.app_fields import app_site_fields
|
from fields.app_fields import app_site_fields
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_restful import Resource, marshal_with, reqparse
|
from flask_restful import Resource, marshal_with, reqparse
|
||||||
from constants.languages import supported_language
|
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from models.model import Site
|
from models.model import Site
|
||||||
from werkzeug.exceptions import Forbidden, NotFound
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
|
@ -2,12 +2,12 @@ import base64
|
||||||
import secrets
|
import secrets
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from constants.languages import supported_language
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.error import AlreadyActivateError
|
from controllers.console.error import AlreadyActivateError
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from flask_restful import Resource, reqparse
|
from flask_restful import Resource, reqparse
|
||||||
from libs.helper import email, str_len, timezone
|
from libs.helper import email, str_len, timezone
|
||||||
from constants.languages import supported_language
|
|
||||||
from libs.password import hash_password, valid_password
|
from libs.password import hash_password, valid_password
|
||||||
from models.account import AccountStatus, Tenant
|
from models.account import AccountStatus, Tenant
|
||||||
from services.account_service import RegisterService
|
from services.account_service import RegisterService
|
||||||
|
|
|
@ -9,7 +9,7 @@ from flask import current_app, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_restful import Resource, marshal_with
|
from flask_restful import Resource, marshal_with
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.file_service import FileService, ALLOWED_EXTENSIONS, UNSTRUSTURED_ALLOWED_EXTENSIONS
|
from services.file_service import ALLOWED_EXTENSIONS, UNSTRUSTURED_ALLOWED_EXTENSIONS, FileService
|
||||||
|
|
||||||
PREVIEW_WORDS_LIMIT = 3000
|
PREVIEW_WORDS_LIMIT = 3000
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ from core.model_runtime.errors.invoke import InvokeError
|
||||||
from fields.message_fields import message_infinite_scroll_pagination_fields
|
from fields.message_fields import message_infinite_scroll_pagination_fields
|
||||||
from flask import Response, stream_with_context
|
from flask import Response, stream_with_context
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_restful import marshal_with, reqparse, fields
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
from flask_restful.inputs import int_range
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import uuid_value, TimestampField
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
from services.errors.app import MoreLikeThisDisabledError
|
from services.errors.app import MoreLikeThisDisabledError
|
||||||
from services.errors.conversation import ConversationNotExistsError
|
from services.errors.conversation import ConversationNotExistsError
|
||||||
|
|
|
@ -3,12 +3,12 @@ import json
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
|
from extensions.ext_database import db
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_restful import fields, marshal_with
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import InstalledApp, AppModelConfig
|
from models.model import AppModelConfig, InstalledApp
|
||||||
from models.tools import ApiToolProvider
|
from models.tools import ApiToolProvider
|
||||||
|
|
||||||
from extensions.ext_database import db
|
|
||||||
|
|
||||||
class AppParameterApi(InstalledAppResource):
|
class AppParameterApi(InstalledAppResource):
|
||||||
"""Resource for app variables."""
|
"""Resource for app variables."""
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
from constants.languages import languages
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import AppNotFoundError
|
from controllers.console.app.error import AppNotFoundError
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
|
@ -9,7 +10,6 @@ from libs.login import login_required
|
||||||
from models.model import App, InstalledApp, RecommendedApp
|
from models.model import App, InstalledApp, RecommendedApp
|
||||||
from services.account_service import TenantService
|
from services.account_service import TenantService
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from constants.languages import languages
|
|
||||||
|
|
||||||
app_fields = {
|
app_fields = {
|
||||||
'id': fields.String,
|
'id': fields.String,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flask import current_app, session
|
from flask import current_app, session
|
||||||
from flask_restful import Resource, reqparse
|
from flask_restful import Resource, reqparse
|
||||||
from libs.helper import str_len
|
from libs.helper import str_len
|
||||||
|
|
|
@ -10,7 +10,7 @@ from models.model import DifySetup
|
||||||
from services.account_service import AccountService, RegisterService, TenantService
|
from services.account_service import AccountService, RegisterService, TenantService
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .error import AlreadySetupError, NotSetupError, NotInitValidateError
|
from .error import AlreadySetupError, NotInitValidateError, NotSetupError
|
||||||
from .init_validate import get_init_validate_status
|
from .init_validate import get_init_validate_status
|
||||||
from .wraps import only_edition_self_hosted
|
from .wraps import only_edition_self_hosted
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
from constants.languages import supported_language
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.setup import setup_required
|
||||||
from controllers.console.workspace.error import (AccountAlreadyInitedError, CurrentPasswordIncorrectError,
|
from controllers.console.workspace.error import (AccountAlreadyInitedError, CurrentPasswordIncorrectError,
|
||||||
|
@ -12,7 +13,6 @@ from flask import current_app, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_restful import Resource, fields, marshal_with, reqparse
|
from flask_restful import Resource, fields, marshal_with, reqparse
|
||||||
from libs.helper import TimestampField, timezone
|
from libs.helper import TimestampField, timezone
|
||||||
from constants.languages import supported_language
|
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from models.account import AccountIntegrate, InvitationCode
|
from models.account import AccountIntegrate, InvitationCode
|
||||||
from services.account_service import AccountService
|
from services.account_service import AccountService
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import current_app
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, abort, fields, marshal_with, reqparse
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.setup import setup_required
|
||||||
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
|
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import current_app
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, abort, fields, marshal_with, reqparse
|
||||||
from libs.helper import TimestampField
|
from libs.helper import TimestampField
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from models.account import Account
|
from models.account import Account
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
from flask import send_file
|
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.setup import setup_required
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
|
from flask import send_file
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from services.tools_manage_service import ToolManageService
|
from services.tools_manage_service import ToolManageService
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
import io
|
|
||||||
|
|
||||||
class ToolProviderListApi(Resource):
|
class ToolProviderListApi(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import json
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from flask import request
|
|
||||||
|
|
||||||
from controllers.console.workspace.error import AccountNotInitializedError
|
from controllers.console.workspace.error import AccountNotInitializedError
|
||||||
from flask import abort, current_app
|
from flask import abort, current_app, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from services.feature_service import FeatureService
|
from services.feature_service import FeatureService
|
||||||
from services.operation_service import OperationService
|
from services.operation_service import OperationService
|
||||||
|
|
|
@ -6,5 +6,4 @@ bp = Blueprint('files', __name__)
|
||||||
api = ExternalApi(bp)
|
api = ExternalApi(bp)
|
||||||
|
|
||||||
|
|
||||||
from . import image_preview
|
from . import image_preview, tool_files
|
||||||
from . import tool_files
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from controllers.files import api
|
from controllers.files import api
|
||||||
|
from core.tools.tool_file_manager import ToolFileManager
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from flask_restful import Resource, reqparse
|
from flask_restful import Resource, reqparse
|
||||||
from libs.exception import BaseHTTPException
|
from libs.exception import BaseHTTPException
|
||||||
from werkzeug.exceptions import NotFound, Forbidden
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
from core.tools.tool_file_manager import ToolFileManager
|
|
||||||
|
|
||||||
class ToolFilePreviewApi(Resource):
|
class ToolFilePreviewApi(Resource):
|
||||||
def get(self, file_id, extension):
|
def get(self, file_id, extension):
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
import json
|
||||||
|
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.wraps import AppApiResource
|
from controllers.service_api.wraps import AppApiResource
|
||||||
|
from extensions.ext_database import db
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_restful import fields, marshal_with
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import App, AppModelConfig
|
from models.model import App, AppModelConfig
|
||||||
from models.tools import ApiToolProvider
|
from models.tools import ApiToolProvider
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from extensions.ext_database import db
|
|
||||||
|
|
||||||
|
|
||||||
class AppParameterApi(AppApiResource):
|
class AppParameterApi(AppApiResource):
|
||||||
"""Resource for app variables."""
|
"""Resource for app variables."""
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from models.dataset import Dataset
|
|
||||||
import services.dataset_service
|
import services.dataset_service
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.dataset.error import DatasetNameDuplicateError
|
from controllers.service_api.dataset.error import DatasetNameDuplicateError
|
||||||
|
@ -9,6 +8,7 @@ from fields.dataset_fields import dataset_detail_fields
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import marshal, reqparse
|
from flask_restful import marshal, reqparse
|
||||||
from libs.login import current_user
|
from libs.login import current_user
|
||||||
|
from models.dataset import Dataset
|
||||||
from services.dataset_service import DatasetService
|
from services.dataset_service import DatasetService
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
from controllers.service_api import api
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
|
||||||
from controllers.service_api import api
|
|
||||||
|
|
||||||
|
|
||||||
class IndexApi(Resource):
|
class IndexApi(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
import json
|
||||||
|
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
|
from extensions.ext_database import db
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_restful import fields, marshal_with
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import App, AppModelConfig
|
from models.model import App, AppModelConfig
|
||||||
from models.tools import ApiToolProvider
|
from models.tools import ApiToolProvider
|
||||||
|
|
||||||
from extensions.ext_database import db
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
class AppParameterApi(WebApiResource):
|
class AppParameterApi(WebApiResource):
|
||||||
"""Resource for app variables."""
|
"""Resource for app variables."""
|
||||||
|
|
|
@ -2,8 +2,13 @@ import time
|
||||||
from typing import Generator, List, Optional, Tuple, Union, cast
|
from typing import Generator, List, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.entities.application_entities import AppOrchestrationConfigEntity, ModelConfigEntity, \
|
from core.entities.application_entities import (ApplicationGenerateEntity, AppOrchestrationConfigEntity,
|
||||||
PromptTemplateEntity, ExternalDataVariableEntity, ApplicationGenerateEntity, InvokeFrom
|
ExternalDataVariableEntity, InvokeFrom, ModelConfigEntity,
|
||||||
|
PromptTemplateEntity)
|
||||||
|
from core.features.annotation_reply import AnnotationReplyFeature
|
||||||
|
from core.features.external_data_fetch import ExternalDataFetchFeature
|
||||||
|
from core.features.hosting_moderation import HostingModerationFeature
|
||||||
|
from core.features.moderation import ModerationFeature
|
||||||
from core.file.file_obj import FileObj
|
from core.file.file_obj import FileObj
|
||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
||||||
|
@ -11,12 +16,9 @@ from core.model_runtime.entities.message_entities import AssistantPromptMessage,
|
||||||
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
||||||
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.features.hosting_moderation import HostingModerationFeature
|
|
||||||
from core.features.moderation import ModerationFeature
|
|
||||||
from core.features.external_data_fetch import ExternalDataFetchFeature
|
|
||||||
from core.features.annotation_reply import AnnotationReplyFeature
|
|
||||||
from core.prompt.prompt_transform import PromptTransform
|
from core.prompt.prompt_transform import PromptTransform
|
||||||
from models.model import App, MessageAnnotation, Message
|
from models.model import App, Message, MessageAnnotation
|
||||||
|
|
||||||
|
|
||||||
class AppRunner:
|
class AppRunner:
|
||||||
def get_pre_calculate_rest_tokens(self, app_record: App,
|
def get_pre_calculate_rest_tokens(self, app_record: App,
|
||||||
|
|
|
@ -3,11 +3,10 @@ import logging
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from core.app_runner.app_runner import AppRunner
|
from core.app_runner.app_runner import AppRunner
|
||||||
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
|
from core.entities.application_entities import AgentEntity, ApplicationGenerateEntity, ModelConfigEntity
|
||||||
from core.features.assistant_cot_runner import AssistantCotApplicationRunner
|
from core.features.assistant_cot_runner import AssistantCotApplicationRunner
|
||||||
from core.features.assistant_fc_runner import AssistantFunctionCallApplicationRunner
|
from core.features.assistant_fc_runner import AssistantFunctionCallApplicationRunner
|
||||||
from core.entities.application_entities import ApplicationGenerateEntity, ModelConfigEntity, \
|
|
||||||
AgentEntity
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
|
||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_manager import ModelInstance
|
from core.model_manager import ModelInstance
|
||||||
from core.model_runtime.entities.llm_entities import LLMUsage
|
from core.model_runtime.entities.llm_entities import LLMUsage
|
||||||
|
@ -16,7 +15,7 @@ from core.model_runtime.model_providers.__base.large_language_model import Large
|
||||||
from core.moderation.base import ModerationException
|
from core.moderation.base import ModerationException
|
||||||
from core.tools.entities.tool_entities import ToolRuntimeVariablePool
|
from core.tools.entities.tool_entities import ToolRuntimeVariablePool
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import Conversation, Message, App, MessageChain, MessageAgentThought
|
from models.model import App, Conversation, Message, MessageAgentThought, MessageChain
|
||||||
from models.tools import ToolConversationVariables
|
from models.tools import ToolConversationVariables
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -4,8 +4,7 @@ from typing import Optional
|
||||||
from core.app_runner.app_runner import AppRunner
|
from core.app_runner.app_runner import AppRunner
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||||
from core.entities.application_entities import (ApplicationGenerateEntity, DatasetEntity,
|
from core.entities.application_entities import ApplicationGenerateEntity, DatasetEntity, InvokeFrom, ModelConfigEntity
|
||||||
InvokeFrom, ModelConfigEntity)
|
|
||||||
from core.features.dataset_retrieval import DatasetRetrievalFeature
|
from core.features.dataset_retrieval import DatasetRetrievalFeature
|
||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_manager import ModelInstance
|
from core.model_manager import ModelInstance
|
||||||
|
|
|
@ -6,21 +6,21 @@ from typing import Generator, Optional, Union, cast
|
||||||
from core.app_runner.moderation_handler import ModerationRule, OutputModerationHandler
|
from core.app_runner.moderation_handler import ModerationRule, OutputModerationHandler
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.entities.application_entities import ApplicationGenerateEntity, InvokeFrom
|
from core.entities.application_entities import ApplicationGenerateEntity, InvokeFrom
|
||||||
from core.entities.queue_entities import (AnnotationReplyEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
from core.entities.queue_entities import (AnnotationReplyEvent, QueueAgentMessageEvent, QueueAgentThoughtEvent,
|
||||||
QueueMessageEndEvent, QueueMessageEvent, QueueMessageReplaceEvent,
|
QueueErrorEvent, QueueMessageEndEvent, QueueMessageEvent,
|
||||||
QueuePingEvent, QueueRetrieverResourcesEvent, QueueStopEvent,
|
QueueMessageFileEvent, QueueMessageReplaceEvent, QueuePingEvent,
|
||||||
QueueMessageFileEvent, QueueAgentMessageEvent)
|
QueueRetrieverResourcesEvent, QueueStopEvent)
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||||
PromptMessage, PromptMessageContentType, PromptMessageRole,
|
PromptMessage, PromptMessageContentType, PromptMessageRole,
|
||||||
TextPromptMessageContent)
|
TextPromptMessageContent)
|
||||||
from core.model_runtime.errors.invoke import InvokeAuthorizationError, InvokeError
|
from core.model_runtime.errors.invoke import InvokeAuthorizationError, InvokeError
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.tools.tool_file_manager import ToolFileManager
|
|
||||||
from core.tools.tool_manager import ToolManager
|
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.prompt.prompt_template import PromptTemplateParser
|
from core.prompt.prompt_template import PromptTemplateParser
|
||||||
|
from core.tools.tool_file_manager import ToolFileManager
|
||||||
|
from core.tools.tool_manager import ToolManager
|
||||||
from events.message_event import message_was_created
|
from events.message_event import message_was_created
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import Conversation, Message, MessageAgentThought, MessageFile
|
from models.model import Conversation, Message, MessageAgentThought, MessageFile
|
||||||
|
|
|
@ -9,11 +9,12 @@ from core.app_runner.basic_app_runner import BasicApplicationRunner
|
||||||
from core.app_runner.generate_task_pipeline import GenerateTaskPipeline
|
from core.app_runner.generate_task_pipeline import GenerateTaskPipeline
|
||||||
from core.application_queue_manager import ApplicationQueueManager, ConversationTaskStoppedException, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, ConversationTaskStoppedException, PublishFrom
|
||||||
from core.entities.application_entities import (AdvancedChatPromptTemplateEntity,
|
from core.entities.application_entities import (AdvancedChatPromptTemplateEntity,
|
||||||
AdvancedCompletionPromptTemplateEntity, AgentEntity, AgentToolEntity,
|
AdvancedCompletionPromptTemplateEntity, AgentEntity, AgentPromptEntity,
|
||||||
ApplicationGenerateEntity, AppOrchestrationConfigEntity, DatasetEntity,
|
AgentToolEntity, ApplicationGenerateEntity,
|
||||||
|
AppOrchestrationConfigEntity, DatasetEntity,
|
||||||
DatasetRetrieveConfigEntity, ExternalDataVariableEntity,
|
DatasetRetrieveConfigEntity, ExternalDataVariableEntity,
|
||||||
FileUploadEntity, InvokeFrom, ModelConfigEntity, PromptTemplateEntity,
|
FileUploadEntity, InvokeFrom, ModelConfigEntity, PromptTemplateEntity,
|
||||||
SensitiveWordAvoidanceEntity, AgentPromptEntity)
|
SensitiveWordAvoidanceEntity)
|
||||||
from core.entities.model_entities import ModelStatus
|
from core.entities.model_entities import ModelStatus
|
||||||
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.file.file_obj import FileObj
|
from core.file.file_obj import FileObj
|
||||||
|
|
|
@ -4,10 +4,10 @@ from enum import Enum
|
||||||
from typing import Any, Generator
|
from typing import Any, Generator
|
||||||
|
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.entities.queue_entities import (AnnotationReplyEvent, AppQueueEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
from core.entities.queue_entities import (AnnotationReplyEvent, AppQueueEvent, QueueAgentMessageEvent,
|
||||||
QueueMessage, QueueMessageEndEvent, QueueMessageEvent,
|
QueueAgentThoughtEvent, QueueErrorEvent, QueueMessage, QueueMessageEndEvent,
|
||||||
QueueMessageReplaceEvent, QueuePingEvent, QueueRetrieverResourcesEvent,
|
QueueMessageEvent, QueueMessageFileEvent, QueueMessageReplaceEvent,
|
||||||
QueueStopEvent, QueueMessageFileEvent, QueueAgentMessageEvent)
|
QueuePingEvent, QueueRetrieverResourcesEvent, QueueStopEvent)
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
from models.model import MessageAgentThought, MessageFile
|
from models.model import MessageAgentThought, MessageFile
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import os
|
import os
|
||||||
from typing import Any, Dict, Optional, Union
|
from typing import Any, Dict, Optional, Union
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from langchain.callbacks.base import BaseCallbackHandler
|
from langchain.callbacks.base import BaseCallbackHandler
|
||||||
from langchain.input import print_text
|
from langchain.input import print_text
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class DifyAgentCallbackHandler(BaseCallbackHandler, BaseModel):
|
class DifyAgentCallbackHandler(BaseCallbackHandler, BaseModel):
|
||||||
"""Callback Handler that prints to std out."""
|
"""Callback Handler that prints to std out."""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from langchain.document_loaders.base import BaseLoader
|
from langchain.document_loaders.base import BaseLoader
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,8 @@ from core.model_manager import ModelInstance
|
||||||
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from langchain.embeddings.base import Embeddings
|
|
||||||
|
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
|
from langchain.embeddings.base import Embeddings
|
||||||
from libs import helper
|
from libs import helper
|
||||||
from models.dataset import Embedding
|
from models.dataset import Embedding
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, Any, cast, Literal, Union
|
from typing import Any, Literal, Optional, Union, cast
|
||||||
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from core.entities.provider_configuration import ProviderModelBundle
|
from core.entities.provider_configuration import ProviderModelBundle
|
||||||
from core.file.file_obj import FileObj
|
from core.file.file_obj import FileObj
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageRole
|
from core.model_runtime.entities.message_entities import PromptMessageRole
|
||||||
from core.model_runtime.entities.model_entities import AIModelEntity
|
from core.model_runtime.entities.model_entities import AIModelEntity
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class ModelConfigEntity(BaseModel):
|
class ModelConfigEntity(BaseModel):
|
||||||
|
|
|
@ -1,27 +1,26 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import cast, Optional, List
|
from typing import List, Optional, cast
|
||||||
|
|
||||||
from langchain import WikipediaAPIWrapper
|
|
||||||
from langchain.callbacks.base import BaseCallbackHandler
|
|
||||||
from langchain.tools import BaseTool, WikipediaQueryRun, Tool
|
|
||||||
from pydantic import BaseModel, Field
|
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from core.agent.agent_executor import PlanningStrategy, AgentConfiguration, AgentExecutor
|
from core.agent.agent_executor import AgentConfiguration, AgentExecutor, PlanningStrategy
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from core.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
from core.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
||||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||||
from core.callback_handler.std_out_callback_handler import DifyStdOutCallbackHandler
|
from core.callback_handler.std_out_callback_handler import DifyStdOutCallbackHandler
|
||||||
from core.entities.application_entities import ModelConfigEntity, InvokeFrom, \
|
from core.entities.application_entities import (AgentEntity, AgentToolEntity, AppOrchestrationConfigEntity, InvokeFrom,
|
||||||
AgentEntity, AgentToolEntity, AppOrchestrationConfigEntity
|
ModelConfigEntity)
|
||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_runtime.entities.model_entities import ModelFeature, ModelType
|
from core.model_runtime.entities.model_entities import ModelFeature, ModelType
|
||||||
from core.model_runtime.model_providers import model_provider_factory
|
from core.model_runtime.model_providers import model_provider_factory
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.tools.tool.dataset_retriever.dataset_retriever_tool import DatasetRetrieverTool
|
from core.tools.tool.dataset_retriever.dataset_retriever_tool import DatasetRetrieverTool
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from langchain import WikipediaAPIWrapper
|
||||||
|
from langchain.callbacks.base import BaseCallbackHandler
|
||||||
|
from langchain.tools import BaseTool, Tool, WikipediaQueryRun
|
||||||
from models.dataset import Dataset
|
from models.dataset import Dataset
|
||||||
from models.model import Message
|
from models.model import Message
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,32 @@
|
||||||
import logging
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
from typing import Optional, List, Tuple, Union, cast
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from mimetypes import guess_extension
|
from mimetypes import guess_extension
|
||||||
|
from typing import List, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
from core.app_runner.app_runner import AppRunner
|
from core.app_runner.app_runner import AppRunner
|
||||||
from extensions.ext_database import db
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
|
|
||||||
from models.model import MessageAgentThought, Message, MessageFile
|
|
||||||
from models.tools import ToolConversationVariables
|
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolInvokeMessageBinary, \
|
|
||||||
ToolRuntimeVariablePool, ToolParameter
|
|
||||||
from core.tools.tool.tool import Tool
|
|
||||||
from core.tools.tool_manager import ToolManager
|
|
||||||
from core.tools.tool_file_manager import ToolFileManager
|
|
||||||
from core.tools.tool.dataset_retriever_tool import DatasetRetrieverTool
|
|
||||||
from core.app_runner.app_runner import AppRunner
|
|
||||||
from core.callback_handler.agent_tool_callback_handler import DifyAgentCallbackHandler
|
from core.callback_handler.agent_tool_callback_handler import DifyAgentCallbackHandler
|
||||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||||
from core.entities.application_entities import ModelConfigEntity, AgentEntity, AgentToolEntity
|
from core.entities.application_entities import (AgentEntity, AgentToolEntity, ApplicationGenerateEntity,
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
AppOrchestrationConfigEntity, InvokeFrom, ModelConfigEntity)
|
||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
|
||||||
from core.entities.application_entities import ModelConfigEntity, \
|
|
||||||
AgentEntity, AppOrchestrationConfigEntity, ApplicationGenerateEntity, InvokeFrom
|
|
||||||
from core.model_runtime.entities.message_entities import PromptMessage, PromptMessageTool
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMUsage
|
|
||||||
from core.model_runtime.entities.model_entities import ModelFeature
|
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
from core.file.message_file_parser import FileTransferMethod
|
from core.file.message_file_parser import FileTransferMethod
|
||||||
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
|
from core.model_runtime.entities.llm_entities import LLMUsage
|
||||||
|
from core.model_runtime.entities.message_entities import PromptMessage, PromptMessageTool
|
||||||
|
from core.model_runtime.entities.model_entities import ModelFeature
|
||||||
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
|
from core.tools.entities.tool_entities import (ToolInvokeMessage, ToolInvokeMessageBinary, ToolParameter,
|
||||||
|
ToolRuntimeVariablePool)
|
||||||
|
from core.tools.tool.dataset_retriever_tool import DatasetRetrieverTool
|
||||||
|
from core.tools.tool.tool import Tool
|
||||||
|
from core.tools.tool_file_manager import ToolFileManager
|
||||||
|
from core.tools.tool_manager import ToolManager
|
||||||
|
from extensions.ext_database import db
|
||||||
|
from models.model import Message, MessageAgentThought, MessageFile
|
||||||
|
from models.tools import ToolConversationVariables
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Literal, Union, Generator, Dict, List
|
from typing import Dict, Generator, List, Literal, Union
|
||||||
|
|
||||||
from core.entities.application_entities import AgentPromptEntity, AgentScratchpadUnit
|
|
||||||
from core.application_queue_manager import PublishFrom
|
from core.application_queue_manager import PublishFrom
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.entities.application_entities import AgentPromptEntity, AgentScratchpadUnit
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageTool, PromptMessage, \
|
|
||||||
UserPromptMessage, SystemPromptMessage, AssistantPromptMessage
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMUsage, LLMResultChunk, LLMResultChunkDelta
|
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
|
|
||||||
from core.tools.errors import ToolInvokeError, ToolNotFoundError, \
|
|
||||||
ToolNotSupportedError, ToolProviderNotFoundError, ToolParameterValidationError, \
|
|
||||||
ToolProviderCredentialValidationError
|
|
||||||
|
|
||||||
from core.features.assistant_base_runner import BaseAssistantApplicationRunner
|
from core.features.assistant_base_runner import BaseAssistantApplicationRunner
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
||||||
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
|
SystemPromptMessage, UserPromptMessage)
|
||||||
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
|
from core.tools.errors import (ToolInvokeError, ToolNotFoundError, ToolNotSupportedError, ToolParameterValidationError,
|
||||||
|
ToolProviderCredentialValidationError, ToolProviderNotFoundError)
|
||||||
from models.model import Conversation, Message
|
from models.model import Conversation, Message
|
||||||
|
|
||||||
|
|
||||||
class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
|
class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
|
||||||
def run(self, conversation: Conversation,
|
def run(self, conversation: Conversation,
|
||||||
message: Message,
|
message: Message,
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any, Dict, Generator, List, Tuple, Union
|
||||||
|
|
||||||
from typing import Union, Generator, Dict, Any, Tuple, List
|
|
||||||
|
|
||||||
from core.model_runtime.entities.message_entities import PromptMessage, UserPromptMessage,\
|
|
||||||
SystemPromptMessage, AssistantPromptMessage, ToolPromptMessage, PromptMessageTool
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResultChunk, LLMResult, LLMUsage, LLMResultChunkDelta
|
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
from core.application_queue_manager import PublishFrom
|
from core.application_queue_manager import PublishFrom
|
||||||
|
|
||||||
from core.tools.errors import ToolInvokeError, ToolNotFoundError, \
|
|
||||||
ToolNotSupportedError, ToolProviderNotFoundError, ToolParameterValidationError, \
|
|
||||||
ToolProviderCredentialValidationError
|
|
||||||
|
|
||||||
from core.features.assistant_base_runner import BaseAssistantApplicationRunner
|
from core.features.assistant_base_runner import BaseAssistantApplicationRunner
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
||||||
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
|
SystemPromptMessage, ToolPromptMessage, UserPromptMessage)
|
||||||
|
from core.tools.errors import (ToolInvokeError, ToolNotFoundError, ToolNotSupportedError, ToolParameterValidationError,
|
||||||
|
ToolProviderCredentialValidationError, ToolProviderNotFoundError)
|
||||||
from models.model import Conversation, Message, MessageAgentThought
|
from models.model import Conversation, Message, MessageAgentThought
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from core.file.file_obj import FileObj, FileTransferMethod, FileType, FileBelongsTo
|
from core.file.file_obj import FileBelongsTo, FileObj, FileTransferMethod, FileType
|
||||||
from services.file_service import IMAGE_EXTENSIONS
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.account import Account
|
from models.account import Account
|
||||||
from models.model import AppModelConfig, EndUser, MessageFile, UploadFile
|
from models.model import AppModelConfig, EndUser, MessageFile, UploadFile
|
||||||
|
from services.file_service import IMAGE_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
class MessageFileParser:
|
class MessageFileParser:
|
||||||
|
|
|
@ -2,7 +2,7 @@ from typing import Optional
|
||||||
|
|
||||||
from core.entities.provider_entities import QuotaUnit, RestrictModel
|
from core.entities.provider_entities import QuotaUnit, RestrictModel
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from flask import Flask, Config
|
from flask import Config, Flask
|
||||||
from models.provider import ProviderQuotaType
|
from models.provider import ProviderQuotaType
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from core.docstore.dataset_docstore import DatasetDocumentStore
|
||||||
from core.errors.error import ProviderTokenNotInitError
|
from core.errors.error import ProviderTokenNotInitError
|
||||||
from core.generator.llm_generator import LLMGenerator
|
from core.generator.llm_generator import LLMGenerator
|
||||||
from core.index.index import IndexBuilder
|
from core.index.index import IndexBuilder
|
||||||
from core.model_manager import ModelManager, ModelInstance
|
from core.model_manager import ModelInstance, ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType, PriceType
|
from core.model_runtime.entities.model_entities import ModelType, PriceType
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
|
|
|
@ -12,8 +12,8 @@ from core.model_runtime.model_providers.__base.large_language_model import Large
|
||||||
from core.model_runtime.model_providers.__base.moderation_model import ModerationModel
|
from core.model_runtime.model_providers.__base.moderation_model import ModerationModel
|
||||||
from core.model_runtime.model_providers.__base.rerank_model import RerankModel
|
from core.model_runtime.model_providers.__base.rerank_model import RerankModel
|
||||||
from core.model_runtime.model_providers.__base.speech2text_model import Speech2TextModel
|
from core.model_runtime.model_providers.__base.speech2text_model import Speech2TextModel
|
||||||
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
|
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
||||||
from core.provider_manager import ProviderManager
|
from core.provider_manager import ProviderManager
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import uuid
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import uuid
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from core.model_runtime.entities.model_entities import ModelPropertyKey, ModelType
|
||||||
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
|
||||||
|
|
||||||
|
|
||||||
class TTSModel(AIModel):
|
class TTSModel(AIModel):
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, List, Optional, Union
|
from typing import Generator, List, Optional, Union
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from botocore.exceptions import ClientError, EndpointConnectionError, NoRegionError, ServiceNotInRegionError, UnknownServiceError
|
|
||||||
from botocore.config import Config
|
from botocore.config import Config
|
||||||
import json
|
from botocore.exceptions import (ClientError, EndpointConnectionError, NoRegionError, ServiceNotInRegionError,
|
||||||
|
UnknownServiceError)
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage,
|
SystemPromptMessage, UserPromptMessage)
|
||||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage)
|
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
|
|
|
@ -5,7 +5,8 @@ from typing import Generator, List, Optional, cast
|
||||||
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageFunction,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageFunction,
|
||||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
PromptMessageTool, SystemPromptMessage, ToolPromptMessage,
|
||||||
|
UserPromptMessage)
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, List, Optional, Union, cast, Tuple
|
from typing import Generator, List, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
import cohere
|
import cohere
|
||||||
from cohere.responses import Chat, Generations
|
from cohere.responses import Chat, Generations
|
||||||
from cohere.responses.chat import StreamingChat, StreamTextGeneration, StreamEnd
|
from cohere.responses.chat import StreamEnd, StreamingChat, StreamTextGeneration
|
||||||
from cohere.responses.generation import StreamingText, StreamingGenerations
|
from cohere.responses.generation import StreamingGenerations, StreamingText
|
||||||
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage,
|
||||||
PromptMessageContentType, SystemPromptMessage,
|
PromptMessageContentType, PromptMessageTool,
|
||||||
TextPromptMessageContent, UserPromptMessage,
|
SystemPromptMessage, TextPromptMessageContent,
|
||||||
PromptMessageTool)
|
UserPromptMessage)
|
||||||
from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, I18nObject, ModelType
|
from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, I18nObject, ModelType
|
||||||
from core.model_runtime.errors.invoke import InvokeConnectionError, InvokeServerUnavailableError, InvokeError, \
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeRateLimitError, InvokeAuthorizationError, InvokeBadRequestError
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,10 @@ from typing import Optional, Tuple
|
||||||
import cohere
|
import cohere
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from cohere.responses import Tokens
|
from cohere.responses import Tokens
|
||||||
|
|
||||||
from core.model_runtime.entities.model_entities import PriceType
|
from core.model_runtime.entities.model_entities import PriceType
|
||||||
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||||
from core.model_runtime.errors.invoke import InvokeConnectionError, InvokeServerUnavailableError, InvokeRateLimitError, \
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeAuthorizationError, InvokeBadRequestError, InvokeError
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ from typing import Generator, List
|
||||||
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
SystemPromptMessage, ToolPromptMessage, UserPromptMessage)
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
|
|
|
@ -2,21 +2,20 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Optional, Generator, Union, List, cast
|
from typing import Generator, List, Optional, Union, cast
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageTool, PromptMessage, AssistantPromptMessage, \
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||||
UserPromptMessage, PromptMessageContentType, ImagePromptMessageContent, \
|
PromptMessage, PromptMessageContentType, PromptMessageTool,
|
||||||
TextPromptMessageContent, SystemPromptMessage
|
SystemPromptMessage, TextPromptMessageContent,
|
||||||
from core.model_runtime.entities.model_entities import I18nObject, ModelType, \
|
UserPromptMessage)
|
||||||
PriceConfig, AIModelEntity, FetchFrom, ModelPropertyKey, ParameterRule, ParameterType, DefaultParameterName, \
|
from core.model_runtime.entities.model_entities import (AIModelEntity, DefaultParameterName, FetchFrom, I18nObject,
|
||||||
ModelFeature
|
ModelFeature, ModelPropertyKey, ModelType, ParameterRule,
|
||||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, \
|
ParameterType, PriceConfig)
|
||||||
LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
from core.model_runtime.errors.invoke import InvokeError, InvokeAuthorizationError, InvokeBadRequestError, \
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
InvokeRateLimitError, InvokeServerUnavailableError, InvokeConnectionError
|
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import requests
|
||||||
from core.model_runtime.entities.common_entities import I18nObject
|
from core.model_runtime.entities.common_entities import I18nObject
|
||||||
from core.model_runtime.entities.model_entities import PriceType, ModelPropertyKey, ModelType, AIModelEntity, FetchFrom, \
|
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelPropertyKey, ModelType,
|
||||||
PriceConfig
|
PriceConfig, PriceType)
|
||||||
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult, EmbeddingUsage
|
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||||
from core.model_runtime.errors.invoke import InvokeError, InvokeAuthorizationError, InvokeBadRequestError, \
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeRateLimitError, InvokeServerUnavailableError, InvokeConnectionError
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
|
import concurrent.futures
|
||||||
|
from functools import reduce
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from functools import reduce
|
|
||||||
from pydub import AudioSegment
|
|
||||||
|
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
|
||||||
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
||||||
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
||||||
from core.model_runtime.model_providers.openai._common import _CommonOpenAI
|
from core.model_runtime.model_providers.openai._common import _CommonOpenAI
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
from flask import Response, stream_with_context
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
import concurrent.futures
|
from pydub import AudioSegment
|
||||||
|
|
||||||
|
|
||||||
class OpenAIText2SpeechModel(_CommonOpenAI, TTSModel):
|
class OpenAIText2SpeechModel(_CommonOpenAI, TTSModel):
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
from typing import Generator, List, Optional, Union
|
from typing import Generator, List, Optional, Union
|
||||||
|
|
||||||
from dashscope import get_tokenizer
|
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMMode
|
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
SystemPromptMessage, UserPromptMessage)
|
SystemPromptMessage, UserPromptMessage)
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
from dashscope import get_tokenizer
|
||||||
from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
|
from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
|
||||||
from dashscope.common.error import (AuthenticationError, InvalidParameter, RequestFailure, ServiceUnavailableError,
|
from dashscope.common.error import (AuthenticationError, InvalidParameter, RequestFailure, ServiceUnavailableError,
|
||||||
UnsupportedHTTPMethod, UnsupportedModel)
|
UnsupportedHTTPMethod, UnsupportedModel)
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
|
import concurrent.futures
|
||||||
|
from functools import reduce
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from functools import reduce
|
|
||||||
from pydub import AudioSegment
|
|
||||||
|
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
|
||||||
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
|
||||||
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
|
||||||
from core.model_runtime.model_providers.tongyi._common import _CommonTongyi
|
|
||||||
|
|
||||||
import dashscope
|
import dashscope
|
||||||
|
from core.model_runtime.errors.invoke import InvokeBadRequestError
|
||||||
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
|
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
||||||
|
from core.model_runtime.model_providers.tongyi._common import _CommonTongyi
|
||||||
from flask import Response, stream_with_context
|
from flask import Response, stream_with_context
|
||||||
import concurrent.futures
|
from pydub import AudioSegment
|
||||||
|
|
||||||
|
|
||||||
class TongyiText2SpeechModel(_CommonTongyi, TTSModel):
|
class TongyiText2SpeechModel(_CommonTongyi, TTSModel):
|
||||||
|
|
|
@ -3,9 +3,9 @@ from typing import Generator, Iterator, List, Optional, Union, cast
|
||||||
from core.model_runtime.entities.common_entities import I18nObject
|
from core.model_runtime.entities.common_entities import I18nObject
|
||||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||||
SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
SystemPromptMessage, ToolPromptMessage, UserPromptMessage)
|
||||||
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelPropertyKey, ModelType,
|
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelFeature, ModelPropertyKey,
|
||||||
ParameterRule, ParameterType, ModelFeature)
|
ModelType, ParameterRule, ParameterType)
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
|
|
|
@ -2,15 +2,15 @@ import time
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from core.model_runtime.entities.common_entities import I18nObject
|
from core.model_runtime.entities.common_entities import I18nObject
|
||||||
from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, ModelType, PriceType, ModelPropertyKey
|
from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, ModelPropertyKey, ModelType, PriceType
|
||||||
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
|
from core.model_runtime.model_providers.xinference.xinference_helper import XinferenceHelper
|
||||||
from xinference_client.client.restful.restful_client import Client, RESTfulEmbeddingModelHandle, RESTfulModelHandle
|
from xinference_client.client.restful.restful_client import Client, RESTfulEmbeddingModelHandle, RESTfulModelHandle
|
||||||
|
|
||||||
from core.model_runtime.model_providers.xinference.xinference_helper import XinferenceHelper
|
|
||||||
|
|
||||||
class XinferenceTextEmbeddingModel(TextEmbeddingModel):
|
class XinferenceTextEmbeddingModel(TextEmbeddingModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
from os import path
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from time import time
|
from time import time
|
||||||
from typing import List
|
from typing import List
|
||||||
from os import path
|
|
||||||
|
|
||||||
from requests import get
|
from requests import get
|
||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
|
|
|
@ -2,16 +2,19 @@ import json
|
||||||
from typing import Any, Dict, Generator, List, Optional, Union
|
from typing import Any, Dict, Generator, List, Optional, Union
|
||||||
|
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageRole,
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage, ToolPromptMessage,
|
PromptMessage, PromptMessageContentType, PromptMessageRole,
|
||||||
TextPromptMessageContent, ImagePromptMessageContent, PromptMessageContentType)
|
PromptMessageTool, SystemPromptMessage,
|
||||||
|
TextPromptMessageContent, ToolPromptMessage,
|
||||||
|
UserPromptMessage)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.utils import helper
|
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.model_runtime.model_providers.zhipuai._common import _CommonZhipuaiAI
|
from core.model_runtime.model_providers.zhipuai._common import _CommonZhipuaiAI
|
||||||
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk._client import ZhipuAI
|
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk._client import ZhipuAI
|
||||||
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk.types.chat.chat_completion_chunk import ChatCompletionChunk
|
|
||||||
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk.types.chat.chat_completion import Completion
|
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk.types.chat.chat_completion import Completion
|
||||||
|
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk.types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||||
|
from core.model_runtime.utils import helper
|
||||||
|
|
||||||
|
|
||||||
class ZhipuAILargeLanguageModel(_CommonZhipuaiAI, LargeLanguageModel):
|
class ZhipuAILargeLanguageModel(_CommonZhipuaiAI, LargeLanguageModel):
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ from core.model_runtime.entities.model_entities import PriceType
|
||||||
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
from core.model_runtime.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||||
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk._client import ZhipuAI
|
|
||||||
from core.model_runtime.model_providers.zhipuai._common import _CommonZhipuaiAI
|
from core.model_runtime.model_providers.zhipuai._common import _CommonZhipuaiAI
|
||||||
|
from core.model_runtime.model_providers.zhipuai.zhipuai_sdk._client import ZhipuAI
|
||||||
from langchain.schema.language_model import _get_token_ids_default_method
|
from langchain.schema.language_model import _get_token_ids_default_method
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
|
|
||||||
from ._client import ZhipuAI
|
|
||||||
|
|
||||||
from .core._errors import (
|
|
||||||
ZhipuAIError,
|
|
||||||
APIStatusError,
|
|
||||||
APIRequestFailedError,
|
|
||||||
APIAuthenticationError,
|
|
||||||
APIReachLimitError,
|
|
||||||
APIInternalError,
|
|
||||||
APIServerFlowExceedError,
|
|
||||||
APIResponseError,
|
|
||||||
APIResponseValidationError,
|
|
||||||
APITimeoutError,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .__version__ import __version__
|
from .__version__ import __version__
|
||||||
|
from ._client import ZhipuAI
|
||||||
|
from .core._errors import (APIAuthenticationError, APIInternalError, APIReachLimitError, APIRequestFailedError,
|
||||||
|
APIResponseError, APIResponseValidationError, APIServerFlowExceedError, APIStatusError,
|
||||||
|
APITimeoutError, ZhipuAIError)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, Mapping
|
|
||||||
|
|
||||||
from typing_extensions import override
|
|
||||||
|
|
||||||
from .core import _jwt_token
|
|
||||||
from .core._errors import ZhipuAIError
|
|
||||||
from .core._http_client import HttpClient, ZHIPUAI_DEFAULT_MAX_RETRIES
|
|
||||||
from .core._base_type import NotGiven, NOT_GIVEN
|
|
||||||
from . import api_resource
|
|
||||||
import os
|
import os
|
||||||
|
from typing import Mapping, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from httpx import Timeout
|
from httpx import Timeout
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
|
from . import api_resource
|
||||||
|
from .core import _jwt_token
|
||||||
|
from .core._base_type import NOT_GIVEN, NotGiven
|
||||||
|
from .core._errors import ZhipuAIError
|
||||||
|
from .core._http_client import ZHIPUAI_DEFAULT_MAX_RETRIES, HttpClient
|
||||||
|
|
||||||
|
|
||||||
class ZhipuAI(HttpClient):
|
class ZhipuAI(HttpClient):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from .chat import chat
|
from .chat import chat
|
||||||
from .images import Images
|
|
||||||
from .embeddings import Embeddings
|
from .embeddings import Embeddings
|
||||||
from .files import Files
|
from .files import Files
|
||||||
from .fine_tuning import fine_tuning
|
from .fine_tuning import fine_tuning
|
||||||
|
from .images import Images
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, List, Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List, Optional, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
from ...core._base_api import BaseAPI
|
from ...core._base_api import BaseAPI
|
||||||
from ...core._base_type import NotGiven, NOT_GIVEN, Headers
|
from ...core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||||
from ...core._http_client import make_user_request_input
|
from ...core._http_client import make_user_request_input
|
||||||
from ...types.chat.async_chat_completion import AsyncTaskStatus, AsyncCompletion
|
from ...types.chat.async_chat_completion import AsyncCompletion, AsyncTaskStatus
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..._client import ZhipuAI
|
from ..._client import ZhipuAI
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from .completions import Completions
|
|
||||||
from .async_completions import AsyncCompletions
|
|
||||||
from ...core._base_api import BaseAPI
|
from ...core._base_api import BaseAPI
|
||||||
|
from .async_completions import AsyncCompletions
|
||||||
|
from .completions import Completions
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..._client import ZhipuAI
|
from ..._client import ZhipuAI
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, List, Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List, Optional, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
from ...core._base_api import BaseAPI
|
from ...core._base_api import BaseAPI
|
||||||
from ...core._base_type import NotGiven, NOT_GIVEN, Headers
|
from ...core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||||
from ...core._http_client import make_user_request_input
|
from ...core._http_client import make_user_request_input
|
||||||
from ...core._sse_client import StreamResponse
|
from ...core._sse_client import StreamResponse
|
||||||
from ...types.chat.chat_completion import Completion
|
from ...types.chat.chat_completion import Completion
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, List, Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List, Optional, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from ..core._base_api import BaseAPI
|
from ..core._base_api import BaseAPI
|
||||||
from ..core._base_type import NotGiven, NOT_GIVEN, Headers
|
from ..core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||||
from ..core._http_client import make_user_request_input
|
from ..core._http_client import make_user_request_input
|
||||||
from ..types.embeddings import EmbeddingsResponded
|
from ..types.embeddings import EmbeddingsResponded
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,9 @@ from typing import TYPE_CHECKING
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from ..core._base_api import BaseAPI
|
from ..core._base_api import BaseAPI
|
||||||
from ..core._base_type import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
|
from ..core._base_type import NOT_GIVEN, Body, FileTypes, Headers, NotGiven, Query
|
||||||
from ..core._files import is_file_content
|
from ..core._files import is_file_content
|
||||||
from ..core._http_client import (
|
from ..core._http_client import make_user_request_input
|
||||||
make_user_request_input,
|
|
||||||
)
|
|
||||||
from ..types.file_object import FileObject, ListOfFileObject
|
from ..types.file_object import FileObject, ListOfFileObject
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from .jobs import Jobs
|
|
||||||
from ...core._base_api import BaseAPI
|
from ...core._base_api import BaseAPI
|
||||||
|
from .jobs import Jobs
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..._client import ZhipuAI
|
from ..._client import ZhipuAI
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from ...core._base_api import BaseAPI
|
from ...core._base_api import BaseAPI
|
||||||
from ...core._base_type import NOT_GIVEN, Headers, NotGiven
|
from ...core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||||
from ...core._http_client import (
|
from ...core._http_client import make_user_request_input
|
||||||
make_user_request_input,
|
from ...types.fine_tuning import FineTuningJob, FineTuningJobEvent, ListOfFineTuningJob, job_create_params
|
||||||
)
|
|
||||||
from ...types.fine_tuning import (
|
|
||||||
FineTuningJob,
|
|
||||||
job_create_params,
|
|
||||||
ListOfFineTuningJob,
|
|
||||||
FineTuningJobEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..._client import ZhipuAI
|
from ..._client import ZhipuAI
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, List, Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List, Optional, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from ..core._base_api import BaseAPI
|
from ..core._base_api import BaseAPI
|
||||||
from ..core._base_type import NotGiven, NOT_GIVEN, Headers
|
from ..core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||||
from ..core._http_client import make_user_request_input
|
from ..core._http_client import make_user_request_input
|
||||||
from ..types.image import ImagesResponded
|
from ..types.image import ImagesResponded
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from os import PathLike
|
from os import PathLike
|
||||||
from typing import (
|
from typing import IO, TYPE_CHECKING, Any, List, Mapping, Sequence, Tuple, Type, TypeVar, Union
|
||||||
TYPE_CHECKING,
|
|
||||||
Type,
|
|
||||||
Union,
|
|
||||||
Mapping,
|
|
||||||
TypeVar, IO, Tuple, Sequence, Any, List,
|
|
||||||
)
|
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from typing_extensions import (
|
from typing_extensions import Literal, override
|
||||||
Literal,
|
|
||||||
override,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
Query = Mapping[str, object]
|
Query = Mapping[str, object]
|
||||||
Body = object
|
Body = object
|
||||||
|
|
|
@ -5,12 +5,7 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Mapping, Sequence
|
from typing import Mapping, Sequence
|
||||||
|
|
||||||
from ._base_type import (
|
from ._base_type import FileTypes, HttpxFileTypes, HttpxRequestFiles, RequestFiles
|
||||||
FileTypes,
|
|
||||||
HttpxFileTypes,
|
|
||||||
HttpxRequestFiles,
|
|
||||||
RequestFiles,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def is_file_content(obj: object) -> bool:
|
def is_file_content(obj: object) -> bool:
|
||||||
|
|
|
@ -2,20 +2,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
from typing import (
|
from typing import Any, Mapping, Type, Union, cast
|
||||||
Any,
|
|
||||||
Type,
|
|
||||||
Union,
|
|
||||||
cast,
|
|
||||||
Mapping,
|
|
||||||
)
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import pydantic
|
import pydantic
|
||||||
from httpx import URL, Timeout
|
from httpx import URL, Timeout
|
||||||
|
|
||||||
from . import _errors
|
from . import _errors
|
||||||
from ._base_type import NotGiven, ResponseT, Body, Headers, NOT_GIVEN, RequestFiles, Query, Data
|
from ._base_type import NOT_GIVEN, Body, Data, Headers, NotGiven, Query, RequestFiles, ResponseT
|
||||||
from ._errors import APIResponseValidationError, APIStatusError, APITimeoutError
|
from ._errors import APIResponseValidationError, APIStatusError, APITimeoutError
|
||||||
from ._files import make_httpx_files
|
from ._files import make_httpx_files
|
||||||
from ._request_opt import ClientRequestParam, UserRequestInput
|
from ._request_opt import ClientRequestParam, UserRequestInput
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Union, Any, cast
|
from typing import Any, Union, cast
|
||||||
|
|
||||||
import pydantic.generics
|
import pydantic.generics
|
||||||
from httpx import Timeout
|
from httpx import Timeout
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
from typing_extensions import (
|
from typing_extensions import ClassVar, TypedDict, Unpack
|
||||||
Unpack, ClassVar, TypedDict
|
|
||||||
)
|
|
||||||
|
|
||||||
from ._base_type import Body, NotGiven, Headers, HttpxRequestFiles, Query
|
from ._base_type import Body, Headers, HttpxRequestFiles, NotGiven, Query
|
||||||
from ._utils import remove_notgiven_indict
|
from ._utils import remove_notgiven_indict
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import TypeVar, Generic, cast, Any, TYPE_CHECKING
|
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import pydantic
|
import pydantic
|
||||||
from typing_extensions import ParamSpec, get_origin, get_args
|
from typing_extensions import ParamSpec, get_args, get_origin
|
||||||
|
|
||||||
from ._base_type import NoneType
|
from ._base_type import NoneType
|
||||||
from ._sse_client import StreamResponse
|
from ._sse_client import StreamResponse
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Generic, Iterator, TYPE_CHECKING, Mapping
|
from typing import TYPE_CHECKING, Generic, Iterator, Mapping
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Mapping, Iterable, TypeVar
|
from typing import Iterable, Mapping, TypeVar
|
||||||
|
|
||||||
from ._base_type import NotGiven
|
from ._base_type import NotGiven
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from .chat.chat_completion import CompletionUsage
|
from .chat.chat_completion import CompletionUsage
|
||||||
|
|
||||||
__all__ = ["Embedding", "EmbeddingsResponded"]
|
__all__ = ["Embedding", "EmbeddingsResponded"]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import List, Union, Optional
|
from typing import List, Optional, Union
|
||||||
from typing_extensions import Literal
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
__all__ = ["FineTuningJob", "Error", "Hyperparameters", "ListOfFineTuningJob" ]
|
__all__ = ["FineTuningJob", "Error", "Hyperparameters", "ListOfFineTuningJob" ]
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import List, Union, Optional
|
from typing import List, Optional, Union
|
||||||
from typing_extensions import Literal
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
__all__ = ["FineTuningJobEvent", "Metric", "JobEvent"]
|
__all__ = ["FineTuningJobEvent", "Metric", "JobEvent"]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from pydantic import BaseModel
|
from typing import Any, Dict, List, Optional
|
||||||
from typing import Dict, Optional, Any, List
|
|
||||||
|
from core.tools.entities.tool_entities import ToolParameter, ToolProviderType
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolProviderType, ToolParameter
|
|
||||||
|
|
||||||
class ApiBasedToolBundle(BaseModel):
|
class ApiBasedToolBundle(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from pydantic import BaseModel, Field
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, List, Dict, Any, Union, cast
|
from typing import Any, Dict, List, Optional, Union, cast
|
||||||
|
|
||||||
from core.tools.entities.common_entities import I18nObject
|
from core.tools.entities.common_entities import I18nObject
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
class ToolProviderType(Enum):
|
class ToolProviderType(Enum):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from pydantic import BaseModel
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import List, Dict, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
from core.tools.entities.common_entities import I18nObject
|
from core.tools.entities.common_entities import I18nObject
|
||||||
from core.tools.entities.tool_entities import ToolProviderCredentials
|
from core.tools.entities.tool_entities import ToolProviderCredentials
|
||||||
from core.tools.tool.tool import ToolParameter
|
from core.tools.tool.tool import ToolParameter
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class UserToolProvider(BaseModel):
|
class UserToolProvider(BaseModel):
|
||||||
class ProviderType(Enum):
|
class ProviderType(Enum):
|
||||||
|
|
|
@ -4,23 +4,21 @@
|
||||||
Therefore, a model manager is needed to list/invoke/validate models.
|
Therefore, a model manager is needed to list/invoke/validate models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from core.model_runtime.entities.message_entities import PromptMessage
|
import json
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult
|
from typing import List, cast
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel, ModelPropertyKey
|
|
||||||
from core.model_runtime.errors.invoke import InvokeRateLimitError, InvokeBadRequestError, \
|
|
||||||
InvokeConnectionError, InvokeAuthorizationError, InvokeServerUnavailableError
|
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
|
||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
|
from core.model_runtime.entities.llm_entities import LLMResult
|
||||||
|
from core.model_runtime.entities.message_entities import PromptMessage
|
||||||
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
|
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||||
|
InvokeRateLimitError, InvokeServerUnavailableError)
|
||||||
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel, ModelPropertyKey
|
||||||
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.tools.model.errors import InvokeModelError
|
from core.tools.model.errors import InvokeModelError
|
||||||
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
|
||||||
from models.tools import ToolModelInvoke
|
from models.tools import ToolModelInvoke
|
||||||
|
|
||||||
from typing import List, cast
|
|
||||||
import json
|
|
||||||
|
|
||||||
class ToolModelManager:
|
class ToolModelManager:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
from core.tools.entities.tool_entities import ToolProviderType, ApiProviderAuthType, ToolProviderCredentials, ToolCredentialsOption
|
|
||||||
from core.tools.entities.common_entities import I18nObject
|
from core.tools.entities.common_entities import I18nObject
|
||||||
from core.tools.entities.tool_bundle import ApiBasedToolBundle
|
from core.tools.entities.tool_bundle import ApiBasedToolBundle
|
||||||
from core.tools.tool.tool import Tool
|
from core.tools.entities.tool_entities import (ApiProviderAuthType, ToolCredentialsOption, ToolProviderCredentials,
|
||||||
from core.tools.tool.api_tool import ApiTool
|
ToolProviderType)
|
||||||
from core.tools.provider.tool_provider import ToolProviderController
|
from core.tools.provider.tool_provider import ToolProviderController
|
||||||
|
from core.tools.tool.api_tool import ApiTool
|
||||||
|
from core.tools.tool.tool import Tool
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
|
||||||
from models.tools import ApiToolProvider
|
from models.tools import ApiToolProvider
|
||||||
|
|
||||||
|
|
||||||
class ApiBasedToolProviderController(ToolProviderController):
|
class ApiBasedToolProviderController(ToolProviderController):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_db(db_provider: ApiToolProvider, auth_type: ApiProviderAuthType) -> 'ApiBasedToolProviderController':
|
def from_db(db_provider: ApiToolProvider, auth_type: ApiProviderAuthType) -> 'ApiBasedToolProviderController':
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
from typing import Any, Dict, List
|
|
||||||
from core.tools.entities.tool_entities import ToolProviderType, ToolParameter, ToolParameterOption
|
|
||||||
from core.tools.tool.tool import Tool
|
|
||||||
from core.tools.entities.common_entities import I18nObject
|
|
||||||
from core.tools.provider.tool_provider import ToolProviderController
|
|
||||||
|
|
||||||
from extensions.ext_database import db
|
|
||||||
from models.tools import PublishedAppTool
|
|
||||||
from models.model import App, AppModelConfig
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
from core.tools.entities.common_entities import I18nObject
|
||||||
|
from core.tools.entities.tool_entities import ToolParameter, ToolParameterOption, ToolProviderType
|
||||||
|
from core.tools.provider.tool_provider import ToolProviderController
|
||||||
|
from core.tools.tool.tool import Tool
|
||||||
|
from extensions.ext_database import db
|
||||||
|
from models.model import App, AppModelConfig
|
||||||
|
from models.tools import PublishedAppTool
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from core.tools.entities.user_entities import UserToolProvider
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
from core.tools.entities.user_entities import UserToolProvider
|
||||||
|
|
||||||
position = {
|
position = {
|
||||||
'google': 1,
|
'google': 1,
|
||||||
'wikipedia': 2,
|
'wikipedia': 2,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
|
||||||
from core.tools.provider.builtin.azuredalle.tools.dalle3 import DallE3Tool
|
|
||||||
from core.tools.errors import ToolProviderCredentialValidationError
|
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin.azuredalle.tools.dalle3 import DallE3Tool
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
|
|
||||||
class AzureDALLEProvider(BuiltinToolProviderController):
|
class AzureDALLEProvider(BuiltinToolProviderController):
|
||||||
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from typing import Any, Dict, List, Union
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
|
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
from openai import AzureOpenAI
|
from openai import AzureOpenAI
|
||||||
|
|
||||||
|
|
||||||
class DallE3Tool(BuiltinTool):
|
class DallE3Tool(BuiltinTool):
|
||||||
def _invoke(self,
|
def _invoke(self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
|
||||||
from core.tools.errors import ToolProviderCredentialValidationError
|
|
||||||
|
|
||||||
from core.tools.provider.builtin.chart.tools.line import LinearChartTool
|
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin.chart.tools.line import LinearChartTool
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
# use a business theme
|
# use a business theme
|
||||||
plt.style.use('seaborn-v0_8-darkgrid')
|
plt.style.use('seaborn-v0_8-darkgrid')
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
class BarChartTool(BuiltinTool):
|
class BarChartTool(BuiltinTool):
|
||||||
def _invoke(self, user_id: str, tool_parameters: Dict[str, Any]) \
|
def _invoke(self, user_id: str, tool_parameters: Dict[str, Any]) \
|
||||||
-> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
|
-> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
class LinearChartTool(BuiltinTool):
|
class LinearChartTool(BuiltinTool):
|
||||||
def _invoke(self,
|
def _invoke(self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
class PieChartTool(BuiltinTool):
|
class PieChartTool(BuiltinTool):
|
||||||
def _invoke(self,
|
def _invoke(self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
|
||||||
from core.tools.provider.builtin.dalle.tools.dalle2 import DallE2Tool
|
|
||||||
from core.tools.errors import ToolProviderCredentialValidationError
|
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin.dalle.tools.dalle2 import DallE2Tool
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
|
|
||||||
class DALLEProvider(BuiltinToolProviderController):
|
class DALLEProvider(BuiltinToolProviderController):
|
||||||
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from typing import Any, Dict, List, Union
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
|
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
|
|
||||||
class DallE2Tool(BuiltinTool):
|
class DallE2Tool(BuiltinTool):
|
||||||
def _invoke(self,
|
def _invoke(self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from typing import Any, Dict, List, Union
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
|
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
|
|
||||||
class DallE3Tool(BuiltinTool):
|
class DallE3Tool(BuiltinTool):
|
||||||
def _invoke(self,
|
def _invoke(self,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import requests
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
|
||||||
|
import requests
|
||||||
from core.tools.errors import ToolProviderCredentialValidationError
|
from core.tools.errors import ToolProviderCredentialValidationError
|
||||||
|
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||||
|
|
||||||
|
|
||||||
class GaodeProvider(BuiltinToolProviderController):
|
class GaodeProvider(BuiltinToolProviderController):
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import json
|
import json
|
||||||
import requests
|
|
||||||
from core.tools.tool.builtin_tool import BuiltinTool
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
from core.tools.tool.builtin_tool import BuiltinTool
|
||||||
|
|
||||||
|
|
||||||
class GaodeRepositoriesTool(BuiltinTool):
|
class GaodeRepositoriesTool(BuiltinTool):
|
||||||
def _invoke(self, user_id: str, tool_parameters: Dict[str, Any]) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
|
def _invoke(self, user_id: str, tool_parameters: Dict[str, Any]) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user