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 libs.passport import PassportService
|
||||
# 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
|
||||
|
||||
# DO NOT REMOVE ABOVE
|
||||
|
|
|
@ -87,7 +87,7 @@ class Config:
|
|||
# ------------------------
|
||||
# General Configurations.
|
||||
# ------------------------
|
||||
self.CURRENT_VERSION = "0.5.2"
|
||||
self.CURRENT_VERSION = "0.5.3"
|
||||
self.COMMIT_SHA = get_env('COMMIT_SHA')
|
||||
self.EDITION = "SELF_HOSTED"
|
||||
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
import json
|
||||
|
||||
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']
|
||||
|
|
|
@ -11,11 +11,11 @@ from .app import (advanced_prompt_template, annotation, app, audio, completion,
|
|||
model_config, site, statistic)
|
||||
# Import auth controllers
|
||||
from .auth import activate, data_source_oauth, login, oauth
|
||||
# Import billing controllers
|
||||
from .billing import billing
|
||||
# Import datasets controllers
|
||||
from .datasets import data_source, datasets, datasets_document, datasets_segments, file, hit_testing
|
||||
# Import explore controllers
|
||||
from .explore import audio, completion, conversation, installed_app, message, parameter, recommended_app, saved_message
|
||||
# Import workspace controllers
|
||||
from .workspace import account, members, model_providers, models, tool_providers, workspace
|
||||
# Import billing controllers
|
||||
from .billing import billing
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
from functools import wraps
|
||||
|
||||
from constants.languages import supported_language
|
||||
from controllers.console import api
|
||||
from controllers.console.wraps import only_edition_cloud
|
||||
from extensions.ext_database import db
|
||||
from flask import request
|
||||
from flask_restful import Resource, reqparse
|
||||
from constants.languages import supported_language
|
||||
from models.model import App, InstalledApp, RecommendedApp
|
||||
from werkzeug.exceptions import NotFound, Unauthorized
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import json
|
|||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from constants.model_template import model_templates
|
||||
from constants.languages import demo_model_templates, languages
|
||||
from constants.model_template import model_templates
|
||||
from controllers.console import api
|
||||
from controllers.console.app.error import AppNotFoundError, ProviderNotInitializeError
|
||||
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 werkzeug.exceptions import Forbidden
|
||||
|
||||
|
||||
def _get_app(app_id, tenant_id):
|
||||
app = db.session.query(App).filter(App.id == app_id, App.tenant_id == tenant_id).first()
|
||||
if not app:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from constants.languages import supported_language
|
||||
from controllers.console import api
|
||||
from controllers.console.app import _get_app
|
||||
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 flask_login import current_user
|
||||
from flask_restful import Resource, marshal_with, reqparse
|
||||
from constants.languages import supported_language
|
||||
from libs.login import login_required
|
||||
from models.model import Site
|
||||
from werkzeug.exceptions import Forbidden, NotFound
|
||||
|
|
|
@ -2,12 +2,12 @@ import base64
|
|||
import secrets
|
||||
from datetime import datetime
|
||||
|
||||
from constants.languages import supported_language
|
||||
from controllers.console import api
|
||||
from controllers.console.error import AlreadyActivateError
|
||||
from extensions.ext_database import db
|
||||
from flask_restful import Resource, reqparse
|
||||
from libs.helper import email, str_len, timezone
|
||||
from constants.languages import supported_language
|
||||
from libs.password import hash_password, valid_password
|
||||
from models.account import AccountStatus, Tenant
|
||||
from services.account_service import RegisterService
|
||||
|
|
|
@ -9,7 +9,7 @@ from flask import current_app, request
|
|||
from flask_login import current_user
|
||||
from flask_restful import Resource, marshal_with
|
||||
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
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ from core.model_runtime.errors.invoke import InvokeError
|
|||
from fields.message_fields import message_infinite_scroll_pagination_fields
|
||||
from flask import Response, stream_with_context
|
||||
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 libs.helper import uuid_value, TimestampField
|
||||
from libs.helper import TimestampField, uuid_value
|
||||
from services.completion_service import CompletionService
|
||||
from services.errors.app import MoreLikeThisDisabledError
|
||||
from services.errors.conversation import ConversationNotExistsError
|
||||
|
|
|
@ -3,12 +3,12 @@ import json
|
|||
|
||||
from controllers.console import api
|
||||
from controllers.console.explore.wraps import InstalledAppResource
|
||||
from extensions.ext_database import db
|
||||
from flask import current_app
|
||||
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 extensions.ext_database import db
|
||||
|
||||
class AppParameterApi(InstalledAppResource):
|
||||
"""Resource for app variables."""
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from constants.languages import languages
|
||||
from controllers.console import api
|
||||
from controllers.console.app.error import AppNotFoundError
|
||||
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 services.account_service import TenantService
|
||||
from sqlalchemy import and_
|
||||
from constants.languages import languages
|
||||
|
||||
app_fields = {
|
||||
'id': fields.String,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
|
||||
from flask import current_app, session
|
||||
from flask_restful import Resource, reqparse
|
||||
from libs.helper import str_len
|
||||
|
|
|
@ -10,7 +10,7 @@ from models.model import DifySetup
|
|||
from services.account_service import AccountService, RegisterService, TenantService
|
||||
|
||||
from . import api
|
||||
from .error import AlreadySetupError, NotSetupError, NotInitValidateError
|
||||
from .error import AlreadySetupError, NotInitValidateError, NotSetupError
|
||||
from .init_validate import get_init_validate_status
|
||||
from .wraps import only_edition_self_hosted
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
from constants.languages import supported_language
|
||||
from controllers.console import api
|
||||
from controllers.console.setup import setup_required
|
||||
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_restful import Resource, fields, marshal_with, reqparse
|
||||
from libs.helper import TimestampField, timezone
|
||||
from constants.languages import supported_language
|
||||
from libs.login import login_required
|
||||
from models.account import AccountIntegrate, InvitationCode
|
||||
from services.account_service import AccountService
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# -*- 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
|
||||
from controllers.console import api
|
||||
from controllers.console.setup import setup_required
|
||||
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
|
||||
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.login import login_required
|
||||
from models.account import Account
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
import io
|
||||
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.setup import setup_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 werkzeug.exceptions import Forbidden
|
||||
|
||||
import io
|
||||
|
||||
class ToolProviderListApi(Resource):
|
||||
@setup_required
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
import json
|
||||
from functools import wraps
|
||||
from flask import request
|
||||
|
||||
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 services.feature_service import FeatureService
|
||||
from services.operation_service import OperationService
|
||||
|
|
|
@ -6,5 +6,4 @@ bp = Blueprint('files', __name__)
|
|||
api = ExternalApi(bp)
|
||||
|
||||
|
||||
from . import image_preview
|
||||
from . import tool_files
|
||||
from . import image_preview, tool_files
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from controllers.files import api
|
||||
from core.tools.tool_file_manager import ToolFileManager
|
||||
from flask import Response
|
||||
from flask_restful import Resource, reqparse
|
||||
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):
|
||||
def get(self, file_id, extension):
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
import json
|
||||
|
||||
from controllers.service_api import api
|
||||
from controllers.service_api.wraps import AppApiResource
|
||||
from extensions.ext_database import db
|
||||
from flask import current_app
|
||||
from flask_restful import fields, marshal_with
|
||||
from models.model import App, AppModelConfig
|
||||
from models.tools import ApiToolProvider
|
||||
|
||||
import json
|
||||
|
||||
from extensions.ext_database import db
|
||||
|
||||
|
||||
class AppParameterApi(AppApiResource):
|
||||
"""Resource for app variables."""
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from models.dataset import Dataset
|
||||
import services.dataset_service
|
||||
from controllers.service_api import api
|
||||
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_restful import marshal, reqparse
|
||||
from libs.login import current_user
|
||||
from models.dataset import Dataset
|
||||
from services.dataset_service import DatasetService
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from controllers.service_api import api
|
||||
from flask import current_app
|
||||
from flask_restful import Resource
|
||||
|
||||
from controllers.service_api import api
|
||||
|
||||
|
||||
class IndexApi(Resource):
|
||||
def get(self):
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
import json
|
||||
|
||||
from controllers.web import api
|
||||
from controllers.web.wraps import WebApiResource
|
||||
from extensions.ext_database import db
|
||||
from flask import current_app
|
||||
from flask_restful import fields, marshal_with
|
||||
from models.model import App, AppModelConfig
|
||||
from models.tools import ApiToolProvider
|
||||
|
||||
from extensions.ext_database import db
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class AppParameterApi(WebApiResource):
|
||||
"""Resource for app variables."""
|
||||
|
|
|
@ -2,8 +2,13 @@ import time
|
|||
from typing import Generator, List, Optional, Tuple, Union, cast
|
||||
|
||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||
from core.entities.application_entities import AppOrchestrationConfigEntity, ModelConfigEntity, \
|
||||
PromptTemplateEntity, ExternalDataVariableEntity, ApplicationGenerateEntity, InvokeFrom
|
||||
from core.entities.application_entities import (ApplicationGenerateEntity, AppOrchestrationConfigEntity,
|
||||
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.memory.token_buffer_memory import TokenBufferMemory
|
||||
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.errors.invoke import InvokeBadRequestError
|
||||
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 models.model import App, MessageAnnotation, Message
|
||||
from models.model import App, Message, MessageAnnotation
|
||||
|
||||
|
||||
class AppRunner:
|
||||
def get_pre_calculate_rest_tokens(self, app_record: App,
|
||||
|
|
|
@ -3,11 +3,10 @@ import logging
|
|||
from typing import cast
|
||||
|
||||
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_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.model_manager import ModelInstance
|
||||
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.tools.entities.tool_entities import ToolRuntimeVariablePool
|
||||
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
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -4,8 +4,7 @@ from typing import Optional
|
|||
from core.app_runner.app_runner import AppRunner
|
||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||
from core.entities.application_entities import (ApplicationGenerateEntity, DatasetEntity,
|
||||
InvokeFrom, ModelConfigEntity)
|
||||
from core.entities.application_entities import ApplicationGenerateEntity, DatasetEntity, InvokeFrom, ModelConfigEntity
|
||||
from core.features.dataset_retrieval import DatasetRetrievalFeature
|
||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||
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.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||
from core.entities.application_entities import ApplicationGenerateEntity, InvokeFrom
|
||||
from core.entities.queue_entities import (AnnotationReplyEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
||||
QueueMessageEndEvent, QueueMessageEvent, QueueMessageReplaceEvent,
|
||||
QueuePingEvent, QueueRetrieverResourcesEvent, QueueStopEvent,
|
||||
QueueMessageFileEvent, QueueAgentMessageEvent)
|
||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
||||
from core.entities.queue_entities import (AnnotationReplyEvent, QueueAgentMessageEvent, QueueAgentThoughtEvent,
|
||||
QueueErrorEvent, QueueMessageEndEvent, QueueMessageEvent,
|
||||
QueueMessageFileEvent, QueueMessageReplaceEvent, QueuePingEvent,
|
||||
QueueRetrieverResourcesEvent, QueueStopEvent)
|
||||
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.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||
PromptMessage, PromptMessageContentType, PromptMessageRole,
|
||||
TextPromptMessageContent)
|
||||
from core.model_runtime.errors.invoke import InvokeAuthorizationError, InvokeError
|
||||
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.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 extensions.ext_database import db
|
||||
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.application_queue_manager import ApplicationQueueManager, ConversationTaskStoppedException, PublishFrom
|
||||
from core.entities.application_entities import (AdvancedChatPromptTemplateEntity,
|
||||
AdvancedCompletionPromptTemplateEntity, AgentEntity, AgentToolEntity,
|
||||
ApplicationGenerateEntity, AppOrchestrationConfigEntity, DatasetEntity,
|
||||
AdvancedCompletionPromptTemplateEntity, AgentEntity, AgentPromptEntity,
|
||||
AgentToolEntity, ApplicationGenerateEntity,
|
||||
AppOrchestrationConfigEntity, DatasetEntity,
|
||||
DatasetRetrieveConfigEntity, ExternalDataVariableEntity,
|
||||
FileUploadEntity, InvokeFrom, ModelConfigEntity, PromptTemplateEntity,
|
||||
SensitiveWordAvoidanceEntity, AgentPromptEntity)
|
||||
SensitiveWordAvoidanceEntity)
|
||||
from core.entities.model_entities import ModelStatus
|
||||
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||
from core.file.file_obj import FileObj
|
||||
|
|
|
@ -4,10 +4,10 @@ from enum import Enum
|
|||
from typing import Any, Generator
|
||||
|
||||
from core.entities.application_entities import InvokeFrom
|
||||
from core.entities.queue_entities import (AnnotationReplyEvent, AppQueueEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
||||
QueueMessage, QueueMessageEndEvent, QueueMessageEvent,
|
||||
QueueMessageReplaceEvent, QueuePingEvent, QueueRetrieverResourcesEvent,
|
||||
QueueStopEvent, QueueMessageFileEvent, QueueAgentMessageEvent)
|
||||
from core.entities.queue_entities import (AnnotationReplyEvent, AppQueueEvent, QueueAgentMessageEvent,
|
||||
QueueAgentThoughtEvent, QueueErrorEvent, QueueMessage, QueueMessageEndEvent,
|
||||
QueueMessageEvent, QueueMessageFileEvent, QueueMessageReplaceEvent,
|
||||
QueuePingEvent, QueueRetrieverResourcesEvent, QueueStopEvent)
|
||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
|
||||
from extensions.ext_redis import redis_client
|
||||
from models.model import MessageAgentThought, MessageFile
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import os
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from pydantic import BaseModel
|
||||
|
||||
from langchain.callbacks.base import BaseCallbackHandler
|
||||
from langchain.input import print_text
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class DifyAgentCallbackHandler(BaseCallbackHandler, BaseModel):
|
||||
"""Callback Handler that prints to std out."""
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
from typing import List
|
||||
|
||||
from langchain.document_loaders.base import BaseLoader
|
||||
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.model_providers.__base.text_embedding_model import TextEmbeddingModel
|
||||
from extensions.ext_database import db
|
||||
from langchain.embeddings.base import Embeddings
|
||||
|
||||
from extensions.ext_redis import redis_client
|
||||
from langchain.embeddings.base import Embeddings
|
||||
from libs import helper
|
||||
from models.dataset import Embedding
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
from enum import Enum
|
||||
from typing import Optional, Any, cast, Literal, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing import Any, Literal, Optional, Union, cast
|
||||
|
||||
from core.entities.provider_configuration import ProviderModelBundle
|
||||
from core.file.file_obj import FileObj
|
||||
from core.model_runtime.entities.message_entities import PromptMessageRole
|
||||
from core.model_runtime.entities.model_entities import AIModelEntity
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ModelConfigEntity(BaseModel):
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
import logging
|
||||
from typing import cast, Optional, List
|
||||
|
||||
from langchain import WikipediaAPIWrapper
|
||||
from langchain.callbacks.base import BaseCallbackHandler
|
||||
from langchain.tools import BaseTool, WikipediaQueryRun, Tool
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional, cast
|
||||
|
||||
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.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||
from core.callback_handler.std_out_callback_handler import DifyStdOutCallbackHandler
|
||||
from core.entities.application_entities import ModelConfigEntity, InvokeFrom, \
|
||||
AgentEntity, AgentToolEntity, AppOrchestrationConfigEntity
|
||||
from core.entities.application_entities import (AgentEntity, AgentToolEntity, AppOrchestrationConfigEntity, InvokeFrom,
|
||||
ModelConfigEntity)
|
||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||
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.__base.large_language_model import LargeLanguageModel
|
||||
from core.tools.tool.dataset_retriever.dataset_retriever_tool import DatasetRetrieverTool
|
||||
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.model import Message
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,37 +1,32 @@
|
|||
import logging
|
||||
import json
|
||||
|
||||
from typing import Optional, List, Tuple, Union, cast
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from mimetypes import guess_extension
|
||||
from typing import List, Optional, Tuple, Union, cast
|
||||
|
||||
from core.app_runner.app_runner import AppRunner
|
||||
from extensions.ext_database import db
|
||||
|
||||
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.application_queue_manager import ApplicationQueueManager
|
||||
from core.callback_handler.agent_tool_callback_handler import DifyAgentCallbackHandler
|
||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
||||
from core.entities.application_entities import ModelConfigEntity, AgentEntity, AgentToolEntity
|
||||
from core.application_queue_manager import ApplicationQueueManager
|
||||
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.entities.application_entities import (AgentEntity, AgentToolEntity, ApplicationGenerateEntity,
|
||||
AppOrchestrationConfigEntity, InvokeFrom, ModelConfigEntity)
|
||||
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__)
|
||||
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
import json
|
||||
import logging
|
||||
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.model_runtime.utils.encoders import jsonable_encoder
|
||||
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.entities.application_entities import AgentPromptEntity, AgentScratchpadUnit
|
||||
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
|
||||
|
||||
|
||||
class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
|
||||
def run(self, conversation: Conversation,
|
||||
message: Message,
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
import json
|
||||
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.tools.errors import ToolInvokeError, ToolNotFoundError, \
|
||||
ToolNotSupportedError, ToolProviderNotFoundError, ToolParameterValidationError, \
|
||||
ToolProviderCredentialValidationError
|
||||
|
||||
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
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from typing import Dict, List, Optional, Union
|
||||
|
||||
import requests
|
||||
from core.file.file_obj import FileObj, FileTransferMethod, FileType, FileBelongsTo
|
||||
from services.file_service import IMAGE_EXTENSIONS
|
||||
from core.file.file_obj import FileBelongsTo, FileObj, FileTransferMethod, FileType
|
||||
from extensions.ext_database import db
|
||||
from models.account import Account
|
||||
from models.model import AppModelConfig, EndUser, MessageFile, UploadFile
|
||||
from services.file_service import IMAGE_EXTENSIONS
|
||||
|
||||
|
||||
class MessageFileParser:
|
||||
|
|
|
@ -2,7 +2,7 @@ from typing import Optional
|
|||
|
||||
from core.entities.provider_entities import QuotaUnit, RestrictModel
|
||||
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 pydantic import BaseModel
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ from core.docstore.dataset_docstore import DatasetDocumentStore
|
|||
from core.errors.error import ProviderTokenNotInitError
|
||||
from core.generator.llm_generator import LLMGenerator
|
||||
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.model_providers.__base.large_language_model import LargeLanguageModel
|
||||
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.rerank_model import RerankModel
|
||||
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.tts_model import TTSModel
|
||||
from core.provider_manager import ProviderManager
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import uuid
|
||||
import hashlib
|
||||
import subprocess
|
||||
import uuid
|
||||
from abc import abstractmethod
|
||||
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.entities.model_entities import ModelType
|
||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||
from core.model_runtime.entities.model_entities import ModelPropertyKey
|
||||
|
||||
|
||||
class TTSModel(AIModel):
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import json
|
||||
import logging
|
||||
from typing import Generator, List, Optional, Union
|
||||
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError, EndpointConnectionError, NoRegionError, ServiceNotInRegionError, UnknownServiceError
|
||||
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.message_entities import (AssistantPromptMessage, PromptMessage,
|
||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage)
|
||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||
SystemPromptMessage, UserPromptMessage)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
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.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageFunction,
|
||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
||||
PromptMessageTool, SystemPromptMessage, ToolPromptMessage,
|
||||
UserPromptMessage)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import logging
|
||||
from typing import Generator, List, Optional, Union, cast, Tuple
|
||||
from typing import Generator, List, Optional, Tuple, Union, cast
|
||||
|
||||
import cohere
|
||||
from cohere.responses import Chat, Generations
|
||||
from cohere.responses.chat import StreamingChat, StreamTextGeneration, StreamEnd
|
||||
from cohere.responses.generation import StreamingText, StreamingGenerations
|
||||
|
||||
from cohere.responses.chat import StreamEnd, StreamingChat, StreamTextGeneration
|
||||
from cohere.responses.generation import StreamingGenerations, StreamingText
|
||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage,
|
||||
PromptMessageContentType, SystemPromptMessage,
|
||||
TextPromptMessageContent, UserPromptMessage,
|
||||
PromptMessageTool)
|
||||
PromptMessageContentType, PromptMessageTool,
|
||||
SystemPromptMessage, TextPromptMessageContent,
|
||||
UserPromptMessage)
|
||||
from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, I18nObject, ModelType
|
||||
from core.model_runtime.errors.invoke import InvokeConnectionError, InvokeServerUnavailableError, InvokeError, \
|
||||
InvokeRateLimitError, InvokeAuthorizationError, InvokeBadRequestError
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ from typing import Optional, Tuple
|
|||
import cohere
|
||||
import numpy as np
|
||||
from cohere.responses import Tokens
|
||||
|
||||
from core.model_runtime.entities.model_entities import PriceType
|
||||
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||
from core.model_runtime.errors.invoke import InvokeConnectionError, InvokeServerUnavailableError, InvokeRateLimitError, \
|
||||
InvokeAuthorizationError, InvokeBadRequestError, InvokeError
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
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.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||
SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
||||
SystemPromptMessage, ToolPromptMessage, UserPromptMessage)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
|
|
|
@ -2,21 +2,20 @@ import json
|
|||
import logging
|
||||
import re
|
||||
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
|
||||
|
||||
import requests
|
||||
|
||||
from core.model_runtime.entities.message_entities import PromptMessageTool, PromptMessage, AssistantPromptMessage, \
|
||||
UserPromptMessage, PromptMessageContentType, ImagePromptMessageContent, \
|
||||
TextPromptMessageContent, SystemPromptMessage
|
||||
from core.model_runtime.entities.model_entities import I18nObject, ModelType, \
|
||||
PriceConfig, AIModelEntity, FetchFrom, ModelPropertyKey, ParameterRule, ParameterType, DefaultParameterName, \
|
||||
ModelFeature
|
||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, \
|
||||
LLMResultChunk, LLMResultChunkDelta
|
||||
from core.model_runtime.errors.invoke import InvokeError, InvokeAuthorizationError, InvokeBadRequestError, \
|
||||
InvokeRateLimitError, InvokeServerUnavailableError, InvokeConnectionError
|
||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||
PromptMessage, PromptMessageContentType, PromptMessageTool,
|
||||
SystemPromptMessage, TextPromptMessageContent,
|
||||
UserPromptMessage)
|
||||
from core.model_runtime.entities.model_entities import (AIModelEntity, DefaultParameterName, FetchFrom, I18nObject,
|
||||
ModelFeature, ModelPropertyKey, ModelType, ParameterRule,
|
||||
ParameterType, PriceConfig)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import json
|
||||
import logging
|
||||
import time
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
from urllib.parse import urljoin
|
||||
import requests
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
|
||||
import requests
|
||||
from core.model_runtime.entities.common_entities import I18nObject
|
||||
from core.model_runtime.entities.model_entities import PriceType, ModelPropertyKey, ModelType, AIModelEntity, FetchFrom, \
|
||||
PriceConfig
|
||||
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult, EmbeddingUsage
|
||||
from core.model_runtime.errors.invoke import InvokeError, InvokeAuthorizationError, InvokeBadRequestError, \
|
||||
InvokeRateLimitError, InvokeServerUnavailableError, InvokeConnectionError
|
||||
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelPropertyKey, ModelType,
|
||||
PriceConfig, PriceType)
|
||||
from core.model_runtime.entities.text_embedding_entities import EmbeddingUsage, TextEmbeddingResult
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
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 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.validate import CredentialsValidateFailedError
|
||||
from core.model_runtime.model_providers.__base.tts_model import TTSModel
|
||||
from core.model_runtime.model_providers.openai._common import _CommonOpenAI
|
||||
|
||||
from flask import Response, stream_with_context
|
||||
from openai import OpenAI
|
||||
import concurrent.futures
|
||||
from pydub import AudioSegment
|
||||
|
||||
|
||||
class OpenAIText2SpeechModel(_CommonOpenAI, TTSModel):
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
from typing import Generator, List, Optional, Union
|
||||
|
||||
from dashscope import get_tokenizer
|
||||
|
||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMMode
|
||||
from core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta
|
||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||
SystemPromptMessage, UserPromptMessage)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||
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.common.error import (AuthenticationError, InvalidParameter, RequestFailure, ServiceUnavailableError,
|
||||
UnsupportedHTTPMethod, UnsupportedModel)
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import concurrent.futures
|
||||
from functools import reduce
|
||||
from io import BytesIO
|
||||
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
|
||||
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
|
||||
import concurrent.futures
|
||||
from pydub import AudioSegment
|
||||
|
||||
|
||||
class TongyiText2SpeechModel(_CommonTongyi, TTSModel):
|
||||
|
|
|
@ -3,15 +3,15 @@ from typing import Generator, Iterator, List, Optional, Union, cast
|
|||
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.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageTool,
|
||||
SystemPromptMessage, UserPromptMessage, ToolPromptMessage)
|
||||
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelPropertyKey, ModelType,
|
||||
ParameterRule, ParameterType, ModelFeature)
|
||||
SystemPromptMessage, ToolPromptMessage, UserPromptMessage)
|
||||
from core.model_runtime.entities.model_entities import (AIModelEntity, FetchFrom, ModelFeature, ModelPropertyKey,
|
||||
ModelType, ParameterRule, ParameterType)
|
||||
from core.model_runtime.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
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.xinference.xinference_helper import (XinferenceHelper,
|
||||
XinferenceModelExtraParameter)
|
||||
XinferenceModelExtraParameter)
|
||||
from core.model_runtime.utils import helper
|
||||
from openai import (APIConnectionError, APITimeoutError, AuthenticationError, ConflictError, InternalServerError,
|
||||
NotFoundError, OpenAI, PermissionDeniedError, RateLimitError, Stream, UnprocessableEntityError)
|
||||
|
|
|
@ -2,15 +2,15 @@ import time
|
|||
from typing import Optional
|
||||
|
||||
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.errors.invoke import (InvokeAuthorizationError, InvokeBadRequestError, InvokeConnectionError,
|
||||
InvokeError, InvokeRateLimitError, InvokeServerUnavailableError)
|
||||
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.xinference.xinference_helper import XinferenceHelper
|
||||
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):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from os import path
|
||||
from threading import Lock
|
||||
from time import time
|
||||
from typing import List
|
||||
from os import path
|
||||
|
||||
from requests import get
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
|
|
@ -2,16 +2,19 @@ import json
|
|||
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.message_entities import (AssistantPromptMessage, PromptMessage, PromptMessageRole,
|
||||
PromptMessageTool, SystemPromptMessage, UserPromptMessage, ToolPromptMessage,
|
||||
TextPromptMessageContent, ImagePromptMessageContent, PromptMessageContentType)
|
||||
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||
PromptMessage, PromptMessageContentType, PromptMessageRole,
|
||||
PromptMessageTool, SystemPromptMessage,
|
||||
TextPromptMessageContent, ToolPromptMessage,
|
||||
UserPromptMessage)
|
||||
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.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.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_chunk import ChatCompletionChunk
|
||||
from core.model_runtime.utils import helper
|
||||
|
||||
|
||||
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.errors.validate import CredentialsValidateFailedError
|
||||
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.zhipuai_sdk._client import ZhipuAI
|
||||
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 ._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 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
|
||||
from typing import Mapping, Union
|
||||
|
||||
import httpx
|
||||
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):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from .chat import chat
|
||||
from .images import Images
|
||||
from .embeddings import Embeddings
|
||||
from .files import Files
|
||||
from .fine_tuning import fine_tuning
|
||||
from .images import Images
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, List, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
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 ...types.chat.async_chat_completion import AsyncTaskStatus, AsyncCompletion
|
||||
from ...types.chat.async_chat_completion import AsyncCompletion, AsyncTaskStatus
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZhipuAI
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from typing import TYPE_CHECKING
|
||||
from .completions import Completions
|
||||
from .async_completions import AsyncCompletions
|
||||
|
||||
from ...core._base_api import BaseAPI
|
||||
from .async_completions import AsyncCompletions
|
||||
from .completions import Completions
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZhipuAI
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, List, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
import httpx
|
||||
from typing_extensions import Literal
|
||||
|
||||
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._sse_client import StreamResponse
|
||||
from ...types.chat.chat_completion import Completion
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, List, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
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 ..types.embeddings import EmbeddingsResponded
|
||||
|
||||
|
|
|
@ -5,11 +5,9 @@ from typing import TYPE_CHECKING
|
|||
import httpx
|
||||
|
||||
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._http_client import (
|
||||
make_user_request_input,
|
||||
)
|
||||
from ..core._http_client import make_user_request_input
|
||||
from ..types.file_object import FileObject, ListOfFileObject
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from typing import TYPE_CHECKING
|
||||
from .jobs import Jobs
|
||||
|
||||
from ...core._base_api import BaseAPI
|
||||
from .jobs import Jobs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZhipuAI
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
import httpx
|
||||
|
||||
from ...core._base_api import BaseAPI
|
||||
from ...core._base_type import NOT_GIVEN, Headers, NotGiven
|
||||
from ...core._http_client import (
|
||||
make_user_request_input,
|
||||
)
|
||||
from ...types.fine_tuning import (
|
||||
FineTuningJob,
|
||||
job_create_params,
|
||||
ListOfFineTuningJob,
|
||||
FineTuningJobEvent,
|
||||
)
|
||||
from ...core._http_client import make_user_request_input
|
||||
from ...types.fine_tuning import FineTuningJob, FineTuningJobEvent, ListOfFineTuningJob, job_create_params
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..._client import ZhipuAI
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, List, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
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 ..types.image import ImagesResponded
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from os import PathLike
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Type,
|
||||
Union,
|
||||
Mapping,
|
||||
TypeVar, IO, Tuple, Sequence, Any, List,
|
||||
)
|
||||
from typing import IO, TYPE_CHECKING, Any, List, Mapping, Sequence, Tuple, Type, TypeVar, Union
|
||||
|
||||
import pydantic
|
||||
from typing_extensions import (
|
||||
Literal,
|
||||
override,
|
||||
)
|
||||
|
||||
from typing_extensions import Literal, override
|
||||
|
||||
Query = Mapping[str, object]
|
||||
Body = object
|
||||
|
|
|
@ -5,12 +5,7 @@ import os
|
|||
from pathlib import Path
|
||||
from typing import Mapping, Sequence
|
||||
|
||||
from ._base_type import (
|
||||
FileTypes,
|
||||
HttpxFileTypes,
|
||||
HttpxRequestFiles,
|
||||
RequestFiles,
|
||||
)
|
||||
from ._base_type import FileTypes, HttpxFileTypes, HttpxRequestFiles, RequestFiles
|
||||
|
||||
|
||||
def is_file_content(obj: object) -> bool:
|
||||
|
|
|
@ -2,20 +2,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from typing import (
|
||||
Any,
|
||||
Type,
|
||||
Union,
|
||||
cast,
|
||||
Mapping,
|
||||
)
|
||||
from typing import Any, Mapping, Type, Union, cast
|
||||
|
||||
import httpx
|
||||
import pydantic
|
||||
from httpx import URL, Timeout
|
||||
|
||||
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 ._files import make_httpx_files
|
||||
from ._request_opt import ClientRequestParam, UserRequestInput
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, Any, cast
|
||||
from typing import Any, Union, cast
|
||||
|
||||
import pydantic.generics
|
||||
from httpx import Timeout
|
||||
from pydantic import ConfigDict
|
||||
from typing_extensions import (
|
||||
Unpack, ClassVar, TypedDict
|
||||
)
|
||||
from typing_extensions import ClassVar, TypedDict, Unpack
|
||||
|
||||
from ._base_type import Body, NotGiven, Headers, HttpxRequestFiles, Query
|
||||
from ._base_type import Body, Headers, HttpxRequestFiles, NotGiven, Query
|
||||
from ._utils import remove_notgiven_indict
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TypeVar, Generic, cast, Any, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast
|
||||
|
||||
import httpx
|
||||
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 ._sse_client import StreamResponse
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Generic, Iterator, TYPE_CHECKING, Mapping
|
||||
from typing import TYPE_CHECKING, Generic, Iterator, Mapping
|
||||
|
||||
import httpx
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Mapping, Iterable, TypeVar
|
||||
from typing import Iterable, Mapping, TypeVar
|
||||
|
||||
from ._base_type import NotGiven
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .chat.chat_completion import CompletionUsage
|
||||
|
||||
__all__ = ["Embedding", "EmbeddingsResponded"]
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional, List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from typing import List, Union, Optional
|
||||
from typing_extensions import Literal
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing_extensions import Literal
|
||||
|
||||
__all__ = ["FineTuningJob", "Error", "Hyperparameters", "ListOfFineTuningJob" ]
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from typing import List, Union, Optional
|
||||
from typing_extensions import Literal
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing_extensions import Literal
|
||||
|
||||
__all__ = ["FineTuningJobEvent", "Metric", "JobEvent"]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from pydantic import BaseModel
|
||||
from typing import Dict, Optional, Any, List
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
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):
|
||||
"""
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from pydantic import BaseModel, Field
|
||||
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 pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ToolProviderType(Enum):
|
||||
"""
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from pydantic import BaseModel
|
||||
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.tool_entities import ToolProviderCredentials
|
||||
from core.tools.tool.tool import ToolParameter
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class UserToolProvider(BaseModel):
|
||||
class ProviderType(Enum):
|
||||
|
|
|
@ -4,23 +4,21 @@
|
|||
Therefore, a model manager is needed to list/invoke/validate models.
|
||||
"""
|
||||
|
||||
from core.model_runtime.entities.message_entities import PromptMessage
|
||||
from core.model_runtime.entities.llm_entities import LLMResult
|
||||
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
|
||||
import json
|
||||
from typing import List, cast
|
||||
|
||||
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 extensions.ext_database import db
|
||||
|
||||
from models.tools import ToolModelInvoke
|
||||
|
||||
from typing import List, cast
|
||||
import json
|
||||
|
||||
class ToolModelManager:
|
||||
@staticmethod
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
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.tool_bundle import ApiBasedToolBundle
|
||||
from core.tools.tool.tool import Tool
|
||||
from core.tools.tool.api_tool import ApiTool
|
||||
from core.tools.entities.tool_entities import (ApiProviderAuthType, ToolCredentialsOption, ToolProviderCredentials,
|
||||
ToolProviderType)
|
||||
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 models.tools import ApiToolProvider
|
||||
|
||||
|
||||
class ApiBasedToolProviderController(ToolProviderController):
|
||||
@staticmethod
|
||||
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
|
||||
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__)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from core.tools.entities.user_entities import UserToolProvider
|
||||
from typing import List
|
||||
|
||||
from core.tools.entities.user_entities import UserToolProvider
|
||||
|
||||
position = {
|
||||
'google': 1,
|
||||
'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 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):
|
||||
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
||||
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 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
|
||||
|
||||
|
||||
class DallE3Tool(BuiltinTool):
|
||||
def _invoke(self,
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
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):
|
||||
def _invoke(self, user_id: str, tool_parameters: Dict[str, Any]) \
|
||||
-> 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
|
||||
|
||||
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):
|
||||
def _invoke(self,
|
||||
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
|
||||
|
||||
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):
|
||||
def _invoke(self,
|
||||
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 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):
|
||||
def _validate_credentials(self, credentials: Dict[str, Any]) -> None:
|
||||
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 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
|
||||
|
||||
|
||||
class DallE2Tool(BuiltinTool):
|
||||
def _invoke(self,
|
||||
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 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
|
||||
|
||||
|
||||
class DallE3Tool(BuiltinTool):
|
||||
def _invoke(self,
|
||||
user_id: str,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import requests
|
||||
import urllib.parse
|
||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||
|
||||
import requests
|
||||
from core.tools.errors import ToolProviderCredentialValidationError
|
||||
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
|
||||
|
||||
|
||||
class GaodeProvider(BuiltinToolProviderController):
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
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
|
||||
|
||||
import requests
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||
from core.tools.tool.builtin_tool import BuiltinTool
|
||||
|
||||
|
||||
class GaodeRepositoriesTool(BuiltinTool):
|
||||
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