mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
improve: introduce isort for linting Python imports (#1983)
This commit is contained in:
parent
cca9edc97a
commit
cc9e74123c
2
.github/linters/.isort.cfg
vendored
Normal file
2
.github/linters/.isort.cfg
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[settings]
|
||||||
|
line_length=120
|
33
api/app.py
33
api/app.py
|
@ -13,30 +13,29 @@ if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
|
||||||
import langchain
|
import langchain
|
||||||
langchain.verbose = True
|
langchain.verbose = True
|
||||||
|
|
||||||
import time
|
|
||||||
import logging
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
import warnings
|
||||||
|
|
||||||
from flask import Flask, request, Response
|
from commands import register_commands
|
||||||
from flask_cors import CORS
|
from config import CloudEditionConfig, Config
|
||||||
|
from events import event_handlers
|
||||||
from extensions import ext_celery, ext_sentry, ext_redis, ext_login, ext_migrate, \
|
from extensions import (ext_celery, ext_code_based_extension, ext_database, ext_hosting_provider, ext_login, ext_mail,
|
||||||
ext_database, ext_storage, ext_mail, ext_code_based_extension, ext_hosting_provider
|
ext_migrate, ext_redis, ext_sentry, ext_storage)
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from extensions.ext_login import login_manager
|
from extensions.ext_login import login_manager
|
||||||
|
from flask import Flask, Response, request
|
||||||
|
from flask_cors import CORS
|
||||||
|
from libs.passport import PassportService
|
||||||
# DO NOT REMOVE BELOW
|
# DO NOT REMOVE BELOW
|
||||||
from models import model, account, dataset, web, task, source, tool
|
from models import account, dataset, model, source, task, tool, web
|
||||||
from events import event_handlers
|
from services.account_service import AccountService
|
||||||
|
|
||||||
# DO NOT REMOVE ABOVE
|
# DO NOT REMOVE ABOVE
|
||||||
|
|
||||||
from config import Config, CloudEditionConfig
|
|
||||||
from commands import register_commands
|
|
||||||
from services.account_service import AccountService
|
|
||||||
from libs.passport import PassportService
|
|
||||||
|
|
||||||
import warnings
|
|
||||||
warnings.simplefilter("ignore", ResourceWarning)
|
warnings.simplefilter("ignore", ResourceWarning)
|
||||||
|
|
||||||
# fix windows platform
|
# fix windows platform
|
||||||
|
@ -136,10 +135,10 @@ def unauthorized_handler():
|
||||||
|
|
||||||
# register blueprint routers
|
# register blueprint routers
|
||||||
def register_blueprints(app):
|
def register_blueprints(app):
|
||||||
from controllers.service_api import bp as service_api_bp
|
|
||||||
from controllers.web import bp as web_bp
|
|
||||||
from controllers.console import bp as console_app_bp
|
from controllers.console import bp as console_app_bp
|
||||||
from controllers.files import bp as files_bp
|
from controllers.files import bp as files_bp
|
||||||
|
from controllers.service_api import bp as service_api_bp
|
||||||
|
from controllers.web import bp as web_bp
|
||||||
|
|
||||||
CORS(service_api_bp,
|
CORS(service_api_bp,
|
||||||
allow_headers=['Content-Type', 'Authorization', 'X-App-Code'],
|
allow_headers=['Content-Type', 'Authorization', 'X-App-Code'],
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
|
import secrets
|
||||||
import string
|
import string
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
@ -9,26 +11,22 @@ import uuid
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import qdrant_client
|
import qdrant_client
|
||||||
from qdrant_client.http.models import TextIndexParams, TextIndexType, TokenizerType
|
|
||||||
from tqdm import tqdm
|
|
||||||
from flask import current_app, Flask
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from core.embedding.cached_embedding import CacheEmbedding
|
from core.embedding.cached_embedding import CacheEmbedding
|
||||||
from core.index.index import IndexBuilder
|
from core.index.index import IndexBuilder
|
||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from libs.password import password_pattern, valid_password, hash_password
|
|
||||||
from libs.helper import email as email_validate
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import Flask, current_app
|
||||||
|
from libs.helper import email as email_validate
|
||||||
|
from libs.password import hash_password, password_pattern, valid_password
|
||||||
from libs.rsa import generate_key_pair
|
from libs.rsa import generate_key_pair
|
||||||
from models.account import InvitationCode, Tenant, TenantAccountJoin
|
from models.account import InvitationCode, Tenant, TenantAccountJoin
|
||||||
from models.dataset import Dataset, DatasetQuery, Document, DatasetCollectionBinding
|
from models.dataset import Dataset, DatasetCollectionBinding, DatasetQuery, Document
|
||||||
from models.model import Account, AppModelConfig, App, MessageAnnotation, Message
|
from models.model import Account, App, AppModelConfig, Message, MessageAnnotation
|
||||||
import secrets
|
from models.provider import Provider, ProviderModel, ProviderQuotaType, ProviderType
|
||||||
import base64
|
from qdrant_client.http.models import TextIndexParams, TextIndexType, TokenizerType
|
||||||
|
from tqdm import tqdm
|
||||||
from models.provider import Provider, ProviderType, ProviderQuotaType, ProviderModel
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
@click.command('reset-password', help='Reset the account password.')
|
@click.command('reset-password', help='Reset the account password.')
|
||||||
|
@ -362,7 +360,7 @@ def create_qdrant_indexes():
|
||||||
model_provider=model_provider)
|
model_provider=model_provider)
|
||||||
embeddings = CacheEmbedding(embedding_model)
|
embeddings = CacheEmbedding(embedding_model)
|
||||||
|
|
||||||
from core.index.vector_index.qdrant_vector_index import QdrantVectorIndex, QdrantConfig
|
from core.index.vector_index.qdrant_vector_index import QdrantConfig, QdrantVectorIndex
|
||||||
|
|
||||||
index = QdrantVectorIndex(
|
index = QdrantVectorIndex(
|
||||||
dataset=dataset,
|
dataset=dataset,
|
||||||
|
@ -433,7 +431,7 @@ def update_qdrant_indexes():
|
||||||
model_provider=model_provider)
|
model_provider=model_provider)
|
||||||
embeddings = CacheEmbedding(embedding_model)
|
embeddings = CacheEmbedding(embedding_model)
|
||||||
|
|
||||||
from core.index.vector_index.qdrant_vector_index import QdrantVectorIndex, QdrantConfig
|
from core.index.vector_index.qdrant_vector_index import QdrantConfig, QdrantVectorIndex
|
||||||
|
|
||||||
index = QdrantVectorIndex(
|
index = QdrantVectorIndex(
|
||||||
dataset=dataset,
|
dataset=dataset,
|
||||||
|
@ -558,7 +556,7 @@ def deal_dataset_vector(flask_app: Flask, dataset: Dataset, normalization_count:
|
||||||
db.session.add(dataset_collection_binding)
|
db.session.add(dataset_collection_binding)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
from core.index.vector_index.qdrant_vector_index import QdrantVectorIndex, QdrantConfig
|
from core.index.vector_index.qdrant_vector_index import QdrantConfig, QdrantVectorIndex
|
||||||
|
|
||||||
index = QdrantVectorIndex(
|
index = QdrantVectorIndex(
|
||||||
dataset=dataset,
|
dataset=dataset,
|
||||||
|
|
|
@ -3,7 +3,6 @@ import os
|
||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
|
|
||||||
|
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from models.model import AppModelConfig, App
|
from models.model import App, AppModelConfig
|
||||||
|
|
||||||
model_templates = {
|
model_templates = {
|
||||||
# completion default mode
|
# completion default mode
|
||||||
|
|
|
@ -1,29 +1,22 @@
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
from libs.external_api import ExternalApi
|
from libs.external_api import ExternalApi
|
||||||
|
|
||||||
bp = Blueprint('console', __name__, url_prefix='/console/api')
|
bp = Blueprint('console', __name__, url_prefix='/console/api')
|
||||||
api = ExternalApi(bp)
|
api = ExternalApi(bp)
|
||||||
|
|
||||||
# Import other controllers
|
# Import other controllers
|
||||||
from . import extension, setup, version, apikey, admin, feature
|
from . import admin, apikey, extension, feature, setup, version
|
||||||
|
|
||||||
# Import app controllers
|
# Import app controllers
|
||||||
from .app import advanced_prompt_template, app, site, completion, model_config, statistic, conversation, message, generator, audio, annotation
|
from .app import (advanced_prompt_template, annotation, app, audio, completion, conversation, generator, message,
|
||||||
|
model_config, site, statistic)
|
||||||
# Import auth controllers
|
# Import auth controllers
|
||||||
from .auth import login, oauth, data_source_oauth, activate
|
from .auth import activate, data_source_oauth, login, oauth
|
||||||
|
|
||||||
# Import datasets controllers
|
|
||||||
from .datasets import datasets, datasets_document, datasets_segments, file, hit_testing, data_source
|
|
||||||
|
|
||||||
# Import workspace controllers
|
|
||||||
from .workspace import workspace, members, model_providers, account, tool_providers, models
|
|
||||||
|
|
||||||
# Import explore controllers
|
|
||||||
from .explore import installed_app, recommended_app, completion, conversation, message, parameter, saved_message, audio
|
|
||||||
|
|
||||||
# Import universal chat controllers
|
|
||||||
from .universal_chat import chat, conversation, message, parameter, audio
|
|
||||||
|
|
||||||
from .billing import billing
|
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 universal chat controllers
|
||||||
|
from .universal_chat import audio, chat, conversation, message, parameter
|
||||||
|
# Import workspace controllers
|
||||||
|
from .workspace import account, members, model_providers, models, tool_providers, workspace
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
import os
|
import os
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
from werkzeug.exceptions import NotFound, Unauthorized
|
|
||||||
|
|
||||||
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_restful import Resource, reqparse
|
||||||
from libs.helper import supported_language
|
from libs.helper import supported_language
|
||||||
from models.model import RecommendedApp, App, InstalledApp
|
from models.model import App, InstalledApp, RecommendedApp
|
||||||
|
from werkzeug.exceptions import NotFound, Unauthorized
|
||||||
|
|
||||||
|
|
||||||
def admin_required(view):
|
def admin_required(view):
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
import flask_restful
|
import flask_restful
|
||||||
from flask_restful import Resource, fields, marshal_with
|
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import App, ApiToken
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, fields, marshal_with
|
||||||
|
from libs.helper import TimestampField
|
||||||
|
from libs.login import login_required
|
||||||
from models.dataset import Dataset
|
from models.dataset import Dataset
|
||||||
|
from models.model import ApiToken, App
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .setup import setup_required
|
from .setup import setup_required
|
||||||
from .wraps import account_initialization_required
|
from .wraps import account_initialization_required
|
||||||
from libs.helper import TimestampField
|
|
||||||
|
|
||||||
api_key_fields = {
|
api_key_fields = {
|
||||||
'id': fields.String,
|
'id': fields.String,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
from flask_login import current_user
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.console.app.error import AppUnavailableError
|
from controllers.console.app.error import AppUnavailableError
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask_login import current_user
|
||||||
from models.model import App
|
from models.model import App
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
def _get_app(app_id, mode=None):
|
def _get_app(app_id, mode=None):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
|
|
||||||
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_restful import Resource, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.advanced_prompt_template_service import AdvancedPromptTemplateService
|
from services.advanced_prompt_template_service import AdvancedPromptTemplateService
|
||||||
|
|
||||||
|
|
||||||
class AdvancedPromptTemplateList(Resource):
|
class AdvancedPromptTemplateList(Resource):
|
||||||
|
|
||||||
@setup_required
|
@setup_required
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with, marshal
|
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import NoFileUploadedError
|
from controllers.console.app.error import NoFileUploadedError
|
||||||
from controllers.console.datasets.error import TooManyFilesError
|
from controllers.console.datasets.error import TooManyFilesError
|
||||||
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_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
from fields.annotation_fields import annotation_list_fields, annotation_hit_history_list_fields, annotation_fields, \
|
from fields.annotation_fields import (annotation_fields, annotation_hit_history_fields,
|
||||||
annotation_hit_history_fields
|
annotation_hit_history_list_fields, annotation_list_fields)
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal, marshal_with, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.annotation_service import AppAnnotationService
|
from services.annotation_service import AppAnnotationService
|
||||||
from flask import request
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
class AnnotationReplyActionApi(Resource):
|
class AnnotationReplyActionApi(Resource):
|
||||||
|
|
|
@ -3,27 +3,25 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask_login import current_user
|
from constants.model_template import demo_model_templates, model_templates
|
||||||
|
|
||||||
from core.model_manager import ModelManager
|
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
|
||||||
from core.provider_manager import ProviderManager
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with, abort, inputs
|
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
from constants.model_template import model_templates, demo_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
|
||||||
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 core.errors.error import ProviderTokenNotInitError, LLMBadRequestError
|
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
||||||
|
from core.model_manager import ModelManager
|
||||||
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
|
from core.provider_manager import ProviderManager
|
||||||
from events.app_event import app_was_created, app_was_deleted
|
from events.app_event import app_was_created, app_was_deleted
|
||||||
from fields.app_fields import app_pagination_fields, app_detail_fields, template_list_fields, \
|
|
||||||
app_detail_fields_with_site
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from fields.app_fields import (app_detail_fields, app_detail_fields_with_site, app_pagination_fields,
|
||||||
|
template_list_fields)
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, abort, inputs, marshal_with, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from models.model import App, AppModelConfig, Site
|
from models.model import App, AppModelConfig, Site
|
||||||
from services.app_model_config_service import AppModelConfigService
|
from services.app_model_config_service import AppModelConfigService
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
def _get_app(app_id, tenant_id):
|
def _get_app(app_id, tenant_id):
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
|
||||||
|
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
|
||||||
from libs.login import login_required
|
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
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.app.error import AppUnavailableError, \
|
from controllers.console.app.error import (AppUnavailableError, AudioTooLargeError, CompletionRequestError,
|
||||||
ProviderNotInitializeError, CompletionRequestError, ProviderQuotaExceededError, \
|
NoAudioUploadedError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderModelCurrentlyNotSupportError, NoAudioUploadedError, AudioTooLargeError, \
|
ProviderNotInitializeError, ProviderNotSupportSpeechToTextError,
|
||||||
UnsupportedAudioTypeError, ProviderNotSupportSpeechToTextError
|
ProviderQuotaExceededError, UnsupportedAudioTypeError)
|
||||||
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 core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import request
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
from libs.login import login_required
|
||||||
from services.audio_service import AudioService
|
from services.audio_service import AudioService
|
||||||
from services.errors.audio import NoAudioUploadedServiceError, AudioTooLargeServiceError, \
|
from services.errors.audio import (AudioTooLargeServiceError, NoAudioUploadedServiceError,
|
||||||
UnsupportedAudioTypeServiceError, ProviderNotSupportSpeechToTextServiceError
|
ProviderNotSupportSpeechToTextServiceError, UnsupportedAudioTypeServiceError)
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
class ChatMessageAudioApi(Resource):
|
class ChatMessageAudioApi(Resource):
|
||||||
|
|
|
@ -4,27 +4,24 @@ import logging
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
import flask_login
|
import flask_login
|
||||||
from flask import Response, stream_with_context
|
|
||||||
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
|
||||||
from core.entities.application_entities import InvokeFrom
|
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
|
||||||
from libs.login import login_required
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
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.app.error import ConversationCompletedError, AppUnavailableError, \
|
from controllers.console.app.error import (AppUnavailableError, CompletionRequestError, ConversationCompletedError,
|
||||||
ProviderNotInitializeError, CompletionRequestError, ProviderQuotaExceededError, \
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
ProviderModelCurrentlyNotSupportError
|
ProviderQuotaExceededError)
|
||||||
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 core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from libs.helper import uuid_value
|
from core.entities.application_entities import InvokeFrom
|
||||||
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import Response, stream_with_context
|
||||||
from flask_restful import Resource, reqparse
|
from flask_restful import Resource, reqparse
|
||||||
|
from libs.helper import uuid_value
|
||||||
|
from libs.login import login_required
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
# define completion message api for user
|
# define completion message api for user
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from sqlalchemy import or_, func
|
|
||||||
from sqlalchemy.orm import joinedload
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
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
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from fields.conversation_fields import conversation_pagination_fields, conversation_detail_fields, \
|
|
||||||
conversation_message_detail_fields, conversation_with_summary_pagination_fields
|
|
||||||
from libs.helper import datetime_string
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import Message, MessageAnnotation, Conversation
|
from fields.conversation_fields import (conversation_detail_fields, conversation_message_detail_fields,
|
||||||
|
conversation_pagination_fields, conversation_with_summary_pagination_fields)
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
from libs.helper import datetime_string
|
||||||
|
from libs.login import login_required
|
||||||
|
from models.model import Conversation, Message, MessageAnnotation
|
||||||
|
from sqlalchemy import func, or_
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class CompletionConversationApi(Resource):
|
class CompletionConversationApi(Resource):
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ProviderNotInitializeError, ProviderQuotaExceededError, \
|
from controllers.console.app.error import (CompletionRequestError, ProviderModelCurrentlyNotSupportError,
|
||||||
CompletionRequestError, ProviderModelCurrentlyNotSupportError
|
ProviderNotInitializeError, ProviderQuotaExceededError)
|
||||||
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 core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.generator.llm_generator import LLMGenerator
|
from core.generator.llm_generator import LLMGenerator
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
|
|
||||||
|
|
||||||
class RuleGenerateApi(Resource):
|
class RuleGenerateApi(Resource):
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Union, Generator
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with, fields
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound, Forbidden
|
|
||||||
|
|
||||||
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.app.error import CompletionRequestError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppMoreLikeThisDisabledError, CompletionRequestError,
|
||||||
AppMoreLikeThisDisabledError, ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
|
ProviderQuotaExceededError)
|
||||||
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 core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from libs.login import login_required
|
from extensions.ext_database import db
|
||||||
from fields.conversation_fields import message_detail_fields, annotation_fields
|
from fields.conversation_fields import annotation_fields, message_detail_fields
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import uuid_value
|
from libs.helper import uuid_value
|
||||||
from libs.infinite_scroll_pagination import InfiniteScrollPagination
|
from libs.infinite_scroll_pagination import InfiniteScrollPagination
|
||||||
from extensions.ext_database import db
|
from libs.login import login_required
|
||||||
from models.model import MessageAnnotation, Conversation, Message, MessageFeedback
|
from models.model import Conversation, Message, MessageAnnotation, MessageFeedback
|
||||||
from services.annotation_service import AppAnnotationService
|
from services.annotation_service import AppAnnotationService
|
||||||
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
|
||||||
from services.errors.message import MessageNotExistsError
|
from services.errors.message import MessageNotExistsError
|
||||||
from services.message_service import MessageService
|
from services.message_service import MessageService
|
||||||
|
from werkzeug.exceptions import Forbidden, InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class ChatMessageListApi(Resource):
|
class ChatMessageListApi(Resource):
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from flask_restful import Resource
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
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
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from libs.login import login_required
|
|
||||||
from events.app_event import app_model_config_was_updated
|
from events.app_event import app_model_config_was_updated
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource
|
||||||
|
from libs.login import login_required
|
||||||
from models.model import AppModelConfig
|
from models.model import AppModelConfig
|
||||||
from services.app_model_config_service import AppModelConfigService
|
from services.app_model_config_service import AppModelConfigService
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with
|
|
||||||
from werkzeug.exceptions import NotFound, Forbidden
|
|
||||||
|
|
||||||
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
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from fields.app_fields import app_site_fields
|
|
||||||
from libs.helper import supported_language
|
|
||||||
from extensions.ext_database import db
|
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 libs.helper import supported_language
|
||||||
|
from libs.login import login_required
|
||||||
from models.model import Site
|
from models.model import Site
|
||||||
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
|
|
||||||
def parse_app_site_args():
|
def parse_app_site_args():
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from decimal import Decimal
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from flask import jsonify
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
|
|
||||||
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
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from libs.helper import datetime_string
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import jsonify
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
|
from libs.helper import datetime_string
|
||||||
|
from libs.login import login_required
|
||||||
|
|
||||||
|
|
||||||
class DailyConversationStatistic(Resource):
|
class DailyConversationStatistic(Resource):
|
||||||
|
|
|
@ -2,13 +2,12 @@ import base64
|
||||||
import secrets
|
import secrets
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
|
|
||||||
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 libs.helper import email, str_len, supported_language, timezone
|
from libs.helper import email, str_len, supported_language, timezone
|
||||||
from libs.password import valid_password, hash_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
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import request, redirect, current_app
|
from controllers.console import api
|
||||||
|
from flask import current_app, redirect, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from libs.oauth_data_source import NotionOAuth
|
from libs.oauth_data_source import NotionOAuth
|
||||||
from controllers.console import api
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
from ..setup import setup_required
|
from ..setup import setup_required
|
||||||
from ..wraps import account_initialization_required
|
from ..wraps import account_initialization_required
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import flask
|
import flask
|
||||||
import flask_login
|
import flask_login
|
||||||
from flask import request, current_app
|
|
||||||
from flask_restful import Resource, 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 flask import current_app, request
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
from libs.helper import email
|
from libs.helper import email
|
||||||
from libs.password import valid_password
|
from libs.password import valid_password
|
||||||
from services.account_service import AccountService, TenantService
|
from services.account_service import AccountService, TenantService
|
||||||
|
|
|
@ -3,13 +3,13 @@ from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import request, redirect, current_app
|
|
||||||
from flask_restful import Resource
|
|
||||||
|
|
||||||
from libs.oauth import OAuthUserInfo, GitHubOAuth, GoogleOAuth
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import current_app, redirect, request
|
||||||
|
from flask_restful import Resource
|
||||||
|
from libs.oauth import GitHubOAuth, GoogleOAuth, OAuthUserInfo
|
||||||
from models.account import Account, AccountStatus
|
from models.account import Account, AccountStatus
|
||||||
from services.account_service import AccountService, RegisterService
|
from services.account_service import AccountService, RegisterService
|
||||||
|
|
||||||
from .. import api
|
from .. import api
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
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, only_edition_cloud
|
||||||
from controllers.console.wraps import only_edition_cloud
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.billing_service import BillingService
|
from services.billing_service import BillingService
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, marshal_with, reqparse
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
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 core.data_loader.loader.notion import NotionLoader
|
from core.data_loader.loader.notion import NotionLoader
|
||||||
from core.indexing_runner import IndexingRunner
|
from core.indexing_runner import IndexingRunner
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from fields.data_source_fields import integrate_notion_info_list_fields, integrate_list_fields
|
from fields.data_source_fields import integrate_list_fields, integrate_notion_info_list_fields
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal_with, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from models.dataset import Document
|
from models.dataset import Document
|
||||||
from models.source import DataSourceBinding
|
from models.source import DataSourceBinding
|
||||||
from services.dataset_service import DatasetService, DocumentService
|
from services.dataset_service import DatasetService, DocumentService
|
||||||
from tasks.document_indexing_sync_task import document_indexing_sync_task
|
from tasks.document_indexing_sync_task import document_indexing_sync_task
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class DataSourceApi(Resource):
|
class DataSourceApi(Resource):
|
||||||
|
|
|
@ -1,29 +1,28 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import flask_restful
|
import flask_restful
|
||||||
from flask import request, current_app
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
from controllers.console.apikey import api_key_list, api_key_fields
|
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
|
||||||
from core.provider_manager import ProviderManager
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal, marshal_with
|
|
||||||
from werkzeug.exceptions import NotFound, Forbidden
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
|
from controllers.console.apikey import api_key_fields, api_key_list
|
||||||
from controllers.console.app.error import ProviderNotInitializeError
|
from controllers.console.app.error import ProviderNotInitializeError
|
||||||
from controllers.console.datasets.error import DatasetNameDuplicateError
|
from controllers.console.datasets.error import DatasetNameDuplicateError
|
||||||
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 core.indexing_runner import IndexingRunner
|
|
||||||
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
||||||
|
from core.indexing_runner import IndexingRunner
|
||||||
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
|
from core.provider_manager import ProviderManager
|
||||||
|
from extensions.ext_database import db
|
||||||
from fields.app_fields import related_app_list
|
from fields.app_fields import related_app_list
|
||||||
from fields.dataset_fields import dataset_detail_fields, dataset_query_detail_fields
|
from fields.dataset_fields import dataset_detail_fields, dataset_query_detail_fields
|
||||||
from fields.document_fields import document_status_fields
|
from fields.document_fields import document_status_fields
|
||||||
from extensions.ext_database import db
|
from flask import current_app, request
|
||||||
from models.dataset import DocumentSegment, Document
|
from flask_login import current_user
|
||||||
from models.model import UploadFile, ApiToken
|
from flask_restful import Resource, marshal, marshal_with, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
|
from models.dataset import Document, DocumentSegment
|
||||||
|
from models.model import ApiToken, UploadFile
|
||||||
from services.dataset_service import DatasetService, DocumentService
|
from services.dataset_service import DatasetService, DocumentService
|
||||||
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
|
|
||||||
def _validate_name(name):
|
def _validate_name(name):
|
||||||
|
|
|
@ -2,38 +2,35 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from flask import request
|
import services
|
||||||
from flask_login import current_user
|
from controllers.console import api
|
||||||
|
from controllers.console.app.error import (ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
|
ProviderQuotaExceededError)
|
||||||
|
from controllers.console.datasets.error import (ArchivedDocumentImmutableError, DocumentAlreadyFinishedError,
|
||||||
|
DocumentIndexingError, InvalidActionError, InvalidMetadataError)
|
||||||
|
from controllers.console.setup import setup_required
|
||||||
|
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
|
||||||
|
from core.errors.error import (LLMBadRequestError, ModelCurrentlyNotSupportError, ProviderTokenNotInitError,
|
||||||
|
QuotaExceededError)
|
||||||
|
from core.indexing_runner import IndexingRunner
|
||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.errors.invoke import InvokeAuthorizationError
|
from core.model_runtime.errors.invoke import InvokeAuthorizationError
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, fields, marshal, marshal_with, reqparse
|
|
||||||
from sqlalchemy import desc, asc
|
|
||||||
from werkzeug.exceptions import NotFound, Forbidden
|
|
||||||
|
|
||||||
import services
|
|
||||||
from controllers.console import api
|
|
||||||
from controllers.console.app.error import ProviderNotInitializeError, ProviderQuotaExceededError, \
|
|
||||||
ProviderModelCurrentlyNotSupportError
|
|
||||||
from controllers.console.datasets.error import DocumentAlreadyFinishedError, InvalidActionError, DocumentIndexingError, \
|
|
||||||
InvalidMetadataError, ArchivedDocumentImmutableError
|
|
||||||
from controllers.console.setup import setup_required
|
|
||||||
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
|
|
||||||
from core.indexing_runner import IndexingRunner
|
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError, \
|
|
||||||
LLMBadRequestError
|
|
||||||
from extensions.ext_redis import redis_client
|
|
||||||
from fields.document_fields import document_with_segments_fields, document_fields, \
|
|
||||||
dataset_and_document_fields, document_status_fields
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.dataset import DatasetProcessRule, Dataset
|
from extensions.ext_redis import redis_client
|
||||||
from models.dataset import Document, DocumentSegment
|
from fields.document_fields import (dataset_and_document_fields, document_fields, document_status_fields,
|
||||||
|
document_with_segments_fields)
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, fields, marshal, marshal_with, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
|
from models.dataset import Dataset, DatasetProcessRule, Document, DocumentSegment
|
||||||
from models.model import UploadFile
|
from models.model import UploadFile
|
||||||
from services.dataset_service import DocumentService, DatasetService
|
from services.dataset_service import DatasetService, DocumentService
|
||||||
|
from sqlalchemy import asc, desc
|
||||||
from tasks.add_document_to_index_task import add_document_to_index_task
|
from tasks.add_document_to_index_task import add_document_to_index_task
|
||||||
from tasks.remove_document_from_index_task import remove_document_from_index_task
|
from tasks.remove_document_from_index_task import remove_document_from_index_task
|
||||||
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
|
|
||||||
class DocumentResource(Resource):
|
class DocumentResource(Resource):
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import request
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, reqparse, marshal
|
|
||||||
from werkzeug.exceptions import NotFound, Forbidden
|
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ProviderNotInitializeError
|
from controllers.console.app.error import ProviderNotInitializeError
|
||||||
|
@ -15,17 +12,19 @@ from controllers.console.wraps import account_initialization_required, cloud_edi
|
||||||
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from libs.login import login_required
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
from fields.segment_fields import segment_fields
|
from fields.segment_fields import segment_fields
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from models.dataset import DocumentSegment
|
from models.dataset import DocumentSegment
|
||||||
|
|
||||||
from services.dataset_service import DatasetService, DocumentService, SegmentService
|
from services.dataset_service import DatasetService, DocumentService, SegmentService
|
||||||
from tasks.enable_segment_to_index_task import enable_segment_to_index_task
|
|
||||||
from tasks.disable_segment_from_index_task import disable_segment_from_index_task
|
|
||||||
from tasks.batch_create_segment_to_index_task import batch_create_segment_to_index_task
|
from tasks.batch_create_segment_to_index_task import batch_create_segment_to_index_task
|
||||||
import pandas as pd
|
from tasks.disable_segment_from_index_task import disable_segment_from_index_task
|
||||||
|
from tasks.enable_segment_to_index_task import enable_segment_to_index_task
|
||||||
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
|
|
||||||
class DatasetDocumentSegmentListApi(Resource):
|
class DatasetDocumentSegmentListApi(Resource):
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
from flask import request, current_app
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, marshal_with
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.datasets.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \
|
from controllers.console.datasets.error import (FileTooLargeError, NoFileUploadedError, TooManyFilesError,
|
||||||
UnsupportedFileTypeError
|
UnsupportedFileTypeError)
|
||||||
|
|
||||||
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 fields.file_fields import upload_config_fields, file_fields
|
from fields.file_fields import file_fields, upload_config_fields
|
||||||
|
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
|
from services.file_service import FileService
|
||||||
|
|
||||||
PREVIEW_WORDS_LIMIT = 3000
|
PREVIEW_WORDS_LIMIT = 3000
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound, Forbidden
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ProviderNotInitializeError, ProviderQuotaExceededError, \
|
from controllers.console.app.error import (CompletionRequestError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderModelCurrentlyNotSupportError, CompletionRequestError
|
ProviderNotInitializeError, ProviderQuotaExceededError)
|
||||||
from controllers.console.datasets.error import HighQualityDatasetOnlyError, DatasetNotInitializedError
|
from controllers.console.datasets.error import DatasetNotInitializedError, HighQualityDatasetOnlyError
|
||||||
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 core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError, \
|
from core.errors.error import (LLMBadRequestError, ModelCurrentlyNotSupportError, ProviderTokenNotInitError,
|
||||||
LLMBadRequestError
|
QuotaExceededError)
|
||||||
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from fields.hit_testing_fields import hit_testing_record_fields
|
from fields.hit_testing_fields import hit_testing_record_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from services.dataset_service import DatasetService
|
from services.dataset_service import DatasetService
|
||||||
from services.hit_testing_service import HitTestingService
|
from services.hit_testing_service import HitTestingService
|
||||||
|
from werkzeug.exceptions import Forbidden, InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class HitTestingApi(Resource):
|
class HitTestingApi(Resource):
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import AppUnavailableError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppUnavailableError, AudioTooLargeError, CompletionRequestError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError, \
|
NoAudioUploadedError, ProviderModelCurrentlyNotSupportError,
|
||||||
NoAudioUploadedError, AudioTooLargeError, \
|
ProviderNotInitializeError, ProviderNotSupportSpeechToTextError,
|
||||||
UnsupportedAudioTypeError, ProviderNotSupportSpeechToTextError
|
ProviderQuotaExceededError, UnsupportedAudioTypeError)
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from services.audio_service import AudioService
|
from flask import request
|
||||||
from services.errors.audio import NoAudioUploadedServiceError, AudioTooLargeServiceError, \
|
|
||||||
UnsupportedAudioTypeServiceError, ProviderNotSupportSpeechToTextServiceError
|
|
||||||
from models.model import AppModelConfig
|
from models.model import AppModelConfig
|
||||||
|
from services.audio_service import AudioService
|
||||||
|
from services.errors.audio import (AudioTooLargeServiceError, NoAudioUploadedServiceError,
|
||||||
|
ProviderNotSupportSpeechToTextServiceError, UnsupportedAudioTypeServiceError)
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
class ChatAudioApi(InstalledAppResource):
|
class ChatAudioApi(InstalledAppResource):
|
||||||
|
|
|
@ -4,24 +4,24 @@ import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ConversationCompletedError, AppUnavailableError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppUnavailableError, CompletionRequestError, ConversationCompletedError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
from controllers.console.explore.error import NotCompletionAppError, NotChatAppError
|
ProviderQuotaExceededError)
|
||||||
|
from controllers.console.explore.error import NotChatAppError, NotCompletionAppError
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import reqparse
|
||||||
from libs.helper import uuid_value
|
from libs.helper import uuid_value
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
# define completion api for user
|
# define completion api for user
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import fields, reqparse, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.explore.error import NotChatAppError
|
from controllers.console.explore.error import NotChatAppError
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import TimestampField, uuid_value
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.conversation_service import ConversationService
|
from services.conversation_service import ConversationService
|
||||||
from services.errors.conversation import LastConversationNotExistsError, ConversationNotExistsError
|
from services.errors.conversation import ConversationNotExistsError, LastConversationNotExistsError
|
||||||
from services.web_conversation_service import WebConversationService
|
from services.web_conversation_service import WebConversationService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class ConversationListApi(InstalledAppResource):
|
class ConversationListApi(InstalledAppResource):
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with, inputs
|
|
||||||
from sqlalchemy import and_
|
|
||||||
from werkzeug.exceptions import NotFound, Forbidden, BadRequest
|
|
||||||
|
|
||||||
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 controllers.console.wraps import account_initialization_required
|
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 fields.installed_app_fields import installed_app_list_fields
|
from fields.installed_app_fields import installed_app_list_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, inputs, marshal_with, reqparse
|
||||||
|
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 controllers.console.wraps import cloud_edition_billing_resource_check
|
from sqlalchemy import and_
|
||||||
|
from werkzeug.exceptions import BadRequest, Forbidden, NotFound
|
||||||
|
|
||||||
|
|
||||||
class InstalledAppsListApi(Resource):
|
class InstalledAppsListApi(Resource):
|
||||||
|
|
|
@ -3,29 +3,29 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import stream_with_context, Response
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound, InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import AppMoreLikeThisDisabledError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppMoreLikeThisDisabledError, CompletionRequestError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
from controllers.console.explore.error import NotCompletionAppError, AppSuggestedQuestionsAfterAnswerDisabledError, \
|
ProviderQuotaExceededError)
|
||||||
NotChatAppError
|
from controllers.console.explore.error import (AppSuggestedQuestionsAfterAnswerDisabledError, NotChatAppError,
|
||||||
|
NotCompletionAppError)
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
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_login import current_user
|
||||||
|
from flask_restful import marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import uuid_value
|
from libs.helper import 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
|
||||||
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
||||||
from services.message_service import MessageService
|
from services.message_service import MessageService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class MessageListApi(InstalledAppResource):
|
class MessageListApi(InstalledAppResource):
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_restful import marshal_with, fields
|
|
||||||
from flask import current_app
|
|
||||||
|
|
||||||
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 flask import current_app
|
||||||
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import InstalledApp
|
from models.model import InstalledApp
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, fields, marshal_with
|
|
||||||
from sqlalchemy import and_
|
|
||||||
|
|
||||||
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
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, fields, marshal_with
|
||||||
|
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_
|
||||||
|
|
||||||
app_fields = {
|
app_fields = {
|
||||||
'id': fields.String,
|
'id': fields.String,
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse, marshal_with, fields
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.explore.error import NotCompletionAppError
|
from controllers.console.explore.error import NotCompletionAppError
|
||||||
from controllers.console.explore.wraps import InstalledAppResource
|
from controllers.console.explore.wraps import InstalledAppResource
|
||||||
from libs.helper import uuid_value, TimestampField
|
from fields.conversation_fields import message_file_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.errors.message import MessageNotExistsError
|
from services.errors.message import MessageNotExistsError
|
||||||
from services.saved_message_service import SavedMessageService
|
from services.saved_message_service import SavedMessageService
|
||||||
from fields.conversation_fields import message_file_fields
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
feedback_fields = {
|
feedback_fields = {
|
||||||
'rating': fields.String
|
'rating': fields.String
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource
|
||||||
|
from libs.login import login_required
|
||||||
from models.model import InstalledApp
|
from models.model import InstalledApp
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
def installed_app_required(view=None):
|
def installed_app_required(view=None):
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
from flask_restful import Resource, reqparse, marshal_with
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
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 fields.api_based_extension_fields import api_based_extension_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, marshal_with, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from models.api_based_extension import APIBasedExtension
|
from models.api_based_extension import APIBasedExtension
|
||||||
from fields.api_based_extension_fields import api_based_extension_fields
|
|
||||||
from services.code_based_extension_service import CodeBasedExtensionService
|
|
||||||
from services.api_based_extension_service import APIBasedExtensionService
|
from services.api_based_extension_service import APIBasedExtensionService
|
||||||
|
from services.code_based_extension_service import CodeBasedExtensionService
|
||||||
|
|
||||||
|
|
||||||
class CodeBasedExtensionAPI(Resource):
|
class CodeBasedExtensionAPI(Resource):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from flask_restful import Resource
|
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource
|
||||||
|
from services.feature_service import FeatureService
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from services.feature_service import FeatureService
|
|
||||||
|
|
||||||
|
|
||||||
class FeatureApi(Resource):
|
class FeatureApi(Resource):
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask import request, current_app
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import DifySetup
|
from flask import current_app, request
|
||||||
from services.account_service import AccountService, TenantService, RegisterService
|
from flask_restful import Resource, reqparse
|
||||||
|
|
||||||
from libs.helper import email, str_len
|
from libs.helper import email, str_len
|
||||||
from libs.password import valid_password
|
from libs.password import valid_password
|
||||||
|
from models.model import DifySetup
|
||||||
|
from services.account_service import AccountService, RegisterService, TenantService
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .error import AlreadySetupError, NotSetupError
|
from .error import AlreadySetupError, NotSetupError
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import AppUnavailableError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppUnavailableError, AudioTooLargeError, CompletionRequestError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError, \
|
NoAudioUploadedError, ProviderModelCurrentlyNotSupportError,
|
||||||
NoAudioUploadedError, AudioTooLargeError, \
|
ProviderNotInitializeError, ProviderNotSupportSpeechToTextError,
|
||||||
UnsupportedAudioTypeError, ProviderNotSupportSpeechToTextError
|
ProviderQuotaExceededError, UnsupportedAudioTypeError)
|
||||||
from controllers.console.universal_chat.wraps import UniversalChatResource
|
from controllers.console.universal_chat.wraps import UniversalChatResource
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from services.audio_service import AudioService
|
from flask import request
|
||||||
from services.errors.audio import NoAudioUploadedServiceError, AudioTooLargeServiceError, \
|
|
||||||
UnsupportedAudioTypeServiceError, ProviderNotSupportSpeechToTextServiceError
|
|
||||||
from models.model import AppModelConfig
|
from models.model import AppModelConfig
|
||||||
|
from services.audio_service import AudioService
|
||||||
|
from services.errors.audio import (AudioTooLargeServiceError, NoAudioUploadedServiceError,
|
||||||
|
ProviderNotSupportSpeechToTextServiceError, UnsupportedAudioTypeServiceError)
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
class UniversalChatAudioApi(UniversalChatResource):
|
class UniversalChatAudioApi(UniversalChatResource):
|
||||||
|
|
|
@ -2,22 +2,22 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ConversationCompletedError, AppUnavailableError, ProviderNotInitializeError, \
|
from controllers.console.app.error import (AppUnavailableError, CompletionRequestError, ConversationCompletedError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
|
ProviderQuotaExceededError)
|
||||||
from controllers.console.universal_chat.wraps import UniversalChatResource
|
from controllers.console.universal_chat.wraps import UniversalChatResource
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import reqparse
|
||||||
from libs.helper import uuid_value
|
from libs.helper import uuid_value
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class UniversalChatApi(UniversalChatResource):
|
class UniversalChatApi(UniversalChatResource):
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import fields, reqparse, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.universal_chat.wraps import UniversalChatResource
|
from controllers.console.universal_chat.wraps import UniversalChatResource
|
||||||
from fields.conversation_fields import conversation_with_model_config_infinite_scroll_pagination_fields, \
|
from fields.conversation_fields import (conversation_with_model_config_fields,
|
||||||
conversation_with_model_config_fields
|
conversation_with_model_config_infinite_scroll_pagination_fields)
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import TimestampField, uuid_value
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.conversation_service import ConversationService
|
from services.conversation_service import ConversationService
|
||||||
from services.errors.conversation import LastConversationNotExistsError, ConversationNotExistsError
|
from services.errors.conversation import ConversationNotExistsError, LastConversationNotExistsError
|
||||||
from services.web_conversation_service import WebConversationService
|
from services.web_conversation_service import WebConversationService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class UniversalChatConversationListApi(UniversalChatResource):
|
class UniversalChatConversationListApi(UniversalChatResource):
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse, fields, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound, InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.app.error import ProviderNotInitializeError, \
|
from controllers.console.app.error import (CompletionRequestError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, CompletionRequestError
|
ProviderNotInitializeError, ProviderQuotaExceededError)
|
||||||
from controllers.console.explore.error import AppSuggestedQuestionsAfterAnswerDisabledError
|
from controllers.console.explore.error import AppSuggestedQuestionsAfterAnswerDisabledError
|
||||||
from controllers.console.universal_chat.wraps import UniversalChatResource
|
from controllers.console.universal_chat.wraps import UniversalChatResource
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from libs.helper import uuid_value, TimestampField
|
from flask_login import current_user
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.errors.conversation import ConversationNotExistsError
|
from services.errors.conversation import ConversationNotExistsError
|
||||||
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
||||||
from services.message_service import MessageService
|
from services.message_service import MessageService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class UniversalChatMessageListApi(UniversalChatResource):
|
class UniversalChatMessageListApi(UniversalChatResource):
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask_restful import marshal_with, fields
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.universal_chat.wraps import UniversalChatResource
|
from controllers.console.universal_chat.wraps import UniversalChatResource
|
||||||
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import App
|
from models.model import App
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import json
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource
|
|
||||||
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 extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource
|
||||||
|
from libs.login import login_required
|
||||||
from models.model import App, AppModelConfig
|
from models.model import App, AppModelConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_restful import reqparse, Resource
|
from flask_restful import Resource, reqparse
|
||||||
from werkzeug.exceptions import InternalServerError
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
|
|
|
@ -2,21 +2,20 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from flask import current_app, request
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, fields, marshal_with
|
|
||||||
|
|
||||||
from services.errors.account import CurrentPasswordIncorrectError as ServiceCurrentPasswordIncorrectError
|
|
||||||
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, InvalidInvitationCodeError, \
|
from controllers.console.workspace.error import (AccountAlreadyInitedError, CurrentPasswordIncorrectError,
|
||||||
RepeatPasswordNotMatchError, CurrentPasswordIncorrectError
|
InvalidInvitationCodeError, RepeatPasswordNotMatchError)
|
||||||
from controllers.console.wraps import account_initialization_required
|
from controllers.console.wraps import account_initialization_required
|
||||||
from libs.helper import TimestampField, supported_language, timezone
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.account import InvitationCode, AccountIntegrate
|
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, supported_language, timezone
|
||||||
|
from libs.login import login_required
|
||||||
|
from models.account import AccountIntegrate, InvitationCode
|
||||||
from services.account_service import AccountService
|
from services.account_service import AccountService
|
||||||
|
from services.errors.account import CurrentPasswordIncorrectError as ServiceCurrentPasswordIncorrectError
|
||||||
|
|
||||||
account_fields = {
|
account_fields = {
|
||||||
'id': fields.String,
|
'id': fields.String,
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import current_app
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, reqparse, marshal_with, abort, fields, marshal
|
|
||||||
|
|
||||||
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 libs.helper import TimestampField
|
|
||||||
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, marshal_with, reqparse
|
||||||
|
from libs.helper import TimestampField
|
||||||
|
from libs.login import login_required
|
||||||
from models.account import Account, TenantAccountJoin
|
from models.account import Account, TenantAccountJoin
|
||||||
from services.account_service import TenantService, RegisterService
|
from services.account_service import RegisterService, TenantService
|
||||||
|
|
||||||
account_fields = {
|
account_fields = {
|
||||||
'id': fields.String,
|
'id': fields.String,
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from flask import send_file
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import Resource, reqparse
|
|
||||||
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 core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
|
from flask import send_file
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.billing_service import BillingService
|
from services.billing_service import BillingService
|
||||||
from services.model_provider_service import ModelProviderService
|
from services.model_provider_service import ModelProviderService
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
class ModelProviderListApi(Resource):
|
class ModelProviderListApi(Resource):
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse, Resource
|
|
||||||
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 core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, reqparse
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.model_provider_service import ModelProviderService
|
from services.model_provider_service import ModelProviderService
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
class DefaultModelApi(Resource):
|
class DefaultModelApi(Resource):
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, abort, reqparse
|
|
||||||
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 core.tool.provider.errors import ToolValidateFailedError
|
from core.tool.provider.errors import ToolValidateFailedError
|
||||||
from core.tool.provider.tool_provider_service import ToolProviderService
|
from core.tool.provider.tool_provider_service import ToolProviderService
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, abort, reqparse
|
||||||
|
from libs.login import login_required
|
||||||
from models.tool import ToolProvider, ToolProviderName
|
from models.tool import ToolProvider, ToolProviderName
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
class ToolProviderListApi(Resource):
|
class ToolProviderListApi(Resource):
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
import services
|
||||||
from flask_login import current_user
|
|
||||||
from libs.login import login_required
|
|
||||||
from flask_restful import Resource, fields, marshal_with, reqparse, marshal, inputs
|
|
||||||
|
|
||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.admin import admin_required
|
from controllers.console.admin import admin_required
|
||||||
from controllers.console.setup import setup_required
|
from controllers.console.datasets.error import (FileTooLargeError, NoFileUploadedError, TooManyFilesError,
|
||||||
|
UnsupportedFileTypeError)
|
||||||
from controllers.console.error import AccountNotLinkTenantError
|
from controllers.console.error import AccountNotLinkTenantError
|
||||||
|
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 controllers.console.datasets.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, UnsupportedFileTypeError
|
|
||||||
from libs.helper import TimestampField
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import Resource, fields, inputs, marshal, marshal_with, reqparse
|
||||||
|
from libs.helper import TimestampField
|
||||||
|
from libs.login import login_required
|
||||||
from models.account import Tenant
|
from models.account import Tenant
|
||||||
import services
|
|
||||||
from services.account_service import TenantService
|
from services.account_service import TenantService
|
||||||
from services.workspace_service import WorkspaceService
|
|
||||||
from services.file_service import FileService
|
from services.file_service import FileService
|
||||||
|
from services.workspace_service import WorkspaceService
|
||||||
|
|
||||||
provider_fields = {
|
provider_fields = {
|
||||||
'provider_name': fields.String,
|
'provider_name': fields.String,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask import current_app, abort
|
|
||||||
from flask_login import current_user
|
|
||||||
|
|
||||||
from controllers.console.workspace.error import AccountNotInitializedError
|
from controllers.console.workspace.error import AccountNotInitializedError
|
||||||
|
from flask import abort, current_app
|
||||||
|
from flask_login import current_user
|
||||||
from services.feature_service import FeatureService
|
from services.feature_service import FeatureService
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
from libs.external_api import ExternalApi
|
from libs.external_api import ExternalApi
|
||||||
|
|
||||||
bp = Blueprint('files', __name__)
|
bp = Blueprint('files', __name__)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from flask import request, Response
|
|
||||||
from flask_restful import Resource
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.files import api
|
from controllers.files import api
|
||||||
|
from flask import Response, request
|
||||||
|
from flask_restful import Resource
|
||||||
from libs.exception import BaseHTTPException
|
from libs.exception import BaseHTTPException
|
||||||
from services.file_service import FileService
|
|
||||||
from services.account_service import TenantService
|
from services.account_service import TenantService
|
||||||
|
from services.file_service import FileService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class ImagePreviewApi(Resource):
|
class ImagePreviewApi(Resource):
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
from libs.external_api import ExternalApi
|
from libs.external_api import ExternalApi
|
||||||
|
|
||||||
bp = Blueprint('service_api', __name__, url_prefix='/v1')
|
bp = Blueprint('service_api', __name__, url_prefix='/v1')
|
||||||
api = ExternalApi(bp)
|
api = ExternalApi(bp)
|
||||||
|
|
||||||
|
|
||||||
from .app import completion, app, conversation, message, audio, file
|
from .app import app, audio, completion, conversation, file, message
|
||||||
|
from .dataset import dataset, document, segment
|
||||||
from .dataset import document, segment, dataset
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_restful import fields, marshal_with
|
|
||||||
from flask import current_app
|
|
||||||
|
|
||||||
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 flask import current_app
|
||||||
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import App
|
from models.model import App
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app.error import AppUnavailableError, ProviderNotInitializeError, CompletionRequestError, ProviderQuotaExceededError, \
|
from controllers.service_api.app.error import (AppUnavailableError, AudioTooLargeError, CompletionRequestError,
|
||||||
ProviderModelCurrentlyNotSupportError, NoAudioUploadedError, AudioTooLargeError, UnsupportedAudioTypeError, \
|
NoAudioUploadedError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderNotSupportSpeechToTextError
|
ProviderNotInitializeError, ProviderNotSupportSpeechToTextError,
|
||||||
|
ProviderQuotaExceededError, UnsupportedAudioTypeError)
|
||||||
from controllers.service_api.wraps import AppApiResource
|
from controllers.service_api.wraps import AppApiResource
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import request
|
||||||
from models.model import App, AppModelConfig
|
from models.model import App, AppModelConfig
|
||||||
from services.audio_service import AudioService
|
from services.audio_service import AudioService
|
||||||
from services.errors.audio import NoAudioUploadedServiceError, AudioTooLargeServiceError, \
|
from services.errors.audio import (AudioTooLargeServiceError, NoAudioUploadedServiceError,
|
||||||
UnsupportedAudioTypeServiceError, ProviderNotSupportSpeechToTextServiceError
|
ProviderNotSupportSpeechToTextServiceError, UnsupportedAudioTypeServiceError)
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
class AudioApi(AppApiResource):
|
class AudioApi(AppApiResource):
|
||||||
def post(self, app_model: App, end_user):
|
def post(self, app_model: App, end_user):
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Union, Generator
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import stream_with_context, Response
|
|
||||||
from flask_restful import reqparse
|
|
||||||
from werkzeug.exceptions import NotFound, InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
||||||
from controllers.service_api.app.error import AppUnavailableError, ProviderNotInitializeError, NotChatAppError, \
|
from controllers.service_api.app.error import (AppUnavailableError, CompletionRequestError, ConversationCompletedError,
|
||||||
ConversationCompletedError, CompletionRequestError, ProviderQuotaExceededError, \
|
NotChatAppError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderModelCurrentlyNotSupportError
|
ProviderNotInitializeError, ProviderQuotaExceededError)
|
||||||
from controllers.service_api.wraps import AppApiResource
|
from controllers.service_api.wraps import AppApiResource
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_restful import reqparse
|
||||||
from libs.helper import uuid_value
|
from libs.helper import uuid_value
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class CompletionApi(AppApiResource):
|
class CompletionApi(AppApiResource):
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import request
|
import services
|
||||||
from flask_restful import fields, marshal_with, reqparse
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
||||||
from controllers.service_api.app.error import NotChatAppError
|
from controllers.service_api.app.error import NotChatAppError
|
||||||
from controllers.service_api.wraps import AppApiResource
|
from controllers.service_api.wraps import AppApiResource
|
||||||
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
||||||
|
from flask import request
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import TimestampField, uuid_value
|
from libs.helper import TimestampField, uuid_value
|
||||||
import services
|
|
||||||
from services.conversation_service import ConversationService
|
from services.conversation_service import ConversationService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class ConversationApi(AppApiResource):
|
class ConversationApi(AppApiResource):
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
import services
|
||||||
|
from controllers.service_api import api
|
||||||
|
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
||||||
|
from controllers.service_api.app.error import (FileTooLargeError, NoFileUploadedError, TooManyFilesError,
|
||||||
|
UnsupportedFileTypeError)
|
||||||
|
from controllers.service_api.wraps import AppApiResource
|
||||||
|
from fields.file_fields import file_fields
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import marshal_with
|
from flask_restful import marshal_with
|
||||||
|
|
||||||
from controllers.service_api import api
|
|
||||||
from controllers.service_api.wraps import AppApiResource
|
|
||||||
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
|
||||||
from controllers.service_api.app.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \
|
|
||||||
UnsupportedFileTypeError
|
|
||||||
import services
|
|
||||||
from services.file_service import FileService
|
from services.file_service import FileService
|
||||||
from fields.file_fields import file_fields
|
|
||||||
|
|
||||||
|
|
||||||
class FileApi(AppApiResource):
|
class FileApi(AppApiResource):
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_restful import fields, marshal_with, reqparse
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
from controllers.service_api.app import create_or_update_end_user_for_user_id
|
||||||
from controllers.service_api.app.error import NotChatAppError
|
from controllers.service_api.app.error import NotChatAppError
|
||||||
from controllers.service_api.wraps import AppApiResource
|
from controllers.service_api.wraps import AppApiResource
|
||||||
from libs.helper import TimestampField, uuid_value
|
|
||||||
from services.message_service import MessageService
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import Message, EndUser
|
|
||||||
from fields.conversation_fields import message_file_fields
|
from fields.conversation_fields import message_file_fields
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
from libs.helper import TimestampField, uuid_value
|
||||||
|
from models.model import EndUser, Message
|
||||||
|
from services.message_service import MessageService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class MessageListApi(AppApiResource):
|
class MessageListApi(AppApiResource):
|
||||||
feedback_fields = {
|
feedback_fields = {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from flask import request
|
|
||||||
from flask_restful import reqparse, marshal
|
|
||||||
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
|
||||||
from controllers.service_api.wraps import DatasetApiResource
|
from controllers.service_api.wraps import DatasetApiResource
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.provider_manager import ProviderManager
|
from core.provider_manager import ProviderManager
|
||||||
from libs.login import current_user
|
|
||||||
from fields.dataset_fields import dataset_detail_fields
|
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 services.dataset_service import DatasetService
|
from services.dataset_service import DatasetService
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from flask_restful import reqparse, marshal
|
|
||||||
from flask_login import current_user
|
|
||||||
from sqlalchemy import desc
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
import services.dataset_service
|
import services.dataset_service
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app.error import ProviderNotInitializeError
|
from controllers.service_api.app.error import ProviderNotInitializeError
|
||||||
from controllers.service_api.dataset.error import ArchivedDocumentImmutableError, DocumentIndexingError, \
|
from controllers.service_api.dataset.error import (ArchivedDocumentImmutableError, DocumentIndexingError,
|
||||||
NoFileUploadedError, TooManyFilesError
|
NoFileUploadedError, TooManyFilesError)
|
||||||
from controllers.service_api.wraps import DatasetApiResource, cloud_edition_billing_resource_check
|
from controllers.service_api.wraps import DatasetApiResource, cloud_edition_billing_resource_check
|
||||||
from libs.login import current_user
|
|
||||||
from core.errors.error import ProviderTokenNotInitError
|
from core.errors.error import ProviderTokenNotInitError
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from fields.document_fields import document_fields, document_status_fields
|
from fields.document_fields import document_fields, document_status_fields
|
||||||
|
from flask import request
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import marshal, reqparse
|
||||||
|
from libs.login import current_user
|
||||||
from models.dataset import Dataset, Document, DocumentSegment
|
from models.dataset import Dataset, Document, DocumentSegment
|
||||||
from services.dataset_service import DocumentService
|
from services.dataset_service import DocumentService
|
||||||
from services.file_service import FileService
|
from services.file_service import FileService
|
||||||
|
from sqlalchemy import desc
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class DocumentAddByTextApi(DatasetApiResource):
|
class DocumentAddByTextApi(DatasetApiResource):
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
from flask_login import current_user
|
|
||||||
from flask_restful import reqparse, marshal
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
from controllers.service_api import api
|
from controllers.service_api import api
|
||||||
from controllers.service_api.app.error import ProviderNotInitializeError
|
from controllers.service_api.app.error import ProviderNotInitializeError
|
||||||
from controllers.service_api.wraps import DatasetApiResource, cloud_edition_billing_resource_check
|
from controllers.service_api.wraps import DatasetApiResource, cloud_edition_billing_resource_check
|
||||||
from core.errors.error import ProviderTokenNotInitError, LLMBadRequestError
|
from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
|
||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from fields.segment_fields import segment_fields
|
from fields.segment_fields import segment_fields
|
||||||
|
from flask_login import current_user
|
||||||
|
from flask_restful import marshal, reqparse
|
||||||
from models.dataset import Dataset, DocumentSegment
|
from models.dataset import Dataset, DocumentSegment
|
||||||
from services.dataset_service import DatasetService, DocumentService, SegmentService
|
from services.dataset_service import DatasetService, DocumentService, SegmentService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class SegmentApi(DatasetApiResource):
|
class SegmentApi(DatasetApiResource):
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask import request, current_app
|
from extensions.ext_database import db
|
||||||
|
from flask import current_app, request
|
||||||
from flask_login import user_logged_in
|
from flask_login import user_logged_in
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
from werkzeug.exceptions import NotFound, Unauthorized
|
|
||||||
|
|
||||||
from libs.login import _get_user
|
from libs.login import _get_user
|
||||||
from extensions.ext_database import db
|
from models.account import Account, Tenant, TenantAccountJoin
|
||||||
from models.account import Tenant, TenantAccountJoin, Account
|
|
||||||
from models.model import ApiToken, App
|
from models.model import ApiToken, App
|
||||||
from services.feature_service import FeatureService
|
from services.feature_service import FeatureService
|
||||||
|
from werkzeug.exceptions import NotFound, Unauthorized
|
||||||
|
|
||||||
|
|
||||||
def validate_app_token(view=None):
|
def validate_app_token(view=None):
|
||||||
def decorator(view):
|
def decorator(view):
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
from libs.external_api import ExternalApi
|
from libs.external_api import ExternalApi
|
||||||
|
|
||||||
bp = Blueprint('web', __name__, url_prefix='/api')
|
bp = Blueprint('web', __name__, url_prefix='/api')
|
||||||
api = ExternalApi(bp)
|
api = ExternalApi(bp)
|
||||||
|
|
||||||
|
|
||||||
from . import completion, app, conversation, message, site, saved_message, audio, passport, file
|
from . import app, audio, completion, conversation, file, message, passport, saved_message, site
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_restful import marshal_with, fields
|
|
||||||
from flask import current_app
|
|
||||||
|
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
|
from flask import current_app
|
||||||
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import App
|
from models.model import App
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request
|
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.error import AppUnavailableError, ProviderNotInitializeError, CompletionRequestError, \
|
from controllers.web.error import (AppUnavailableError, AudioTooLargeError, CompletionRequestError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError, NoAudioUploadedError, AudioTooLargeError, \
|
NoAudioUploadedError, ProviderModelCurrentlyNotSupportError,
|
||||||
UnsupportedAudioTypeError, ProviderNotSupportSpeechToTextError
|
ProviderNotInitializeError, ProviderNotSupportSpeechToTextError,
|
||||||
|
ProviderQuotaExceededError, UnsupportedAudioTypeError)
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from services.audio_service import AudioService
|
from flask import request
|
||||||
from services.errors.audio import NoAudioUploadedServiceError, AudioTooLargeServiceError, \
|
|
||||||
UnsupportedAudioTypeServiceError, ProviderNotSupportSpeechToTextServiceError
|
|
||||||
from models.model import App, AppModelConfig
|
from models.model import App, AppModelConfig
|
||||||
|
from services.audio_service import AudioService
|
||||||
|
from services.errors.audio import (AudioTooLargeServiceError, NoAudioUploadedServiceError,
|
||||||
|
ProviderNotSupportSpeechToTextServiceError, UnsupportedAudioTypeServiceError)
|
||||||
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
|
||||||
|
|
||||||
class AudioApi(WebApiResource):
|
class AudioApi(WebApiResource):
|
||||||
|
|
|
@ -3,22 +3,21 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
|
||||||
from flask_restful import reqparse
|
|
||||||
from werkzeug.exceptions import InternalServerError, NotFound
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.error import AppUnavailableError, ConversationCompletedError, \
|
from controllers.web.error import (AppUnavailableError, CompletionRequestError, ConversationCompletedError,
|
||||||
ProviderNotInitializeError, NotChatAppError, NotCompletionAppError, CompletionRequestError, \
|
NotChatAppError, NotCompletionAppError, ProviderModelCurrentlyNotSupportError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError
|
ProviderNotInitializeError, ProviderQuotaExceededError)
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
from core.application_queue_manager import ApplicationQueueManager
|
from core.application_queue_manager import ApplicationQueueManager
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_restful import reqparse
|
||||||
from libs.helper import uuid_value
|
from libs.helper import uuid_value
|
||||||
from services.completion_service import CompletionService
|
from services.completion_service import CompletionService
|
||||||
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
# define completion api for user
|
# define completion api for user
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from flask_restful import fields, reqparse, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.error import NotChatAppError
|
from controllers.web.error import NotChatAppError
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
from fields.conversation_fields import conversation_infinite_scroll_pagination_fields, simple_conversation_fields
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
from libs.helper import TimestampField, uuid_value
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.conversation_service import ConversationService
|
from services.conversation_service import ConversationService
|
||||||
from services.errors.conversation import LastConversationNotExistsError, ConversationNotExistsError
|
from services.errors.conversation import ConversationNotExistsError, LastConversationNotExistsError
|
||||||
from services.web_conversation_service import WebConversationService
|
from services.web_conversation_service import WebConversationService
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
class ConversationListApi(WebApiResource):
|
class ConversationListApi(WebApiResource):
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
|
import services
|
||||||
|
from controllers.web import api
|
||||||
|
from controllers.web.error import FileTooLargeError, NoFileUploadedError, TooManyFilesError, UnsupportedFileTypeError
|
||||||
|
from controllers.web.wraps import WebApiResource
|
||||||
|
from fields.file_fields import file_fields
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import marshal_with
|
from flask_restful import marshal_with
|
||||||
|
|
||||||
from controllers.web import api
|
|
||||||
from controllers.web.wraps import WebApiResource
|
|
||||||
from controllers.web.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \
|
|
||||||
UnsupportedFileTypeError
|
|
||||||
import services
|
|
||||||
from services.file_service import FileService
|
from services.file_service import FileService
|
||||||
from fields.file_fields import file_fields
|
|
||||||
|
|
||||||
|
|
||||||
class FileApi(WebApiResource):
|
class FileApi(WebApiResource):
|
||||||
|
|
|
@ -3,27 +3,27 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Generator, Union
|
from typing import Generator, Union
|
||||||
|
|
||||||
from flask import stream_with_context, Response
|
|
||||||
from flask_restful import reqparse, fields, marshal_with
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound, InternalServerError
|
|
||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.error import NotChatAppError, CompletionRequestError, ProviderNotInitializeError, \
|
from controllers.web.error import (AppMoreLikeThisDisabledError, AppSuggestedQuestionsAfterAnswerDisabledError,
|
||||||
AppMoreLikeThisDisabledError, NotCompletionAppError, AppSuggestedQuestionsAfterAnswerDisabledError, \
|
CompletionRequestError, NotChatAppError, NotCompletionAppError,
|
||||||
ProviderQuotaExceededError, ProviderModelCurrentlyNotSupportError
|
ProviderModelCurrentlyNotSupportError, ProviderNotInitializeError,
|
||||||
|
ProviderQuotaExceededError)
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.errors.error import ProviderTokenNotInitError, QuotaExceededError, ModelCurrentlyNotSupportError
|
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from libs.helper import uuid_value, TimestampField
|
from fields.conversation_fields import message_file_fields
|
||||||
|
from flask import Response, stream_with_context
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
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
|
||||||
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
from services.errors.message import MessageNotExistsError, SuggestedQuestionsAfterAnswerDisabledError
|
||||||
from services.message_service import MessageService
|
from services.message_service import MessageService
|
||||||
from fields.conversation_fields import message_file_fields
|
from werkzeug.exceptions import InternalServerError, NotFound
|
||||||
|
|
||||||
|
|
||||||
class MessageListApi(WebApiResource):
|
class MessageListApi(WebApiResource):
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from flask_restful import Resource
|
|
||||||
from flask import request
|
|
||||||
from werkzeug.exceptions import Unauthorized, NotFound
|
|
||||||
from models.model import Site, EndUser, App
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import request
|
||||||
|
from flask_restful import Resource
|
||||||
from libs.passport import PassportService
|
from libs.passport import PassportService
|
||||||
|
from models.model import App, EndUser, Site
|
||||||
|
from werkzeug.exceptions import NotFound, Unauthorized
|
||||||
|
|
||||||
|
|
||||||
class PassportResource(Resource):
|
class PassportResource(Resource):
|
||||||
"""Base resource for passport."""
|
"""Base resource for passport."""
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
from flask_restful import reqparse, marshal_with, fields
|
|
||||||
from flask_restful.inputs import int_range
|
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
|
|
||||||
from controllers.web import api
|
from controllers.web import api
|
||||||
from controllers.web.error import NotCompletionAppError
|
from controllers.web.error import NotCompletionAppError
|
||||||
from controllers.web.wraps import WebApiResource
|
from controllers.web.wraps import WebApiResource
|
||||||
from libs.helper import uuid_value, TimestampField
|
from fields.conversation_fields import message_file_fields
|
||||||
|
from flask_restful import fields, marshal_with, reqparse
|
||||||
|
from flask_restful.inputs import int_range
|
||||||
|
from libs.helper import TimestampField, uuid_value
|
||||||
from services.errors.message import MessageNotExistsError
|
from services.errors.message import MessageNotExistsError
|
||||||
from services.saved_message_service import SavedMessageService
|
from services.saved_message_service import SavedMessageService
|
||||||
from fields.conversation_fields import message_file_fields
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
|
||||||
feedback_fields = {
|
feedback_fields = {
|
||||||
'rating': fields.String
|
'rating': fields.String
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flask_restful import fields, marshal_with
|
|
||||||
from flask import current_app
|
|
||||||
from werkzeug.exceptions import Forbidden
|
|
||||||
|
|
||||||
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 extensions.ext_database import db
|
||||||
|
from flask import current_app
|
||||||
|
from flask_restful import fields, marshal_with
|
||||||
from models.model import Site
|
from models.model import Site
|
||||||
from services.feature_service import FeatureService
|
from services.feature_service import FeatureService
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
class AppSiteApi(WebApiResource):
|
class AppSiteApi(WebApiResource):
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from extensions.ext_database import db
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
from libs.passport import PassportService
|
||||||
|
from models.model import App, EndUser, Site
|
||||||
from werkzeug.exceptions import NotFound, Unauthorized
|
from werkzeug.exceptions import NotFound, Unauthorized
|
||||||
|
|
||||||
from extensions.ext_database import db
|
|
||||||
from models.model import App, EndUser, Site
|
|
||||||
from libs.passport import PassportService
|
|
||||||
|
|
||||||
def validate_jwt_token(view=None):
|
def validate_jwt_token(view=None):
|
||||||
def decorator(view):
|
def decorator(view):
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional, List
|
from typing import List, Optional
|
||||||
|
|
||||||
from core.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
from core.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
||||||
from core.model_runtime.callbacks.base_callback import Callback
|
from core.model_runtime.callbacks.base_callback import Callback
|
||||||
from core.model_runtime.entities.llm_entities import LLMResultChunk, LLMResult
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageTool, PromptMessage
|
from core.model_runtime.entities.message_entities import PromptMessage, PromptMessageTool
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from typing import List, cast
|
from typing import List, cast
|
||||||
|
|
||||||
from langchain.schema import BaseMessage
|
|
||||||
|
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
from core.entities.message_entities import lc_messages_to_prompt_messages
|
from core.entities.message_entities import lc_messages_to_prompt_messages
|
||||||
from core.model_runtime.entities.message_entities import PromptMessage
|
from core.model_runtime.entities.message_entities import PromptMessage
|
||||||
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.large_language_model import LargeLanguageModel
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
from langchain.schema import BaseMessage
|
||||||
|
|
||||||
|
|
||||||
class CalcTokenMixin:
|
class CalcTokenMixin:
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
from typing import Tuple, List, Any, Union, Sequence, Optional, cast
|
from typing import Any, List, Optional, Sequence, Tuple, Union, cast
|
||||||
|
|
||||||
from langchain.agents import OpenAIFunctionsAgent, BaseSingleActionAgent
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
|
from core.entities.message_entities import lc_messages_to_prompt_messages
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
|
from core.model_runtime.entities.message_entities import PromptMessageTool
|
||||||
|
from core.third_party.langchain.llms.fake import FakeLLM
|
||||||
|
from langchain.agents import BaseSingleActionAgent, OpenAIFunctionsAgent
|
||||||
from langchain.agents.openai_functions_agent.base import _format_intermediate_steps, _parse_ai_message
|
from langchain.agents.openai_functions_agent.base import _format_intermediate_steps, _parse_ai_message
|
||||||
from langchain.callbacks.base import BaseCallbackManager
|
from langchain.callbacks.base import BaseCallbackManager
|
||||||
from langchain.callbacks.manager import Callbacks
|
from langchain.callbacks.manager import Callbacks
|
||||||
from langchain.prompts.chat import BaseMessagePromptTemplate
|
from langchain.prompts.chat import BaseMessagePromptTemplate
|
||||||
from langchain.schema import AgentAction, AgentFinish, SystemMessage, AIMessage
|
from langchain.schema import AgentAction, AgentFinish, AIMessage, SystemMessage
|
||||||
from langchain.tools import BaseTool
|
from langchain.tools import BaseTool
|
||||||
from pydantic import root_validator
|
from pydantic import root_validator
|
||||||
|
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
from core.entities.message_entities import lc_messages_to_prompt_messages
|
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageTool
|
|
||||||
from core.third_party.langchain.llms.fake import FakeLLM
|
|
||||||
|
|
||||||
|
|
||||||
class MultiDatasetRouterAgent(OpenAIFunctionsAgent):
|
class MultiDatasetRouterAgent(OpenAIFunctionsAgent):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,28 +1,26 @@
|
||||||
from typing import List, Tuple, Any, Union, Sequence, Optional, cast
|
from typing import Any, List, Optional, Sequence, Tuple, Union, cast
|
||||||
|
|
||||||
from langchain.agents import OpenAIFunctionsAgent, BaseSingleActionAgent
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from langchain.agents.openai_functions_agent.base import _parse_ai_message, \
|
from core.agent.agent.calc_token_mixin import CalcTokenMixin, ExceededLLMTokensLimitError
|
||||||
_format_intermediate_steps
|
from core.chain.llm_chain import LLMChain
|
||||||
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
|
from core.entities.message_entities import lc_messages_to_prompt_messages
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
|
from core.model_runtime.entities.message_entities import PromptMessage, PromptMessageTool
|
||||||
|
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
|
from core.third_party.langchain.llms.fake import FakeLLM
|
||||||
|
from langchain.agents import BaseSingleActionAgent, OpenAIFunctionsAgent
|
||||||
|
from langchain.agents.openai_functions_agent.base import _format_intermediate_steps, _parse_ai_message
|
||||||
from langchain.callbacks.base import BaseCallbackManager
|
from langchain.callbacks.base import BaseCallbackManager
|
||||||
from langchain.callbacks.manager import Callbacks
|
from langchain.callbacks.manager import Callbacks
|
||||||
from langchain.chat_models.openai import _convert_message_to_dict, _import_tiktoken
|
from langchain.chat_models.openai import _convert_message_to_dict, _import_tiktoken
|
||||||
from langchain.memory.prompt import SUMMARY_PROMPT
|
from langchain.memory.prompt import SUMMARY_PROMPT
|
||||||
from langchain.prompts.chat import BaseMessagePromptTemplate
|
from langchain.prompts.chat import BaseMessagePromptTemplate
|
||||||
from langchain.schema import AgentAction, AgentFinish, SystemMessage, AIMessage, HumanMessage, BaseMessage, \
|
from langchain.schema import (AgentAction, AgentFinish, AIMessage, BaseMessage, HumanMessage, SystemMessage,
|
||||||
get_buffer_string
|
get_buffer_string)
|
||||||
from langchain.tools import BaseTool
|
from langchain.tools import BaseTool
|
||||||
from pydantic import root_validator
|
from pydantic import root_validator
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
|
||||||
from core.agent.agent.calc_token_mixin import ExceededLLMTokensLimitError, CalcTokenMixin
|
|
||||||
from core.chain.llm_chain import LLMChain
|
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
from core.entities.message_entities import lc_messages_to_prompt_messages
|
|
||||||
from core.model_runtime.entities.message_entities import PromptMessageTool, PromptMessage
|
|
||||||
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
|
||||||
from core.third_party.langchain.llms.fake import FakeLLM
|
|
||||||
|
|
||||||
|
|
||||||
class AutoSummarizingOpenAIFunctionCallAgent(OpenAIFunctionsAgent, CalcTokenMixin):
|
class AutoSummarizingOpenAIFunctionCallAgent(OpenAIFunctionsAgent, CalcTokenMixin):
|
||||||
moving_summary_buffer: str = ""
|
moving_summary_buffer: str = ""
|
||||||
|
|
|
@ -2,8 +2,8 @@ import json
|
||||||
import re
|
import re
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from langchain.agents.structured_chat.output_parser import StructuredChatOutputParser as LCStructuredChatOutputParser, \
|
from langchain.agents.structured_chat.output_parser import StructuredChatOutputParser as LCStructuredChatOutputParser
|
||||||
logger
|
from langchain.agents.structured_chat.output_parser import logger
|
||||||
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
import re
|
import re
|
||||||
from typing import List, Tuple, Any, Union, Sequence, Optional, cast
|
from typing import Any, List, Optional, Sequence, Tuple, Union, cast
|
||||||
|
|
||||||
from langchain import BasePromptTemplate, PromptTemplate
|
|
||||||
from langchain.agents import StructuredChatAgent, AgentOutputParser, Agent
|
|
||||||
from langchain.agents.structured_chat.base import HUMAN_MESSAGE_TEMPLATE
|
|
||||||
from langchain.callbacks.base import BaseCallbackManager
|
|
||||||
from langchain.callbacks.manager import Callbacks
|
|
||||||
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate
|
|
||||||
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
|
||||||
from langchain.tools import BaseTool
|
|
||||||
from langchain.agents.structured_chat.prompt import PREFIX, SUFFIX
|
|
||||||
|
|
||||||
from core.chain.llm_chain import LLMChain
|
from core.chain.llm_chain import LLMChain
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
|
from langchain import BasePromptTemplate, PromptTemplate
|
||||||
|
from langchain.agents import Agent, AgentOutputParser, StructuredChatAgent
|
||||||
|
from langchain.agents.structured_chat.base import HUMAN_MESSAGE_TEMPLATE
|
||||||
|
from langchain.agents.structured_chat.prompt import PREFIX, SUFFIX
|
||||||
|
from langchain.callbacks.base import BaseCallbackManager
|
||||||
|
from langchain.callbacks.manager import Callbacks
|
||||||
|
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate
|
||||||
|
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
||||||
|
from langchain.tools import BaseTool
|
||||||
|
|
||||||
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
|
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
|
||||||
The nouns in the format of "Thought", "Action", "Action Input", "Final Answer" must be expressed in English.
|
The nouns in the format of "Thought", "Action", "Action Input", "Final Answer" must be expressed in English.
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
import re
|
import re
|
||||||
from typing import List, Tuple, Any, Union, Sequence, Optional, cast
|
from typing import Any, List, Optional, Sequence, Tuple, Union, cast
|
||||||
|
|
||||||
from langchain import BasePromptTemplate, PromptTemplate
|
|
||||||
from langchain.agents import StructuredChatAgent, AgentOutputParser, Agent
|
|
||||||
from langchain.agents.structured_chat.base import HUMAN_MESSAGE_TEMPLATE
|
|
||||||
from langchain.callbacks.base import BaseCallbackManager
|
|
||||||
from langchain.callbacks.manager import Callbacks
|
|
||||||
from langchain.memory.prompt import SUMMARY_PROMPT
|
|
||||||
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate
|
|
||||||
from langchain.schema import AgentAction, AgentFinish, AIMessage, HumanMessage, OutputParserException, BaseMessage, \
|
|
||||||
get_buffer_string
|
|
||||||
from langchain.tools import BaseTool
|
|
||||||
from langchain.agents.structured_chat.prompt import PREFIX, SUFFIX
|
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from core.agent.agent.calc_token_mixin import CalcTokenMixin, ExceededLLMTokensLimitError
|
from core.agent.agent.calc_token_mixin import CalcTokenMixin, ExceededLLMTokensLimitError
|
||||||
from core.chain.llm_chain import LLMChain
|
from core.chain.llm_chain import LLMChain
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
from core.entities.message_entities import lc_messages_to_prompt_messages
|
from core.entities.message_entities import lc_messages_to_prompt_messages
|
||||||
|
from langchain import BasePromptTemplate, PromptTemplate
|
||||||
|
from langchain.agents import Agent, AgentOutputParser, StructuredChatAgent
|
||||||
|
from langchain.agents.structured_chat.base import HUMAN_MESSAGE_TEMPLATE
|
||||||
|
from langchain.agents.structured_chat.prompt import PREFIX, SUFFIX
|
||||||
|
from langchain.callbacks.base import BaseCallbackManager
|
||||||
|
from langchain.callbacks.manager import Callbacks
|
||||||
|
from langchain.memory.prompt import SUMMARY_PROMPT
|
||||||
|
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate
|
||||||
|
from langchain.schema import (AgentAction, AgentFinish, AIMessage, BaseMessage, HumanMessage, OutputParserException,
|
||||||
|
get_buffer_string)
|
||||||
|
from langchain.tools import BaseTool
|
||||||
|
|
||||||
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
|
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
|
||||||
The nouns in the format of "Thought", "Action", "Action Input", "Final Answer" must be expressed in English.
|
The nouns in the format of "Thought", "Action", "Action Input", "Final Answer" must be expressed in English.
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import enum
|
import enum
|
||||||
import logging
|
import logging
|
||||||
from typing import Union, Optional
|
from typing import Optional, Union
|
||||||
|
|
||||||
from langchain.agents import BaseSingleActionAgent, BaseMultiActionAgent
|
|
||||||
from langchain.callbacks.manager import Callbacks
|
|
||||||
from langchain.tools import BaseTool
|
|
||||||
from pydantic import BaseModel, Extra
|
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from core.agent.agent.multi_dataset_router_agent import MultiDatasetRouterAgent
|
from core.agent.agent.multi_dataset_router_agent import MultiDatasetRouterAgent
|
||||||
|
@ -13,8 +8,6 @@ from core.agent.agent.openai_function_call import AutoSummarizingOpenAIFunctionC
|
||||||
from core.agent.agent.output_parser.structured_chat import StructuredChatOutputParser
|
from core.agent.agent.output_parser.structured_chat import StructuredChatOutputParser
|
||||||
from core.agent.agent.structed_multi_dataset_router_agent import StructuredMultiDatasetRouterAgent
|
from core.agent.agent.structed_multi_dataset_router_agent import StructuredMultiDatasetRouterAgent
|
||||||
from core.agent.agent.structured_chat import AutoSummarizingStructuredChatAgent
|
from core.agent.agent.structured_chat import AutoSummarizingStructuredChatAgent
|
||||||
from langchain.agents import AgentExecutor as LCAgentExecutor
|
|
||||||
|
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
from core.entities.message_entities import prompt_messages_to_lc_messages
|
from core.entities.message_entities import prompt_messages_to_lc_messages
|
||||||
from core.helper import moderation
|
from core.helper import moderation
|
||||||
|
@ -22,6 +15,11 @@ from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_runtime.errors.invoke import InvokeError
|
from core.model_runtime.errors.invoke import InvokeError
|
||||||
from core.tool.dataset_multi_retriever_tool import DatasetMultiRetrieverTool
|
from core.tool.dataset_multi_retriever_tool import DatasetMultiRetrieverTool
|
||||||
from core.tool.dataset_retriever_tool import DatasetRetrieverTool
|
from core.tool.dataset_retriever_tool import DatasetRetrieverTool
|
||||||
|
from langchain.agents import AgentExecutor as LCAgentExecutor
|
||||||
|
from langchain.agents import BaseMultiActionAgent, BaseSingleActionAgent
|
||||||
|
from langchain.callbacks.manager import Callbacks
|
||||||
|
from langchain.tools import BaseTool
|
||||||
|
from pydantic import BaseModel, Extra
|
||||||
|
|
||||||
|
|
||||||
class PlanningStrategy(str, enum.Enum):
|
class PlanningStrategy(str, enum.Enum):
|
||||||
|
|
|
@ -4,16 +4,16 @@ from typing import cast
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from core.app_runner.app_runner import AppRunner
|
from core.app_runner.app_runner import AppRunner
|
||||||
from core.callback_handler.agent_loop_gather_callback_handler import AgentLoopGatherCallbackHandler
|
|
||||||
from core.entities.application_entities import ApplicationGenerateEntity, PromptTemplateEntity, ModelConfigEntity
|
|
||||||
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.entities.application_entities import ApplicationGenerateEntity, ModelConfigEntity, PromptTemplateEntity
|
||||||
from core.features.agent_runner import AgentRunnerFeature
|
from core.features.agent_runner import AgentRunnerFeature
|
||||||
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
|
||||||
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 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
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import time
|
import time
|
||||||
from typing import cast, Optional, List, Tuple, Generator, Union
|
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 ModelConfigEntity, PromptTemplateEntity, AppOrchestrationConfigEntity
|
from core.entities.application_entities import AppOrchestrationConfigEntity, ModelConfigEntity, PromptTemplateEntity
|
||||||
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
|
||||||
from core.model_runtime.entities.message_entities import PromptMessage, AssistantPromptMessage
|
from core.model_runtime.entities.message_entities import AssistantPromptMessage, PromptMessage
|
||||||
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
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Tuple, Optional
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from core.app_runner.app_runner import AppRunner
|
from core.app_runner.app_runner import AppRunner
|
||||||
from core.callback_handler.index_tool_callback_handler import DatasetIndexToolCallbackHandler
|
|
||||||
from core.entities.application_entities import ApplicationGenerateEntity, ModelConfigEntity, \
|
|
||||||
AppOrchestrationConfigEntity, InvokeFrom, ExternalDataVariableEntity, DatasetEntity
|
|
||||||
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.entities.application_entities import (ApplicationGenerateEntity, AppOrchestrationConfigEntity, DatasetEntity,
|
||||||
|
ExternalDataVariableEntity, InvokeFrom, ModelConfigEntity)
|
||||||
from core.features.annotation_reply import AnnotationReplyFeature
|
from core.features.annotation_reply import AnnotationReplyFeature
|
||||||
from core.features.dataset_retrieval import DatasetRetrievalFeature
|
from core.features.dataset_retrieval import DatasetRetrievalFeature
|
||||||
from core.features.external_data_fetch import ExternalDataFetchFeature
|
from core.features.external_data_fetch import ExternalDataFetchFeature
|
||||||
|
@ -17,7 +17,7 @@ from core.model_runtime.entities.message_entities import PromptMessage
|
||||||
from core.moderation.base import ModerationException
|
from core.moderation.base import ModerationException
|
||||||
from core.prompt.prompt_transform import AppMode
|
from core.prompt.prompt_transform import AppMode
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import Conversation, Message, App, MessageAnnotation
|
from models.model import App, Conversation, Message, MessageAnnotation
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from typing import Union, Generator, cast, Optional
|
from typing import Generator, Optional, Union, cast
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from core.app_runner.moderation_handler import ModerationRule, OutputModerationHandler
|
||||||
|
|
||||||
from core.app_runner.moderation_handler import OutputModerationHandler, ModerationRule
|
|
||||||
from core.entities.application_entities import ApplicationGenerateEntity
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.entities.queue_entities import QueueErrorEvent, QueueStopEvent, QueueMessageEndEvent, \
|
from core.entities.application_entities import ApplicationGenerateEntity
|
||||||
QueueRetrieverResourcesEvent, QueueAgentThoughtEvent, QueuePingEvent, QueueMessageEvent, QueueMessageReplaceEvent, \
|
from core.entities.queue_entities import (AnnotationReplyEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
||||||
AnnotationReplyEvent
|
QueueMessageEndEvent, QueueMessageEvent, QueueMessageReplaceEvent,
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult, LLMUsage, LLMResultChunk, LLMResultChunkDelta
|
QueuePingEvent, QueueRetrieverResourcesEvent, QueueStopEvent)
|
||||||
from core.model_runtime.entities.message_entities import AssistantPromptMessage, PromptMessageRole, \
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta, LLMUsage
|
||||||
TextPromptMessageContent, PromptMessageContentType, ImagePromptMessageContent, PromptMessage
|
from core.model_runtime.entities.message_entities import (AssistantPromptMessage, ImagePromptMessageContent,
|
||||||
from core.model_runtime.errors.invoke import InvokeError, InvokeAuthorizationError
|
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.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
|
||||||
from core.prompt.prompt_template import PromptTemplateParser
|
from core.prompt.prompt_template import PromptTemplateParser
|
||||||
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 Message, Conversation, MessageAgentThought
|
from models.model import Conversation, Message, MessageAgentThought
|
||||||
|
from pydantic import BaseModel
|
||||||
from services.annotation_service import AppAnnotationService
|
from services.annotation_service import AppAnnotationService
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from typing import Any, Optional, Dict
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from flask import current_app, Flask
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from core.application_queue_manager import PublishFrom
|
from core.application_queue_manager import PublishFrom
|
||||||
from core.moderation.base import ModerationAction, ModerationOutputsResult
|
from core.moderation.base import ModerationAction, ModerationOutputsResult
|
||||||
from core.moderation.factory import ModerationFactory
|
from core.moderation.factory import ModerationFactory
|
||||||
|
from flask import Flask, current_app
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -2,31 +2,32 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
from typing import cast, Optional, Any, Union, Generator, Tuple
|
from typing import Any, Generator, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
from flask import Flask, current_app
|
|
||||||
from pydantic import ValidationError
|
|
||||||
|
|
||||||
from core.app_runner.agent_app_runner import AgentApplicationRunner
|
from core.app_runner.agent_app_runner import AgentApplicationRunner
|
||||||
from core.app_runner.basic_app_runner import BasicApplicationRunner
|
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.entities.application_entities import ApplicationGenerateEntity, AppOrchestrationConfigEntity, \
|
from core.application_queue_manager import ApplicationQueueManager, ConversationTaskStoppedException, PublishFrom
|
||||||
ModelConfigEntity, PromptTemplateEntity, AdvancedChatPromptTemplateEntity, \
|
from core.entities.application_entities import (AdvancedChatPromptTemplateEntity,
|
||||||
AdvancedCompletionPromptTemplateEntity, ExternalDataVariableEntity, DatasetEntity, DatasetRetrieveConfigEntity, \
|
AdvancedCompletionPromptTemplateEntity, AgentEntity, AgentToolEntity,
|
||||||
AgentEntity, AgentToolEntity, FileUploadEntity, SensitiveWordAvoidanceEntity, InvokeFrom
|
ApplicationGenerateEntity, AppOrchestrationConfigEntity, DatasetEntity,
|
||||||
|
DatasetRetrieveConfigEntity, ExternalDataVariableEntity,
|
||||||
|
FileUploadEntity, InvokeFrom, ModelConfigEntity, PromptTemplateEntity,
|
||||||
|
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.file.file_obj import FileObj
|
from core.file.file_obj import FileObj
|
||||||
from core.errors.error import QuotaExceededError, ProviderTokenNotInitError, ModelCurrentlyNotSupportError
|
|
||||||
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 ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
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.prompt.prompt_template import PromptTemplateParser
|
from core.prompt.prompt_template import PromptTemplateParser
|
||||||
from core.provider_manager import ProviderManager
|
from core.provider_manager import ProviderManager
|
||||||
from core.application_queue_manager import ApplicationQueueManager, ConversationTaskStoppedException, PublishFrom
|
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
|
from flask import Flask, current_app
|
||||||
from models.account import Account
|
from models.account import Account
|
||||||
from models.model import EndUser, Conversation, Message, MessageFile, App
|
from models.model import App, Conversation, EndUser, Message, MessageFile
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import queue
|
import queue
|
||||||
import time
|
import time
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Generator, Any
|
from typing import Any, Generator
|
||||||
|
|
||||||
from sqlalchemy.orm import DeclarativeMeta
|
|
||||||
|
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from core.entities.queue_entities import QueueStopEvent, AppQueueEvent, QueuePingEvent, QueueErrorEvent, \
|
from core.entities.queue_entities import (AnnotationReplyEvent, AppQueueEvent, QueueAgentThoughtEvent, QueueErrorEvent,
|
||||||
QueueAgentThoughtEvent, QueueMessageEndEvent, QueueRetrieverResourcesEvent, QueueMessageReplaceEvent, \
|
QueueMessage, QueueMessageEndEvent, QueueMessageEvent,
|
||||||
QueueMessageEvent, QueueMessage, AnnotationReplyEvent
|
QueueMessageReplaceEvent, 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
|
from models.model import MessageAgentThought
|
||||||
|
from sqlalchemy.orm import DeclarativeMeta
|
||||||
|
|
||||||
|
|
||||||
class PublishFrom(Enum):
|
class PublishFrom(Enum):
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from typing import Any, Dict, List, Optional, Union, cast
|
||||||
from typing import Any, Dict, List, Union, Optional, cast
|
|
||||||
|
|
||||||
from langchain.agents import openai_functions_agent, openai_functions_multi_agent
|
|
||||||
from langchain.callbacks.base import BaseCallbackHandler
|
|
||||||
from langchain.schema import AgentAction, AgentFinish, LLMResult, ChatGeneration, BaseMessage
|
|
||||||
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.callback_handler.entity.agent_loop import AgentLoop
|
from core.callback_handler.entity.agent_loop import AgentLoop
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
from core.model_runtime.entities.llm_entities import LLMResult as RuntimeLLMResult
|
from core.model_runtime.entities.llm_entities import LLMResult as RuntimeLLMResult
|
||||||
from core.model_runtime.entities.message_entities import UserPromptMessage, AssistantPromptMessage, PromptMessage
|
from core.model_runtime.entities.message_entities import AssistantPromptMessage, PromptMessage, UserPromptMessage
|
||||||
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 extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.model import MessageChain, MessageAgentThought, Message
|
from langchain.agents import openai_functions_agent, openai_functions_multi_agent
|
||||||
|
from langchain.callbacks.base import BaseCallbackHandler
|
||||||
|
from langchain.schema import AgentAction, AgentFinish, BaseMessage, ChatGeneration, LLMResult
|
||||||
|
from models.model import Message, MessageAgentThought, MessageChain
|
||||||
|
|
||||||
|
|
||||||
class AgentLoopGatherCallbackHandler(BaseCallbackHandler):
|
class AgentLoopGatherCallbackHandler(BaseCallbackHandler):
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from langchain.schema import Document
|
|
||||||
|
|
||||||
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
from core.application_queue_manager import ApplicationQueueManager, PublishFrom
|
||||||
from core.entities.application_entities import InvokeFrom
|
from core.entities.application_entities import InvokeFrom
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.dataset import DocumentSegment, DatasetQuery
|
from langchain.schema import Document
|
||||||
|
from models.dataset import DatasetQuery, DocumentSegment
|
||||||
from models.model import DatasetRetrieverResource
|
from models.model import DatasetRetrieverResource
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
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 langchain.schema import AgentAction, AgentFinish, LLMResult, BaseMessage
|
from langchain.schema import AgentAction, AgentFinish, BaseMessage, LLMResult
|
||||||
|
|
||||||
|
|
||||||
class DifyStdOutCallbackHandler(BaseCallbackHandler):
|
class DifyStdOutCallbackHandler(BaseCallbackHandler):
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
from typing import List, Dict, Any, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from langchain import LLMChain as LCLLMChain
|
|
||||||
from langchain.callbacks.manager import CallbackManagerForChainRun
|
|
||||||
from langchain.schema import LLMResult, Generation
|
|
||||||
from langchain.schema.language_model import BaseLanguageModel
|
|
||||||
|
|
||||||
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
from core.agent.agent.agent_llm_callback import AgentLLMCallback
|
||||||
from core.entities.application_entities import ModelConfigEntity
|
from core.entities.application_entities import ModelConfigEntity
|
||||||
from core.model_manager import ModelInstance
|
|
||||||
from core.entities.message_entities import lc_messages_to_prompt_messages
|
from core.entities.message_entities import lc_messages_to_prompt_messages
|
||||||
|
from core.model_manager import ModelInstance
|
||||||
from core.third_party.langchain.llms.fake import FakeLLM
|
from core.third_party.langchain.llms.fake import FakeLLM
|
||||||
|
from langchain import LLMChain as LCLLMChain
|
||||||
|
from langchain.callbacks.manager import CallbackManagerForChainRun
|
||||||
|
from langchain.schema import Generation, LLMResult
|
||||||
|
from langchain.schema.language_model import BaseLanguageModel
|
||||||
|
|
||||||
|
|
||||||
class LLMChain(LCLLMChain):
|
class LLMChain(LCLLMChain):
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user