Fix variable typo (#8084)

This commit is contained in:
Nam Vu 2024-09-08 12:14:11 +07:00 committed by GitHub
parent b1918dae5e
commit 2d7954c7da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
215 changed files with 599 additions and 597 deletions

View File

@ -46,7 +46,7 @@ class CodeExecutionSandboxConfig(BaseSettings):
""" """
CODE_EXECUTION_ENDPOINT: HttpUrl = Field( CODE_EXECUTION_ENDPOINT: HttpUrl = Field(
description="endpoint URL of code execution servcie", description="endpoint URL of code execution service",
default="http://sandbox:8194", default="http://sandbox:8194",
) )
@ -415,7 +415,7 @@ class MailConfig(BaseSettings):
""" """
MAIL_TYPE: Optional[str] = Field( MAIL_TYPE: Optional[str] = Field(
description="Mail provider type name, default to None, availabile values are `smtp` and `resend`.", description="Mail provider type name, default to None, available values are `smtp` and `resend`.",
default=None, default=None,
) )

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ from core.model_runtime.entities.model_entities import ModelType
from core.provider_manager import ProviderManager from core.provider_manager import ProviderManager
from core.rag.datasource.vdb.vector_type import VectorType from core.rag.datasource.vdb.vector_type import VectorType
from core.rag.extractor.entity.extract_setting import ExtractSetting from core.rag.extractor.entity.extract_setting import ExtractSetting
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.ext_database import db 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

View File

@ -67,7 +67,7 @@ class SegmentApi(DatasetApiResource):
segments = SegmentService.multi_create_segment(args["segments"], document, dataset) segments = SegmentService.multi_create_segment(args["segments"], document, dataset)
return {"data": marshal(segments, segment_fields), "doc_form": document.doc_form}, 200 return {"data": marshal(segments, segment_fields), "doc_form": document.doc_form}, 200
else: else:
return {"error": "Segemtns is required"}, 400 return {"error": "Segments is required"}, 400
def get(self, tenant_id, dataset_id, document_id): def get(self, tenant_id, dataset_id, document_id):
"""Create single segment.""" """Create single segment."""

View File

@ -79,7 +79,7 @@ def is_filtered(
name_func: Callable[[Any], str], name_func: Callable[[Any], str],
) -> bool: ) -> bool:
""" """
Chcek if the object should be filtered out. Check if the object should be filtered out.
Overall logic: exclude > include > pin Overall logic: exclude > include > pin
:param include_set: the set of names to be included :param include_set: the set of names to be included
:param exclude_set: the set of names to be excluded :param exclude_set: the set of names to be excluded

View File

@ -494,7 +494,7 @@ class IndexingRunner:
hash = helper.generate_text_hash(document_node.page_content) hash = helper.generate_text_hash(document_node.page_content)
document_node.metadata['doc_id'] = doc_id document_node.metadata['doc_id'] = doc_id
document_node.metadata['doc_hash'] = hash document_node.metadata['doc_hash'] = hash
# delete Spliter character # delete Splitter character
page_content = document_node.page_content page_content = document_node.page_content
if page_content.startswith(".") or page_content.startswith(""): if page_content.startswith(".") or page_content.startswith(""):
page_content = page_content[1:] page_content = page_content[1:]

View File

@ -87,7 +87,7 @@ Here is a task description for which I would like you to create a high-quality p
{{TASK_DESCRIPTION}} {{TASK_DESCRIPTION}}
</task_description> </task_description>
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include: Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
- Do not inlcude <input> or <output> section and variables in the prompt, assume user will add them at their own will. - Do not include <input> or <output> section and variables in the prompt, assume user will add them at their own will.
- Clear instructions for the AI that will be using this prompt, demarcated with <instructions> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag. - Clear instructions for the AI that will be using this prompt, demarcated with <instructions> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag.
- Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not include variables in the prompt. Give three pairs of input and output examples. - Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not include variables in the prompt. Give three pairs of input and output examples.
- Include other relevant sections demarcated with appropriate XML tags like <examples>, <instructions>. - Include other relevant sections demarcated with appropriate XML tags like <examples>, <instructions>.

View File

@ -52,7 +52,7 @@
- `mode` (string) voice model.available for model type `tts` - `mode` (string) voice model.available for model type `tts`
- `name` (string) voice model display name.available for model type `tts` - `name` (string) voice model display name.available for model type `tts`
- `language` (string) the voice model supports languages.available for model type `tts` - `language` (string) the voice model supports languages.available for model type `tts`
- `word_limit` (int) Single conversion word limit, paragraphwise by defaultavailable for model type `tts` - `word_limit` (int) Single conversion word limit, paragraph-wise by defaultavailable for model type `tts`
- `audio_type` (string) Support audio file extension format, e.g.mp3,wavavailable for model type `tts` - `audio_type` (string) Support audio file extension format, e.g.mp3,wavavailable for model type `tts`
- `max_workers` (int) Number of concurrent workers supporting text and audio conversionavailable for model type`tts` - `max_workers` (int) Number of concurrent workers supporting text and audio conversionavailable for model type`tts`
- `max_characters_per_chunk` (int) Maximum characters per chunk (available for model type `moderation`) - `max_characters_per_chunk` (int) Maximum characters per chunk (available for model type `moderation`)
@ -150,7 +150,7 @@
- `input` (float) Input price, i.e., Prompt price - `input` (float) Input price, i.e., Prompt price
- `output` (float) Output price, i.e., returned content price - `output` (float) Output price, i.e., returned content price
- `unit` (float) Pricing unit, e.g., if the price is meausred in 1M tokens, the corresponding token amount for the unit price is `0.000001`. - `unit` (float) Pricing unit, e.g., if the price is measured in 1M tokens, the corresponding token amount for the unit price is `0.000001`.
- `currency` (string) Currency unit - `currency` (string) Currency unit
### ProviderCredentialSchema ### ProviderCredentialSchema

View File

@ -13,7 +13,7 @@ logger = logging.getLogger(__name__)
class TTSModel(AIModel): class TTSModel(AIModel):
""" """
Model class for ttstext model. Model class for TTS model.
""" """
model_type: ModelType = ModelType.TTS model_type: ModelType = ModelType.TTS

View File

@ -284,7 +284,7 @@ class AzureOpenAILargeLanguageModel(_CommonAzureOpenAI, LargeLanguageModel):
try: try:
schema = json.loads(json_schema) schema = json.loads(json_schema)
except: except:
raise ValueError(f"not currect json_schema format: {json_schema}") raise ValueError(f"not correct json_schema format: {json_schema}")
model_parameters.pop("json_schema") model_parameters.pop("json_schema")
model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema} model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}
else: else:

View File

@ -37,7 +37,7 @@ from core.model_runtime.model_providers.baichuan.llm.baichuan_turbo_errors impor
) )
class BaichuanLarguageModel(LargeLanguageModel): class BaichuanLanguageModel(LargeLanguageModel):
def _invoke( def _invoke(
self, self,

View File

@ -60,7 +60,7 @@ class BaichuanTextEmbeddingModel(TextEmbeddingModel):
token_usage = 0 token_usage = 0
for chunk in chunks: for chunk in chunks:
# embeding chunk # embedding chunk
chunk_embeddings, chunk_usage = self.embedding( chunk_embeddings, chunk_usage = self.embedding(
model=model, model=model,
api_key=api_key, api_key=api_key,

View File

@ -793,11 +793,11 @@ class BedrockLargeLanguageModel(LargeLanguageModel):
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
""" """
Map model invoke error to unified error Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model, The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller. which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping :return: Invoke emd = genai.GenerativeModel(model) error mapping
""" """
return { return {
InvokeConnectionError: [], InvokeConnectionError: [],

View File

@ -130,11 +130,11 @@ class BedrockTextEmbeddingModel(TextEmbeddingModel):
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
""" """
Map model invoke error to unified error Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model, The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller. which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping :return: Invoke emd = genai.GenerativeModel(model) error mapping
""" """
return { return {
InvokeConnectionError: [], InvokeConnectionError: [],

View File

@ -416,11 +416,11 @@ class GoogleLargeLanguageModel(LargeLanguageModel):
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
""" """
Map model invoke error to unified error Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model, The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller. which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping :return: Invoke emd = genai.GenerativeModel(model) error mapping
""" """
return { return {
InvokeConnectionError: [ InvokeConnectionError: [

View File

@ -86,7 +86,7 @@ class MinimaxLargeLanguageModel(LargeLanguageModel):
Calculate num tokens for minimax model Calculate num tokens for minimax model
not like ChatGLM, Minimax has a special prompt structure, we could not find a proper way not like ChatGLM, Minimax has a special prompt structure, we could not find a proper way
to caculate the num tokens, so we use str() to convert the prompt to string to calculate the num tokens, so we use str() to convert the prompt to string
Minimax does not provide their own tokenizer of adab5.5 and abab5 model Minimax does not provide their own tokenizer of adab5.5 and abab5 model
therefore, we use gpt2 tokenizer instead therefore, we use gpt2 tokenizer instead

View File

@ -10,6 +10,7 @@ from core.model_runtime.model_providers.openai_api_compatible.llm.llm import OAI
class NovitaLargeLanguageModel(OAIAPICompatLargeLanguageModel): class NovitaLargeLanguageModel(OAIAPICompatLargeLanguageModel):
def _update_endpoint_url(self, credentials: dict): def _update_endpoint_url(self, credentials: dict):
credentials['endpoint_url'] = "https://api.novita.ai/v3/openai" credentials['endpoint_url'] = "https://api.novita.ai/v3/openai"
credentials['extra_headers'] = { 'X-Novita-Source': 'dify.ai' } credentials['extra_headers'] = { 'X-Novita-Source': 'dify.ai' }
return credentials return credentials

View File

@ -243,7 +243,7 @@ class OCILargeLanguageModel(LargeLanguageModel):
request_args["compartmentId"] = compartment_id request_args["compartmentId"] = compartment_id
request_args["servingMode"]["modelId"] = model request_args["servingMode"]["modelId"] = model
chathistory = [] chat_history = []
system_prompts = [] system_prompts = []
#if "meta.llama" in model: #if "meta.llama" in model:
# request_args["chatRequest"]["apiFormat"] = "GENERIC" # request_args["chatRequest"]["apiFormat"] = "GENERIC"
@ -273,16 +273,16 @@ class OCILargeLanguageModel(LargeLanguageModel):
if isinstance(message.content, str): if isinstance(message.content, str):
text = message.content text = message.content
if isinstance(message, UserPromptMessage): if isinstance(message, UserPromptMessage):
chathistory.append({"role": "USER", "message": text}) chat_history.append({"role": "USER", "message": text})
else: else:
chathistory.append({"role": "CHATBOT", "message": text}) chat_history.append({"role": "CHATBOT", "message": text})
if isinstance(message, SystemPromptMessage): if isinstance(message, SystemPromptMessage):
if isinstance(message.content, str): if isinstance(message.content, str):
system_prompts.append(message.content) system_prompts.append(message.content)
args = {"apiFormat": "COHERE", args = {"apiFormat": "COHERE",
"preambleOverride": ' '.join(system_prompts), "preambleOverride": ' '.join(system_prompts),
"message": prompt_messages[-1].content, "message": prompt_messages[-1].content,
"chatHistory": chathistory, } "chatHistory": chat_history, }
request_args["chatRequest"].update(args) request_args["chatRequest"].update(args)
elif model.startswith("meta"): elif model.startswith("meta"):
#print("run meta " * 10) #print("run meta " * 10)

View File

@ -552,7 +552,7 @@ class OpenAILargeLanguageModel(_CommonOpenAI, LargeLanguageModel):
try: try:
schema = json.loads(json_schema) schema = json.loads(json_schema)
except: except:
raise ValueError(f"not currect json_schema format: {json_schema}") raise ValueError(f"not correct json_schema format: {json_schema}")
model_parameters.pop("json_schema") model_parameters.pop("json_schema")
model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema} model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}
else: else:

View File

@ -67,7 +67,7 @@ class FlashRecognitionRequest:
class FlashRecognizer: class FlashRecognizer:
""" """
reponse: response:
request_id string request_id string
status Integer status Integer
message String message String
@ -132,9 +132,9 @@ class FlashRecognizer:
signstr = self._format_sign_string(query) signstr = self._format_sign_string(query)
signature = self._sign(signstr, secret_key) signature = self._sign(signstr, secret_key)
header["Authorization"] = signature header["Authorization"] = signature
requrl = "https://" req_url = "https://"
requrl += signstr[4::] req_url += signstr[4::]
return requrl return req_url
def _create_query_arr(self, req): def _create_query_arr(self, req):
return { return {

View File

@ -695,11 +695,11 @@ class VertexAiLargeLanguageModel(LargeLanguageModel):
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
""" """
Map model invoke error to unified error Map model invoke error to unified error
The key is the ermd = gml.GenerativeModel(model)ror type thrown to the caller The key is the ermd = gml.GenerativeModel(model) error type thrown to the caller
The value is the md = gml.GenerativeModel(model)error type thrown by the model, The value is the md = gml.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller. which needs to be converted into a unified error type for the caller.
:return: Invoke emd = gml.GenerativeModel(model)rror mapping :return: Invoke emd = gml.GenerativeModel(model) error mapping
""" """
return { return {
InvokeConnectionError: [ InvokeConnectionError: [

View File

@ -135,16 +135,16 @@ class HttpClient:
**kwargs, **kwargs,
) )
def _object_to_formfata(self, key: str, value: Data | Mapping[object, object]) -> list[tuple[str, str]]: def _object_to_formdata(self, key: str, value: Data | Mapping[object, object]) -> list[tuple[str, str]]:
items = [] items = []
if isinstance(value, Mapping): if isinstance(value, Mapping):
for k, v in value.items(): for k, v in value.items():
items.extend(self._object_to_formfata(f"{key}[{k}]", v)) items.extend(self._object_to_formdata(f"{key}[{k}]", v))
return items return items
if isinstance(value, list | tuple): if isinstance(value, list | tuple):
for v in value: for v in value:
items.extend(self._object_to_formfata(key + "[]", v)) items.extend(self._object_to_formdata(key + "[]", v))
return items return items
def _primitive_value_to_str(val) -> str: def _primitive_value_to_str(val) -> str:
@ -165,7 +165,7 @@ class HttpClient:
def _make_multipartform(self, data: Mapping[object, object]) -> dict[str, object]: def _make_multipartform(self, data: Mapping[object, object]) -> dict[str, object]:
items = flatten([self._object_to_formfata(k, v) for k, v in data.items()]) items = flatten([self._object_to_formdata(k, v) for k, v in data.items()])
serialized: dict[str, object] = {} serialized: dict[str, object] = {}
for key, value in items: for key, value in items:

View File

@ -8,5 +8,5 @@ class UnstructuredNonAsciiCharsCleaner(BaseCleaner):
"""clean document content.""" """clean document content."""
from unstructured.cleaners.core import clean_non_ascii_chars from unstructured.cleaners.core import clean_non_ascii_chars
# Returns "This text containsnon-ascii characters!" # Returns "This text contains non-ascii characters!"
return clean_non_ascii_chars(content) return clean_non_ascii_chars(content)

View File

@ -7,7 +7,7 @@ from core.rag.data_post_processor.data_post_processor import DataPostProcessor
from core.rag.datasource.keyword.keyword_factory import Keyword from core.rag.datasource.keyword.keyword_factory import Keyword
from core.rag.datasource.vdb.vector_factory import Vector from core.rag.datasource.vdb.vector_factory import Vector
from core.rag.rerank.constants.rerank_mode import RerankMode from core.rag.rerank.constants.rerank_mode import RerankMode
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.ext_database import db from extensions.ext_database import db
from models.dataset import Dataset from models.dataset import Dataset
@ -26,7 +26,7 @@ default_retrieval_model = {
class RetrievalService: class RetrievalService:
@classmethod @classmethod
def retrieve(cls, retrival_method: str, dataset_id: str, query: str, def retrieve(cls, retrieval_method: str, dataset_id: str, query: str,
top_k: int, score_threshold: Optional[float] = .0, top_k: int, score_threshold: Optional[float] = .0,
reranking_model: Optional[dict] = None, reranking_mode: Optional[str] = 'reranking_model', reranking_model: Optional[dict] = None, reranking_mode: Optional[str] = 'reranking_model',
weights: Optional[dict] = None): weights: Optional[dict] = None):
@ -39,7 +39,7 @@ class RetrievalService:
threads = [] threads = []
exceptions = [] exceptions = []
# retrieval_model source with keyword # retrieval_model source with keyword
if retrival_method == 'keyword_search': if retrieval_method == 'keyword_search':
keyword_thread = threading.Thread(target=RetrievalService.keyword_search, kwargs={ keyword_thread = threading.Thread(target=RetrievalService.keyword_search, kwargs={
'flask_app': current_app._get_current_object(), 'flask_app': current_app._get_current_object(),
'dataset_id': dataset_id, 'dataset_id': dataset_id,
@ -51,7 +51,7 @@ class RetrievalService:
threads.append(keyword_thread) threads.append(keyword_thread)
keyword_thread.start() keyword_thread.start()
# retrieval_model source with semantic # retrieval_model source with semantic
if RetrievalMethod.is_support_semantic_search(retrival_method): if RetrievalMethod.is_support_semantic_search(retrieval_method):
embedding_thread = threading.Thread(target=RetrievalService.embedding_search, kwargs={ embedding_thread = threading.Thread(target=RetrievalService.embedding_search, kwargs={
'flask_app': current_app._get_current_object(), 'flask_app': current_app._get_current_object(),
'dataset_id': dataset_id, 'dataset_id': dataset_id,
@ -60,19 +60,19 @@ class RetrievalService:
'score_threshold': score_threshold, 'score_threshold': score_threshold,
'reranking_model': reranking_model, 'reranking_model': reranking_model,
'all_documents': all_documents, 'all_documents': all_documents,
'retrival_method': retrival_method, 'retrieval_method': retrieval_method,
'exceptions': exceptions, 'exceptions': exceptions,
}) })
threads.append(embedding_thread) threads.append(embedding_thread)
embedding_thread.start() embedding_thread.start()
# retrieval source with full text # retrieval source with full text
if RetrievalMethod.is_support_fulltext_search(retrival_method): if RetrievalMethod.is_support_fulltext_search(retrieval_method):
full_text_index_thread = threading.Thread(target=RetrievalService.full_text_index_search, kwargs={ full_text_index_thread = threading.Thread(target=RetrievalService.full_text_index_search, kwargs={
'flask_app': current_app._get_current_object(), 'flask_app': current_app._get_current_object(),
'dataset_id': dataset_id, 'dataset_id': dataset_id,
'query': query, 'query': query,
'retrival_method': retrival_method, 'retrieval_method': retrieval_method,
'score_threshold': score_threshold, 'score_threshold': score_threshold,
'top_k': top_k, 'top_k': top_k,
'reranking_model': reranking_model, 'reranking_model': reranking_model,
@ -89,7 +89,7 @@ class RetrievalService:
exception_message = ';\n'.join(exceptions) exception_message = ';\n'.join(exceptions)
raise Exception(exception_message) raise Exception(exception_message)
if retrival_method == RetrievalMethod.HYBRID_SEARCH.value: if retrieval_method == RetrievalMethod.HYBRID_SEARCH.value:
data_post_processor = DataPostProcessor(str(dataset.tenant_id), reranking_mode, data_post_processor = DataPostProcessor(str(dataset.tenant_id), reranking_mode,
reranking_model, weights, False) reranking_model, weights, False)
all_documents = data_post_processor.invoke( all_documents = data_post_processor.invoke(
@ -124,7 +124,7 @@ class RetrievalService:
@classmethod @classmethod
def embedding_search(cls, flask_app: Flask, dataset_id: str, query: str, def embedding_search(cls, flask_app: Flask, dataset_id: str, query: str,
top_k: int, score_threshold: Optional[float], reranking_model: Optional[dict], top_k: int, score_threshold: Optional[float], reranking_model: Optional[dict],
all_documents: list, retrival_method: str, exceptions: list): all_documents: list, retrieval_method: str, exceptions: list):
with flask_app.app_context(): with flask_app.app_context():
try: try:
dataset = db.session.query(Dataset).filter( dataset = db.session.query(Dataset).filter(
@ -146,7 +146,7 @@ class RetrievalService:
) )
if documents: if documents:
if reranking_model and reranking_model.get('reranking_model_name') and reranking_model.get('reranking_provider_name') and retrival_method == RetrievalMethod.SEMANTIC_SEARCH.value: if reranking_model and reranking_model.get('reranking_model_name') and reranking_model.get('reranking_provider_name') and retrieval_method == RetrievalMethod.SEMANTIC_SEARCH.value:
data_post_processor = DataPostProcessor(str(dataset.tenant_id), data_post_processor = DataPostProcessor(str(dataset.tenant_id),
RerankMode.RERANKING_MODEL.value, RerankMode.RERANKING_MODEL.value,
reranking_model, None, False) reranking_model, None, False)
@ -164,7 +164,7 @@ class RetrievalService:
@classmethod @classmethod
def full_text_index_search(cls, flask_app: Flask, dataset_id: str, query: str, def full_text_index_search(cls, flask_app: Flask, dataset_id: str, query: str,
top_k: int, score_threshold: Optional[float], reranking_model: Optional[dict], top_k: int, score_threshold: Optional[float], reranking_model: Optional[dict],
all_documents: list, retrival_method: str, exceptions: list): all_documents: list, retrieval_method: str, exceptions: list):
with flask_app.app_context(): with flask_app.app_context():
try: try:
dataset = db.session.query(Dataset).filter( dataset = db.session.query(Dataset).filter(
@ -180,7 +180,7 @@ class RetrievalService:
top_k=top_k top_k=top_k
) )
if documents: if documents:
if reranking_model and reranking_model.get('reranking_model_name') and reranking_model.get('reranking_provider_name') and retrival_method == RetrievalMethod.FULL_TEXT_SEARCH.value: if reranking_model and reranking_model.get('reranking_model_name') and reranking_model.get('reranking_provider_name') and retrieval_method == RetrievalMethod.FULL_TEXT_SEARCH.value:
data_post_processor = DataPostProcessor(str(dataset.tenant_id), data_post_processor = DataPostProcessor(str(dataset.tenant_id),
RerankMode.RERANKING_MODEL.value, RerankMode.RERANKING_MODEL.value,
reranking_model, None, False) reranking_model, None, False)

View File

@ -275,10 +275,10 @@ class NotionExtractor(BaseExtractor):
data = res.json() data = res.json()
# get table headers text # get table headers text
table_header_cell_texts = [] table_header_cell_texts = []
tabel_header_cells = data["results"][0]['table_row']['cells'] table_header_cells = data["results"][0]['table_row']['cells']
for tabel_header_cell in tabel_header_cells: for table_header_cell in table_header_cells:
if tabel_header_cell: if table_header_cell:
for table_header_cell_text in tabel_header_cell: for table_header_cell_text in table_header_cell:
text = table_header_cell_text["text"]["content"] text = table_header_cell_text["text"]["content"]
table_header_cell_texts.append(text) table_header_cell_texts.append(text)
else: else:

View File

@ -2,7 +2,7 @@
from collections.abc import Iterator from collections.abc import Iterator
from typing import Optional from typing import Optional
from core.rag.extractor.blod.blod import Blob from core.rag.extractor.blob.blob import Blob
from core.rag.extractor.extractor_base import BaseExtractor from core.rag.extractor.extractor_base import BaseExtractor
from core.rag.models.document import Document from core.rag.models.document import Document
from extensions.ext_storage import storage from extensions.ext_storage import storage

View File

@ -34,7 +34,7 @@ class BaseIndexProcessor(ABC):
raise NotImplementedError raise NotImplementedError
@abstractmethod @abstractmethod
def retrieve(self, retrival_method: str, query: str, dataset: Dataset, top_k: int, def retrieve(self, retrieval_method: str, query: str, dataset: Dataset, top_k: int,
score_threshold: float, reranking_model: dict) -> list[Document]: score_threshold: float, reranking_model: dict) -> list[Document]:
raise NotImplementedError raise NotImplementedError

View File

@ -42,7 +42,7 @@ class ParagraphIndexProcessor(BaseIndexProcessor):
hash = helper.generate_text_hash(document_node.page_content) hash = helper.generate_text_hash(document_node.page_content)
document_node.metadata['doc_id'] = doc_id document_node.metadata['doc_id'] = doc_id
document_node.metadata['doc_hash'] = hash document_node.metadata['doc_hash'] = hash
# delete Spliter character # delete Splitter character
page_content = document_node.page_content page_content = document_node.page_content
if page_content.startswith(".") or page_content.startswith(""): if page_content.startswith(".") or page_content.startswith(""):
page_content = page_content[1:].strip() page_content = page_content[1:].strip()
@ -76,10 +76,10 @@ class ParagraphIndexProcessor(BaseIndexProcessor):
else: else:
keyword.delete() keyword.delete()
def retrieve(self, retrival_method: str, query: str, dataset: Dataset, top_k: int, def retrieve(self, retrieval_method: str, query: str, dataset: Dataset, top_k: int,
score_threshold: float, reranking_model: dict) -> list[Document]: score_threshold: float, reranking_model: dict) -> list[Document]:
# Set search parameters. # Set search parameters.
results = RetrievalService.retrieve(retrival_method=retrival_method, dataset_id=dataset.id, query=query, results = RetrievalService.retrieve(retrieval_method=retrieval_method, dataset_id=dataset.id, query=query,
top_k=top_k, score_threshold=score_threshold, top_k=top_k, score_threshold=score_threshold,
reranking_model=reranking_model) reranking_model=reranking_model)
# Organize results. # Organize results.

View File

@ -50,7 +50,7 @@ class QAIndexProcessor(BaseIndexProcessor):
hash = helper.generate_text_hash(document_node.page_content) hash = helper.generate_text_hash(document_node.page_content)
document_node.metadata['doc_id'] = doc_id document_node.metadata['doc_id'] = doc_id
document_node.metadata['doc_hash'] = hash document_node.metadata['doc_hash'] = hash
# delete Spliter character # delete Splitter character
page_content = document_node.page_content page_content = document_node.page_content
if page_content.startswith(".") or page_content.startswith(""): if page_content.startswith(".") or page_content.startswith(""):
page_content = page_content[1:] page_content = page_content[1:]
@ -107,10 +107,10 @@ class QAIndexProcessor(BaseIndexProcessor):
else: else:
vector.delete() vector.delete()
def retrieve(self, retrival_method: str, query: str, dataset: Dataset, top_k: int, def retrieve(self, retrieval_method: str, query: str, dataset: Dataset, top_k: int,
score_threshold: float, reranking_model: dict): score_threshold: float, reranking_model: dict):
# Set search parameters. # Set search parameters.
results = RetrievalService.retrieve(retrival_method=retrival_method, dataset_id=dataset.id, query=query, results = RetrievalService.retrieve(retrieval_method=retrieval_method, dataset_id=dataset.id, query=query,
top_k=top_k, score_threshold=score_threshold, top_k=top_k, score_threshold=score_threshold,
reranking_model=reranking_model) reranking_model=reranking_model)
# Organize results. # Organize results.

View File

@ -21,7 +21,7 @@ from core.rag.data_post_processor.data_post_processor import DataPostProcessor
from core.rag.datasource.keyword.jieba.jieba_keyword_table_handler import JiebaKeywordTableHandler from core.rag.datasource.keyword.jieba.jieba_keyword_table_handler import JiebaKeywordTableHandler
from core.rag.datasource.retrieval_service import RetrievalService from core.rag.datasource.retrieval_service import RetrievalService
from core.rag.models.document import Document from core.rag.models.document import Document
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.rag.retrieval.router.multi_dataset_function_call_router import FunctionCallMultiDatasetRouter from core.rag.retrieval.router.multi_dataset_function_call_router import FunctionCallMultiDatasetRouter
from core.rag.retrieval.router.multi_dataset_react_route import ReactMultiDatasetRouter from core.rag.retrieval.router.multi_dataset_react_route import ReactMultiDatasetRouter
from core.tools.tool.dataset_retriever.dataset_multi_retriever_tool import DatasetMultiRetrieverTool from core.tools.tool.dataset_retriever.dataset_multi_retriever_tool import DatasetMultiRetrieverTool
@ -261,9 +261,9 @@ class DatasetRetrieval:
top_k = retrieval_model_config['top_k'] top_k = retrieval_model_config['top_k']
# get retrieval method # get retrieval method
if dataset.indexing_technique == "economy": if dataset.indexing_technique == "economy":
retrival_method = 'keyword_search' retrieval_method = 'keyword_search'
else: else:
retrival_method = retrieval_model_config['search_method'] retrieval_method = retrieval_model_config['search_method']
# get reranking model # get reranking model
reranking_model = retrieval_model_config['reranking_model'] \ reranking_model = retrieval_model_config['reranking_model'] \
if retrieval_model_config['reranking_enable'] else None if retrieval_model_config['reranking_enable'] else None
@ -275,7 +275,7 @@ class DatasetRetrieval:
with measure_time() as timer: with measure_time() as timer:
results = RetrievalService.retrieve( results = RetrievalService.retrieve(
retrival_method=retrival_method, dataset_id=dataset.id, retrieval_method=retrieval_method, dataset_id=dataset.id,
query=query, query=query,
top_k=top_k, score_threshold=score_threshold, top_k=top_k, score_threshold=score_threshold,
reranking_model=reranking_model, reranking_model=reranking_model,
@ -285,7 +285,7 @@ class DatasetRetrieval:
self._on_query(query, [dataset_id], app_id, user_from, user_id) self._on_query(query, [dataset_id], app_id, user_from, user_id)
if results: if results:
self._on_retrival_end(results, message_id, timer) self._on_retrieval_end(results, message_id, timer)
return results return results
return [] return []
@ -347,14 +347,14 @@ class DatasetRetrieval:
self._on_query(query, dataset_ids, app_id, user_from, user_id) self._on_query(query, dataset_ids, app_id, user_from, user_id)
if all_documents: if all_documents:
self._on_retrival_end(all_documents, message_id, timer) self._on_retrieval_end(all_documents, message_id, timer)
return all_documents return all_documents
def _on_retrival_end( def _on_retrieval_end(
self, documents: list[Document], message_id: Optional[str] = None, timer: Optional[dict] = None self, documents: list[Document], message_id: Optional[str] = None, timer: Optional[dict] = None
) -> None: ) -> None:
"""Handle retrival end.""" """Handle retrieval end."""
for document in documents: for document in documents:
query = db.session.query(DocumentSegment).filter( query = db.session.query(DocumentSegment).filter(
DocumentSegment.index_node_id == document.metadata['doc_id'] DocumentSegment.index_node_id == document.metadata['doc_id']
@ -419,7 +419,7 @@ class DatasetRetrieval:
if dataset.indexing_technique == "economy": if dataset.indexing_technique == "economy":
# use keyword table query # use keyword table query
documents = RetrievalService.retrieve(retrival_method='keyword_search', documents = RetrievalService.retrieve(retrieval_method='keyword_search',
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=top_k top_k=top_k
@ -429,7 +429,7 @@ class DatasetRetrieval:
else: else:
if top_k > 0: if top_k > 0:
# retrieval source # retrieval source
documents = RetrievalService.retrieve(retrival_method=retrieval_model['search_method'], documents = RetrievalService.retrieve(retrieval_method=retrieval_model['search_method'],
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=top_k, top_k=top_k,

View File

@ -29,7 +29,7 @@ credentials_for_provider:
en_US: Please input your OpenAI API key en_US: Please input your OpenAI API key
zh_Hans: 请输入你的 OpenAI API key zh_Hans: 请输入你的 OpenAI API key
pt_BR: Please input your OpenAI API key pt_BR: Please input your OpenAI API key
openai_organizaion_id: openai_organization_id:
type: text-input type: text-input
required: false required: false
label: label:

View File

@ -16,7 +16,7 @@ class DallE2Tool(BuiltinTool):
""" """
invoke tools invoke tools
""" """
openai_organization = self.runtime.credentials.get('openai_organizaion_id', None) openai_organization = self.runtime.credentials.get('openai_organization_id', None)
if not openai_organization: if not openai_organization:
openai_organization = None openai_organization = None
openai_base_url = self.runtime.credentials.get('openai_base_url', None) openai_base_url = self.runtime.credentials.get('openai_base_url', None)

View File

@ -17,7 +17,7 @@ class DallE3Tool(BuiltinTool):
""" """
invoke tools invoke tools
""" """
openai_organization = self.runtime.credentials.get('openai_organizaion_id', None) openai_organization = self.runtime.credentials.get('openai_organization_id', None)
if not openai_organization: if not openai_organization:
openai_organization = None openai_organization = None
openai_base_url = self.runtime.credentials.get('openai_base_url', None) openai_base_url = self.runtime.credentials.get('openai_base_url', None)

View File

@ -4,7 +4,7 @@ from core.tools.errors import ToolProviderCredentialValidationError
from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController
class GihubProvider(BuiltinToolProviderController): class GithubProvider(BuiltinToolProviderController):
def _validate_credentials(self, credentials: dict) -> None: def _validate_credentials(self, credentials: dict) -> None:
try: try:
if 'access_tokens' not in credentials or not credentials.get('access_tokens'): if 'access_tokens' not in credentials or not credentials.get('access_tokens'):

View File

@ -9,7 +9,7 @@ from core.tools.entities.tool_entities import ToolInvokeMessage
from core.tools.tool.builtin_tool import BuiltinTool from core.tools.tool.builtin_tool import BuiltinTool
class GihubRepositoriesTool(BuiltinTool): class GithubRepositoriesTool(BuiltinTool):
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]: def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
""" """
invoke tools invoke tools

View File

@ -60,7 +60,7 @@ class GitlabCommitsTool(BuiltinTool):
project_name = project['name'] project_name = project['name']
print(f"Project: {project_name}") print(f"Project: {project_name}")
# Get all of proejct commits # Get all of project commits
commits_url = f"{domain}/api/v4/projects/{project_id}/repository/commits" commits_url = f"{domain}/api/v4/projects/{project_id}/repository/commits"
params = { params = {
'since': start_time, 'since': start_time,
@ -83,7 +83,7 @@ class GitlabCommitsTool(BuiltinTool):
diffs = diff_response.json() diffs = diff_response.json()
for diff in diffs: for diff in diffs:
# Caculate code lines of changed # Calculate code lines of changed
added_lines = diff['diff'].count('\n+') added_lines = diff['diff'].count('\n+')
removed_lines = diff['diff'].count('\n-') removed_lines = diff['diff'].count('\n-')
total_changes = added_lines + removed_lines total_changes = added_lines + removed_lines

View File

@ -6,7 +6,7 @@ identity:
zh_Hans: GitLab 提交内容查询 zh_Hans: GitLab 提交内容查询
description: description:
human: human:
en_US: A tool for query GitLab commits, Input should be a exists username or projec. en_US: A tool for query GitLab commits, Input should be a exists username or project.
zh_Hans: 一个用于查询 GitLab 代码提交内容的工具,输入的内容应该是一个已存在的用户名或者项目名。 zh_Hans: 一个用于查询 GitLab 代码提交内容的工具,输入的内容应该是一个已存在的用户名或者项目名。
llm: A tool for query GitLab commits, Input should be a exists username or project. llm: A tool for query GitLab commits, Input should be a exists username or project.
parameters: parameters:

View File

@ -29,7 +29,7 @@ class OpenweatherTool(BuiltinTool):
# request URL # request URL
url = "https://api.openweathermap.org/data/2.5/weather" url = "https://api.openweathermap.org/data/2.5/weather"
# request parmas # request params
params = { params = {
"q": city, "q": city,
"appid": self.runtime.credentials.get("api_key"), "appid": self.runtime.credentials.get("api_key"),

View File

@ -35,20 +35,20 @@ def sha256base64(data):
return digest return digest
def parse_url(requset_url): def parse_url(request_url):
stidx = requset_url.index("://") stidx = request_url.index("://")
host = requset_url[stidx + 3 :] host = request_url[stidx + 3 :]
schema = requset_url[: stidx + 3] schema = request_url[: stidx + 3]
edidx = host.index("/") edidx = host.index("/")
if edidx <= 0: if edidx <= 0:
raise AssembleHeaderException("invalid request url:" + requset_url) raise AssembleHeaderException("invalid request url:" + request_url)
path = host[edidx:] path = host[edidx:]
host = host[:edidx] host = host[:edidx]
u = Url(host, path, schema) u = Url(host, path, schema)
return u return u
def assemble_ws_auth_url(requset_url, method="GET", api_key="", api_secret=""): def assemble_ws_auth_url(request_url, method="GET", api_key="", api_secret=""):
u = parse_url(requset_url) u = parse_url(request_url)
host = u.host host = u.host
path = u.path path = u.path
now = datetime.now() now = datetime.now()
@ -69,7 +69,7 @@ def assemble_ws_auth_url(requset_url, method="GET", api_key="", api_secret=""):
) )
values = {"host": host, "date": date, "authorization": authorization} values = {"host": host, "date": date, "authorization": authorization}
return requset_url + "?" + urlencode(values) return request_url + "?" + urlencode(values)
def get_body(appid, text): def get_body(appid, text):

View File

@ -42,6 +42,6 @@ class ScrapeTool(BuiltinTool):
result += "URL: " + i.get('url', '') + "\n" result += "URL: " + i.get('url', '') + "\n"
result += "CONTENT: " + i.get('content', '') + "\n\n" result += "CONTENT: " + i.get('content', '') + "\n\n"
except Exception as e: except Exception as e:
return self.create_text_message("An error occured", str(e)) return self.create_text_message("An error occurred", str(e))
return self.create_text_message(result) return self.create_text_message(result)

View File

@ -8,7 +8,7 @@ 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.rag.datasource.retrieval_service import RetrievalService from core.rag.datasource.retrieval_service import RetrievalService
from core.rag.rerank.rerank_model import RerankModelRunner from core.rag.rerank.rerank_model import RerankModelRunner
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
from extensions.ext_database import db from extensions.ext_database import db
from models.dataset import Dataset, Document, DocumentSegment from models.dataset import Dataset, Document, DocumentSegment
@ -163,7 +163,7 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
if dataset.indexing_technique == "economy": if dataset.indexing_technique == "economy":
# use keyword table query # use keyword table query
documents = RetrievalService.retrieve(retrival_method='keyword_search', documents = RetrievalService.retrieve(retrieval_method='keyword_search',
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=self.top_k top_k=self.top_k
@ -173,7 +173,7 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
else: else:
if self.top_k > 0: if self.top_k > 0:
# retrieval source # retrieval source
documents = RetrievalService.retrieve(retrival_method=retrieval_model['search_method'], documents = RetrievalService.retrieve(retrieval_method=retrieval_model['search_method'],
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=self.top_k, top_k=self.top_k,

View File

@ -2,7 +2,7 @@
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from core.rag.datasource.retrieval_service import RetrievalService from core.rag.datasource.retrieval_service import RetrievalService
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool from core.tools.tool.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool
from extensions.ext_database import db from extensions.ext_database import db
from models.dataset import Dataset, Document, DocumentSegment from models.dataset import Dataset, Document, DocumentSegment
@ -63,7 +63,7 @@ class DatasetRetrieverTool(DatasetRetrieverBaseTool):
retrieval_model = dataset.retrieval_model if dataset.retrieval_model else default_retrieval_model retrieval_model = dataset.retrieval_model if dataset.retrieval_model else default_retrieval_model
if dataset.indexing_technique == "economy": if dataset.indexing_technique == "economy":
# use keyword table query # use keyword table query
documents = RetrievalService.retrieve(retrival_method='keyword_search', documents = RetrievalService.retrieve(retrieval_method='keyword_search',
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=self.top_k top_k=self.top_k
@ -72,7 +72,7 @@ class DatasetRetrieverTool(DatasetRetrieverBaseTool):
else: else:
if self.top_k > 0: if self.top_k > 0:
# retrieval source # retrieval source
documents = RetrievalService.retrieve(retrival_method=retrieval_model.get('search_method', 'semantic_search'), documents = RetrievalService.retrieve(retrieval_method=retrieval_model.get('search_method', 'semantic_search'),
dataset_id=dataset.id, dataset_id=dataset.id,
query=query, query=query,
top_k=self.top_k, top_k=self.top_k,

View File

@ -17,7 +17,7 @@ from core.tools.tool.tool import Tool
class DatasetRetrieverTool(Tool): class DatasetRetrieverTool(Tool):
retrival_tool: DatasetRetrieverBaseTool retrieval_tool: DatasetRetrieverBaseTool
@staticmethod @staticmethod
def get_dataset_tools(tenant_id: str, def get_dataset_tools(tenant_id: str,
@ -42,7 +42,7 @@ class DatasetRetrieverTool(Tool):
# Agent only support SINGLE mode # Agent only support SINGLE mode
original_retriever_mode = retrieve_config.retrieve_strategy original_retriever_mode = retrieve_config.retrieve_strategy
retrieve_config.retrieve_strategy = DatasetRetrieveConfigEntity.RetrieveStrategy.SINGLE retrieve_config.retrieve_strategy = DatasetRetrieveConfigEntity.RetrieveStrategy.SINGLE
retrival_tools = feature.to_dataset_retriever_tool( retrieval_tools = feature.to_dataset_retriever_tool(
tenant_id=tenant_id, tenant_id=tenant_id,
dataset_ids=dataset_ids, dataset_ids=dataset_ids,
retrieve_config=retrieve_config, retrieve_config=retrieve_config,
@ -53,17 +53,17 @@ class DatasetRetrieverTool(Tool):
# restore retrieve strategy # restore retrieve strategy
retrieve_config.retrieve_strategy = original_retriever_mode retrieve_config.retrieve_strategy = original_retriever_mode
# convert retrival tools to Tools # convert retrieval tools to Tools
tools = [] tools = []
for retrival_tool in retrival_tools: for retrieval_tool in retrieval_tools:
tool = DatasetRetrieverTool( tool = DatasetRetrieverTool(
retrival_tool=retrival_tool, retrieval_tool=retrieval_tool,
identity=ToolIdentity(provider='', author='', name=retrival_tool.name, label=I18nObject(en_US='', zh_Hans='')), identity=ToolIdentity(provider='', author='', name=retrieval_tool.name, label=I18nObject(en_US='', zh_Hans='')),
parameters=[], parameters=[],
is_team_authorization=True, is_team_authorization=True,
description=ToolDescription( description=ToolDescription(
human=I18nObject(en_US='', zh_Hans=''), human=I18nObject(en_US='', zh_Hans=''),
llm=retrival_tool.description), llm=retrieval_tool.description),
runtime=DatasetRetrieverTool.Runtime() runtime=DatasetRetrieverTool.Runtime()
) )
@ -95,7 +95,7 @@ class DatasetRetrieverTool(Tool):
return self.create_text_message(text='please input query') return self.create_text_message(text='please input query')
# invoke dataset retriever tool # invoke dataset retriever tool
result = self.retrival_tool._run(query=query) result = self.retrieval_tool._run(query=query)
return self.create_text_message(text=result) return self.create_text_message(text=result)

View File

@ -189,8 +189,8 @@ def extract_text_blocks_as_plain_text(paragraph_html):
def plain_text_leaf_node(element): def plain_text_leaf_node(element):
# Extract all text, stripped of any child HTML elements and normalise it # Extract all text, stripped of any child HTML elements and normalize it
plain_text = normalise_text(element.get_text()) plain_text = normalize_text(element.get_text())
if plain_text != "" and element.name == "li": if plain_text != "" and element.name == "li":
plain_text = "* {}, ".format(plain_text) plain_text = "* {}, ".format(plain_text)
if plain_text == "": if plain_text == "":
@ -231,8 +231,8 @@ def plain_element(element, content_digests, node_indexes):
# For leaf node elements, extract the text content, discarding any HTML tags # For leaf node elements, extract the text content, discarding any HTML tags
# 1. Get element contents as text # 1. Get element contents as text
plain_text = element.get_text() plain_text = element.get_text()
# 2. Normalise the extracted text string to a canonical representation # 2. Normalize the extracted text string to a canonical representation
plain_text = normalise_text(plain_text) plain_text = normalize_text(plain_text)
# 3. Update element content to be plain text # 3. Update element content to be plain text
element.string = plain_text element.string = plain_text
elif is_text(element): elif is_text(element):
@ -243,7 +243,7 @@ def plain_element(element, content_digests, node_indexes):
element = type(element)("") element = type(element)("")
else: else:
plain_text = element.string plain_text = element.string
plain_text = normalise_text(plain_text) plain_text = normalize_text(plain_text)
element = type(element)(plain_text) element = type(element)(plain_text)
else: else:
# If not a leaf node or leaf type call recursively on child nodes, replacing # If not a leaf node or leaf type call recursively on child nodes, replacing
@ -267,12 +267,12 @@ def add_node_indexes(element, node_index="0"):
return element return element
def normalise_text(text): def normalize_text(text):
"""Normalise unicode and whitespace.""" """Normalize unicode and whitespace."""
# Normalise unicode first to try and standardise whitespace characters as much as possible before normalising them # Normalize unicode first to try and standardize whitespace characters as much as possible before normalizing them
text = strip_control_characters(text) text = strip_control_characters(text)
text = normalise_unicode(text) text = normalize_unicode(text)
text = normalise_whitespace(text) text = normalize_whitespace(text)
return text return text
@ -291,14 +291,14 @@ def strip_control_characters(text):
return "".join(["" if (unicodedata.category(char) in control_chars) and (char not in retained_chars) else char for char in text]) return "".join(["" if (unicodedata.category(char) in control_chars) and (char not in retained_chars) else char for char in text])
def normalise_unicode(text): def normalize_unicode(text):
"""Normalise unicode such that things that are visually equivalent map to the same unicode string where possible.""" """Normalize unicode such that things that are visually equivalent map to the same unicode string where possible."""
normal_form = "NFKC" normal_form = "NFKC"
text = unicodedata.normalize(normal_form, text) text = unicodedata.normalize(normal_form, text)
return text return text
def normalise_whitespace(text): def normalize_whitespace(text):
"""Replace runs of whitespace characters with a single space as this is what happens when HTML text is displayed.""" """Replace runs of whitespace characters with a single space as this is what happens when HTML text is displayed."""
text = regex.sub(r"\s+", " ", text) text = regex.sub(r"\s+", " ", text)
# Remove leading and trailing whitespace # Remove leading and trailing whitespace

View File

@ -31,7 +31,7 @@ class VariablePool:
# 'files': [] # 'files': []
# } # }
# Varaible dictionary is a dictionary for looking up variables by their selector. # Variable dictionary is a dictionary for looking up variables by their selector.
# The first element of the selector is the node id, it's the first-level key in the dictionary. # The first element of the selector is the node id, it's the first-level key in the dictionary.
# Other elements of the selector are the keys in the second-level dictionary. To get the key, we hash the # Other elements of the selector are the keys in the second-level dictionary. To get the key, we hash the
# elements of the selector except the first one. # elements of the selector except the first one.

View File

@ -11,7 +11,7 @@ from core.model_manager import ModelInstance, ModelManager
from core.model_runtime.entities.model_entities import ModelFeature, ModelType from core.model_runtime.entities.model_entities import ModelFeature, ModelType
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
from core.rag.retrieval.dataset_retrieval import DatasetRetrieval from core.rag.retrieval.dataset_retrieval import DatasetRetrieval
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.workflow.entities.base_node_data_entities import BaseNodeData from core.workflow.entities.base_node_data_entities import BaseNodeData
from core.workflow.entities.node_entities import NodeRunResult, NodeType from core.workflow.entities.node_entities import NodeRunResult, NodeType
from core.workflow.entities.variable_pool import VariablePool from core.workflow.entities.variable_pool import VariablePool

View File

@ -3,8 +3,8 @@ from .clean_when_document_deleted import handle
from .create_document_index import handle from .create_document_index import handle
from .create_installed_app_when_app_created import handle from .create_installed_app_when_app_created import handle
from .create_site_record_when_app_created import handle from .create_site_record_when_app_created import handle
from .deduct_quota_when_messaeg_created import handle from .deduct_quota_when_message_created import handle
from .delete_tool_parameters_cache_when_sync_draft_workflow import handle from .delete_tool_parameters_cache_when_sync_draft_workflow import handle
from .update_app_dataset_join_when_app_model_config_updated import handle from .update_app_dataset_join_when_app_model_config_updated import handle
from .update_app_dataset_join_when_app_published_workflow_updated import handle from .update_app_dataset_join_when_app_published_workflow_updated import handle
from .update_provider_last_used_at_when_messaeg_created import handle from .update_provider_last_used_at_when_message_created import handle

View File

@ -14,7 +14,7 @@ from sqlalchemy import func
from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.dialects.postgresql import JSONB
from configs import dify_config from configs import dify_config
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.ext_database import db from extensions.ext_database import db
from extensions.ext_storage import storage from extensions.ext_storage import storage

View File

@ -15,7 +15,7 @@ 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.rag.datasource.keyword.keyword_factory import Keyword from core.rag.datasource.keyword.keyword_factory import Keyword
from core.rag.models.document import Document as RAGDocument from core.rag.models.document import Document as RAGDocument
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from events.dataset_event import dataset_was_deleted from events.dataset_event import dataset_was_deleted
from events.document_event import document_was_deleted from events.document_event import document_was_deleted
from extensions.ext_database import db from extensions.ext_database import db

View File

@ -3,7 +3,7 @@ import time
from core.rag.datasource.retrieval_service import RetrievalService from core.rag.datasource.retrieval_service import RetrievalService
from core.rag.models.document import Document from core.rag.models.document import Document
from core.rag.retrieval.retrival_methods import RetrievalMethod from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.ext_database import db from extensions.ext_database import db
from models.account import Account from models.account import Account
from models.dataset import Dataset, DatasetQuery, DocumentSegment from models.dataset import Dataset, DatasetQuery, DocumentSegment
@ -36,7 +36,7 @@ class HitTestingService:
retrieval_model = dataset.retrieval_model if dataset.retrieval_model else default_retrieval_model retrieval_model = dataset.retrieval_model if dataset.retrieval_model else default_retrieval_model
all_documents = RetrievalService.retrieve( all_documents = RetrievalService.retrieve(
retrival_method=retrieval_model.get("search_method", "semantic_search"), retrieval_method=retrieval_model.get("search_method", "semantic_search"),
dataset_id=dataset.id, dataset_id=dataset.id,
query=cls.escape_query_for_search(query), query=cls.escape_query_for_search(query),
top_k=retrieval_model.get("top_k", 2), top_k=retrieval_model.get("top_k", 2),

View File

@ -20,7 +20,7 @@ def sync_website_document_indexing_task(dataset_id: str, document_id: str):
:param dataset_id: :param dataset_id:
:param document_id: :param document_id:
Usage: sunc_website_document_indexing_task.delay(dataset_id, document_id) Usage: sync_website_document_indexing_task.delay(dataset_id, document_id)
""" """
start_at = time.perf_counter() start_at = time.perf_counter()

View File

@ -8,11 +8,11 @@ from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk,
from core.model_runtime.entities.message_entities import AssistantPromptMessage, SystemPromptMessage, UserPromptMessage from core.model_runtime.entities.message_entities import AssistantPromptMessage, SystemPromptMessage, UserPromptMessage
from core.model_runtime.entities.model_entities import AIModelEntity from core.model_runtime.entities.model_entities import AIModelEntity
from core.model_runtime.errors.validate import CredentialsValidateFailedError from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.baichuan.llm.llm import BaichuanLarguageModel from core.model_runtime.model_providers.baichuan.llm.llm import BaichuanLanguageModel
def test_predefined_models(): def test_predefined_models():
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
model_schemas = model.predefined_models() model_schemas = model.predefined_models()
assert len(model_schemas) >= 1 assert len(model_schemas) >= 1
assert isinstance(model_schemas[0], AIModelEntity) assert isinstance(model_schemas[0], AIModelEntity)
@ -20,7 +20,7 @@ def test_predefined_models():
def test_validate_credentials_for_chat_model(): def test_validate_credentials_for_chat_model():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
with pytest.raises(CredentialsValidateFailedError): with pytest.raises(CredentialsValidateFailedError):
model.validate_credentials( model.validate_credentials(
@ -38,7 +38,7 @@ def test_validate_credentials_for_chat_model():
def test_invoke_model(): def test_invoke_model():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
response = model.invoke( response = model.invoke(
model="baichuan2-turbo", model="baichuan2-turbo",
@ -64,7 +64,7 @@ def test_invoke_model():
def test_invoke_model_with_system_message(): def test_invoke_model_with_system_message():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
response = model.invoke( response = model.invoke(
model="baichuan2-turbo", model="baichuan2-turbo",
@ -93,7 +93,7 @@ def test_invoke_model_with_system_message():
def test_invoke_stream_model(): def test_invoke_stream_model():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
response = model.invoke( response = model.invoke(
model="baichuan2-turbo", model="baichuan2-turbo",
@ -122,7 +122,7 @@ def test_invoke_stream_model():
def test_invoke_with_search(): def test_invoke_with_search():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
response = model.invoke( response = model.invoke(
model="baichuan2-turbo", model="baichuan2-turbo",
@ -156,7 +156,7 @@ def test_invoke_with_search():
def test_get_num_tokens(): def test_get_num_tokens():
sleep(3) sleep(3)
model = BaichuanLarguageModel() model = BaichuanLanguageModel()
response = model.get_num_tokens( response = model.get_num_tokens(
model="baichuan2-turbo", model="baichuan2-turbo",

View File

@ -155,7 +155,7 @@ def test_invoke_chat_model_with_vision_multi_pics(setup_google_mock):
user="abc-123", user="abc-123",
) )
print(f"resultz: {result.message.content}") print(f"result: {result.message.content}")
assert isinstance(result, LLMResult) assert isinstance(result, LLMResult)
assert len(result.message.content) > 0 assert len(result.message.content) > 0

View File

@ -109,7 +109,7 @@ def test_invoke_stream_chat_model(setup_openai_mock, setup_xinference_mock):
""" """
Funtion calling of xinference does not support stream mode currently Function calling of xinference does not support stream mode currently
""" """
# def test_invoke_stream_chat_model_with_functions(): # def test_invoke_stream_chat_model_with_functions():
# model = XinferenceAILargeLanguageModel() # model = XinferenceAILargeLanguageModel()

View File

@ -31,5 +31,5 @@ class PGVectoRSVectorTest(AbstractVectorTest):
assert len(ids) == 1 assert len(ids) == 1
def test_pgvecot_rs(setup_mock_redis): def test_pgvecto_rs(setup_mock_redis):
PGVectoRSVectorTest().run_all_tests() PGVectoRSVectorTest().run_all_tests()

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DB_INITIALISED="/opt/oracle/oradata/dbinit" DB_INITIALIZED="/opt/oracle/oradata/dbinit"
#[ -f ${DB_INITIALISED} ] && exit #[ -f ${DB_INITIALIZED} ] && exit
#touch ${DB_INITIALISED} #touch ${DB_INITIALIZED}
if [ -f ${DB_INITIALISED} ]; then if [ -f ${DB_INITIALIZED} ]; then
echo 'File exists. Standards for have been Init' echo 'File exists. Standards for have been Init'
exit exit
else else
echo 'File does not exist. Standards for first time Strart up this DB' echo 'File does not exist. Standards for first time Start up this DB'
"$ORACLE_HOME"/bin/sqlplus -s "/ as sysdba" @"/opt/oracle/scripts/startup/init_user.script"; "$ORACLE_HOME"/bin/sqlplus -s "/ as sysdba" @"/opt/oracle/scripts/startup/init_user.script";
touch ${DB_INITIALISED} touch ${DB_INITIALIZED}
fi fi

View File

@ -18,7 +18,7 @@ const query = 'Please tell me a short story in 10 words or less.'
const remote_url_files = [{ const remote_url_files = [{
type: 'image', type: 'image',
transfer_method: 'remote_url', transfer_method: 'remote_url',
url: 'your_url_addresss' url: 'your_url_address'
}] }]
// Create a completion client // Create a completion client

View File

@ -108,7 +108,7 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
useEffect(() => { useEffect(() => {
setAppDetail() setAppDetail()
fetchAppDetail({ url: '/apps', id: appId }).then((res) => { fetchAppDetail({ url: '/apps', id: appId }).then((res) => {
// redirections // redirection
if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) { if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) {
router.replace(`/app/${appId}/workflow`) router.replace(`/app/${appId}/workflow`)
} }

View File

@ -21,7 +21,7 @@ import Divider from '@/app/components/base/divider'
import { getRedirection } from '@/utils/app-redirection' import { getRedirection } from '@/utils/app-redirection'
import { useProviderContext } from '@/context/provider-context' import { useProviderContext } from '@/context/provider-context'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { AiText, ChatBot, CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal' import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
import EditAppModal from '@/app/components/explore/create-app-modal' import EditAppModal from '@/app/components/explore/create-app-modal'
@ -273,7 +273,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
<ChatBot className='w-3 h-3 text-[#1570EF]' /> <ChatBot className='w-3 h-3 text-[#1570EF]' />
)} )}
{app.mode === 'agent-chat' && ( {app.mode === 'agent-chat' && (
<CuteRobote className='w-3 h-3 text-indigo-600' /> <CuteRobot className='w-3 h-3 text-indigo-600' />
)} )}
{app.mode === 'chat' && ( {app.mode === 'chat' && (
<ChatBot className='w-3 h-3 text-[#1570EF]' /> <ChatBot className='w-3 h-3 text-[#1570EF]' />

View File

@ -35,7 +35,7 @@ import { DataSourceType } from '@/models/datasets'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n/language'
import { useStore } from '@/app/components/app/store' import { useStore } from '@/app/components/app/store'
import { AiText, ChatBot, CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
import { getLocaleOnClient } from '@/i18n' import { getLocaleOnClient } from '@/i18n'
import { useAppContext } from '@/context/app-context' import { useAppContext } from '@/context/app-context'
@ -67,7 +67,7 @@ const LikedItem = ({
<ChatBot className='w-2.5 h-2.5 text-[#1570EF]' /> <ChatBot className='w-2.5 h-2.5 text-[#1570EF]' />
)} )}
{detail.mode === 'agent-chat' && ( {detail.mode === 'agent-chat' && (
<CuteRobote className='w-2.5 h-2.5 text-indigo-600' /> <CuteRobot className='w-2.5 h-2.5 text-indigo-600' />
)} )}
{detail.mode === 'chat' && ( {detail.mode === 'chat' && (
<ChatBot className='w-2.5 h-2.5 text-[#1570EF]' /> <ChatBot className='w-2.5 h-2.5 text-[#1570EF]' />

View File

@ -148,7 +148,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
- original_document_id Source document ID (optional) - original_document_id Source document ID (optional)
- Used to re-upload the document or modify the document cleaning and segmentation configuration. The missing information is copied from the source document - Used to re-upload the document or modify the document cleaning and segmentation configuration. The missing information is copied from the source document
- The source document cannot be an archived document - The source document cannot be an archived document
- When original_document_id is passed in, the update operation is performed on behalf of the document. process_rule is a fillable item. If not filled in, the segmentation method of the source document will be used by defaul - When original_document_id is passed in, the update operation is performed on behalf of the document. process_rule is a fillable item. If not filled in, the segmentation method of the source document will be used by default
- When original_document_id is not passed in, the new operation is performed on behalf of the document, and process_rule is required - When original_document_id is not passed in, the new operation is performed on behalf of the document, and process_rule is required
- indexing_technique Index mode - indexing_technique Index mode

View File

@ -142,7 +142,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
</Property> </Property>
</Properties> </Properties>
### Request Bodys ### Request Body
<Properties> <Properties>
<Property name='data' type='multipart/form-data json string' key='data'> <Property name='data' type='multipart/form-data json string' key='data'>
- original_document_id 源文档 ID (选填) - original_document_id 源文档 ID (选填)

View File

@ -22,7 +22,7 @@ import { copyApp, deleteApp, exportAppConfig, updateAppInfo } from '@/service/ap
import DuplicateAppModal from '@/app/components/app/duplicate-modal' import DuplicateAppModal from '@/app/components/app/duplicate-modal'
import type { DuplicateAppModalProps } from '@/app/components/app/duplicate-modal' import type { DuplicateAppModalProps } from '@/app/components/app/duplicate-modal'
import CreateAppModal from '@/app/components/explore/create-app-modal' import CreateAppModal from '@/app/components/explore/create-app-modal'
import { AiText, ChatBot, CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal' import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
@ -214,7 +214,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
<ChatBot className={cn('w-3 h-3 text-[#1570EF]', !expand && '!w-2.5 !h-2.5')} /> <ChatBot className={cn('w-3 h-3 text-[#1570EF]', !expand && '!w-2.5 !h-2.5')} />
)} )}
{appDetail.mode === 'agent-chat' && ( {appDetail.mode === 'agent-chat' && (
<CuteRobote className={cn('w-3 h-3 text-indigo-600', !expand && '!w-2.5 !h-2.5')} /> <CuteRobot className={cn('w-3 h-3 text-indigo-600', !expand && '!w-2.5 !h-2.5')} />
)} )}
{appDetail.mode === 'chat' && ( {appDetail.mode === 'chat' && (
<ChatBot className={cn('w-3 h-3 text-[#1570EF]', !expand && '!w-2.5 !h-2.5')} /> <ChatBot className={cn('w-3 h-3 text-[#1570EF]', !expand && '!w-2.5 !h-2.5')} />
@ -280,7 +280,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
<ChatBot className='w-3 h-3 text-[#1570EF]' /> <ChatBot className='w-3 h-3 text-[#1570EF]' />
)} )}
{appDetail.mode === 'agent-chat' && ( {appDetail.mode === 'agent-chat' && (
<CuteRobote className='w-3 h-3 text-indigo-600' /> <CuteRobot className='w-3 h-3 text-indigo-600' />
)} )}
{appDetail.mode === 'chat' && ( {appDetail.mode === 'chat' && (
<ChatBot className='w-3 h-3 text-[#1570EF]' /> <ChatBot className='w-3 h-3 text-[#1570EF]' />
@ -323,7 +323,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
</div> </div>
</div> </div>
</div> </div>
{/* desscription */} {/* description */}
{appDetail.description && ( {appDetail.description && (
<div className='px-4 py-2 text-gray-500 text-xs leading-[18px]'>{appDetail.description}</div> <div className='px-4 py-2 text-gray-500 text-xs leading-[18px]'>{appDetail.description}</div>
)} )}

View File

@ -232,8 +232,8 @@ const Annotation: FC<Props> = ({
middlePagesSiblingCount={1} middlePagesSiblingCount={1}
setCurrentPage={setCurrPage} setCurrentPage={setCurrPage}
totalPages={Math.ceil(total / APP_PAGE_LIMIT)} totalPages={Math.ceil(total / APP_PAGE_LIMIT)}
truncableClassName="w-8 px-0.5 text-center" truncatableClassName="w-8 px-0.5 text-center"
truncableText="..." truncatableText="..."
> >
<Pagination.PrevButton <Pagination.PrevButton
disabled={currPage === 0} disabled={currPage === 0}

View File

@ -156,8 +156,8 @@ const ViewAnnotationModal: FC<Props> = ({
middlePagesSiblingCount={1} middlePagesSiblingCount={1}
setCurrentPage={setCurrPage} setCurrentPage={setCurrPage}
totalPages={Math.ceil(total / APP_PAGE_LIMIT)} totalPages={Math.ceil(total / APP_PAGE_LIMIT)}
truncableClassName="w-8 px-0.5 text-center" truncatableClassName="w-8 px-0.5 text-center"
truncableText="..." truncatableText="..."
> >
<Pagination.PrevButton <Pagination.PrevButton
disabled={currPage === 0} disabled={currPage === 0}

View File

@ -262,7 +262,7 @@ const AdvancedPromptInput: FC<Props> = ({
{isShowConfirmAddVar && ( {isShowConfirmAddVar && (
<ConfirmAddVar <ConfirmAddVar
varNameArr={newPromptVariables.map(v => v.name)} varNameArr={newPromptVariables.map(v => v.name)}
onConfrim={handleAutoAdd(true)} onConfirm={handleAutoAdd(true)}
onCancel={handleAutoAdd(false)} onCancel={handleAutoAdd(false)}
onHide={hideConfirmAddVar} onHide={hideConfirmAddVar}
/> />

View File

@ -7,7 +7,7 @@ import Button from '@/app/components/base/button'
export type IConfirmAddVarProps = { export type IConfirmAddVarProps = {
varNameArr: string[] varNameArr: string[]
onConfrim: () => void onConfirm: () => void
onCancel: () => void onCancel: () => void
onHide: () => void onHide: () => void
} }
@ -22,7 +22,7 @@ const VarIcon = (
const ConfirmAddVar: FC<IConfirmAddVarProps> = ({ const ConfirmAddVar: FC<IConfirmAddVarProps> = ({
varNameArr, varNameArr,
onConfrim, onConfirm,
onCancel, onCancel,
// onHide, // onHide,
}) => { }) => {
@ -63,7 +63,7 @@ const ConfirmAddVar: FC<IConfirmAddVarProps> = ({
</div> </div>
<div className='mt-7 flex justify-end space-x-2'> <div className='mt-7 flex justify-end space-x-2'>
<Button onClick={onCancel}>{t('common.operation.cancel')}</Button> <Button onClick={onCancel}>{t('common.operation.cancel')}</Button>
<Button variant='primary' onClick={onConfrim}>{t('common.operation.add')}</Button> <Button variant='primary' onClick={onConfirm}>{t('common.operation.add')}</Button>
</div> </div>
</div> </div>

View File

@ -33,7 +33,7 @@ export type ISimplePromptInput = {
promptTemplate: string promptTemplate: string
promptVariables: PromptVariable[] promptVariables: PromptVariable[]
readonly?: boolean readonly?: boolean
onChange?: (promp: string, promptVariables: PromptVariable[]) => void onChange?: (prompt: string, promptVariables: PromptVariable[]) => void
noTitle?: boolean noTitle?: boolean
gradientBorder?: boolean gradientBorder?: boolean
editorHeight?: number editorHeight?: number
@ -239,7 +239,7 @@ const Prompt: FC<ISimplePromptInput> = ({
{isShowConfirmAddVar && ( {isShowConfirmAddVar && (
<ConfirmAddVar <ConfirmAddVar
varNameArr={newPromptVariables.map(v => v.name)} varNameArr={newPromptVariables.map(v => v.name)}
onConfrim={handleAutoAdd(true)} onConfirm={handleAutoAdd(true)}
onCancel={handleAutoAdd(false)} onCancel={handleAutoAdd(false)}
onHide={hideConfirmAddVar} onHide={hideConfirmAddVar}
/> />

View File

@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { RiCloseLine } from '@remixicon/react' import { RiCloseLine } from '@remixicon/react'
import ItemPanel from './item-panel' import ItemPanel from './item-panel'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Unblur } from '@/app/components/base/icons/src/vender/solid/education' import { Unblur } from '@/app/components/base/icons/src/vender/solid/education'
import Slider from '@/app/components/base/slider' import Slider from '@/app/components/base/slider'
import type { AgentConfig } from '@/models/debug' import type { AgentConfig } from '@/models/debug'
@ -65,7 +65,7 @@ const AgentSetting: FC<Props> = ({
<ItemPanel <ItemPanel
className='mb-4' className='mb-4'
icon={ icon={
<CuteRobote className='w-4 h-4 text-indigo-600' /> <CuteRobot className='w-4 h-4 text-indigo-600' />
} }
name={t('appDebug.agent.agentMode')} name={t('appDebug.agent.agentMode')}
description={t('appDebug.agent.agentModeDes')} description={t('appDebug.agent.agentModeDes')}

View File

@ -12,7 +12,7 @@ import {
} from '@/app/components/base/portal-to-follow-elem' } from '@/app/components/base/portal-to-follow-elem'
import { BubbleText } from '@/app/components/base/icons/src/vender/solid/education' import { BubbleText } from '@/app/components/base/icons/src/vender/solid/education'
import Radio from '@/app/components/base/radio/ui' import Radio from '@/app/components/base/radio/ui'
import { CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Settings04 } from '@/app/components/base/icons/src/vender/line/general' import { Settings04 } from '@/app/components/base/icons/src/vender/line/general'
import { ArrowUpRight } from '@/app/components/base/icons/src/vender/line/arrows' import { ArrowUpRight } from '@/app/components/base/icons/src/vender/line/arrows'
import type { AgentConfig } from '@/models/debug' import type { AgentConfig } from '@/models/debug'
@ -117,7 +117,7 @@ const AssistantTypePicker: FC<Props> = ({
> >
<PortalToFollowElemTrigger onClick={() => setOpen(v => !v)}> <PortalToFollowElemTrigger onClick={() => setOpen(v => !v)}>
<div className={cn(open && 'bg-gray-50', 'flex items-center h-8 px-3 border border-black/5 rounded-lg cursor-pointer select-none space-x-1 text-indigo-600')}> <div className={cn(open && 'bg-gray-50', 'flex items-center h-8 px-3 border border-black/5 rounded-lg cursor-pointer select-none space-x-1 text-indigo-600')}>
{isAgent ? <BubbleText className='w-3 h-3' /> : <CuteRobote className='w-3 h-3' />} {isAgent ? <BubbleText className='w-3 h-3' /> : <CuteRobot className='w-3 h-3' />}
<div className='text-xs font-medium'>{t(`appDebug.assistantType.${isAgent ? 'agentAssistant' : 'chatAssistant'}.name`)}</div> <div className='text-xs font-medium'>{t(`appDebug.assistantType.${isAgent ? 'agentAssistant' : 'chatAssistant'}.name`)}</div>
<RiArrowDownSLine className='w-3 h-3' /> <RiArrowDownSLine className='w-3 h-3' />
</div> </div>
@ -135,7 +135,7 @@ const AssistantTypePicker: FC<Props> = ({
onClick={handleChange} onClick={handleChange}
/> />
<SelectItem <SelectItem
Icon={CuteRobote} Icon={CuteRobot}
value='agent' value='agent'
disabled={disabled} disabled={disabled}
text={t('appDebug.assistantType.agentAssistant.name')} text={t('appDebug.assistantType.agentAssistant.name')}

View File

@ -35,7 +35,7 @@ function useFeature({
moderation: boolean moderation: boolean
setModeration: (moderation: boolean) => void setModeration: (moderation: boolean) => void
}) { }) {
const [tempshowOpeningStatement, setTempShowOpeningStatement] = React.useState(!!introduction) const [tempShowOpeningStatement, setTempShowOpeningStatement] = React.useState(!!introduction)
useEffect(() => { useEffect(() => {
// wait to api data back // wait to api data back
if (introduction) if (introduction)
@ -48,7 +48,7 @@ function useFeature({
// }, [moreLikeThis]) // }, [moreLikeThis])
const featureConfig = { const featureConfig = {
openingStatement: tempshowOpeningStatement, openingStatement: tempShowOpeningStatement,
moreLikeThis, moreLikeThis,
suggestedQuestionsAfterAnswer, suggestedQuestionsAfterAnswer,
speechToText, speechToText,

View File

@ -7,9 +7,9 @@ import { useBoolean, useScroll } from 'ahooks'
import { useFormattingChangedDispatcher } from '../debug/hooks' import { useFormattingChangedDispatcher } from '../debug/hooks'
import DatasetConfig from '../dataset-config' import DatasetConfig from '../dataset-config'
import ChatGroup from '../features/chat-group' import ChatGroup from '../features/chat-group'
import ExperienceEnchanceGroup from '../features/experience-enchance-group' import ExperienceEnhanceGroup from '../features/experience-enhance-group'
import Toolbox from '../toolbox' import Toolbox from '../toolbox'
import HistoryPanel from '../config-prompt/conversation-histroy/history-panel' import HistoryPanel from '../config-prompt/conversation-history/history-panel'
import ConfigVision from '../config-vision' import ConfigVision from '../config-vision'
import useAnnotationConfig from '../toolbox/annotation/use-annotation-config' import useAnnotationConfig from '../toolbox/annotation/use-annotation-config'
import AddFeatureBtn from './feature/add-feature-btn' import AddFeatureBtn from './feature/add-feature-btn'
@ -254,7 +254,7 @@ const Config: FC = () => {
/> />
)} )}
{/* ChatConifig */} {/* ChatConfig */}
{ {
hasChatConfig && ( hasChatConfig && (
<ChatGroup <ChatGroup
@ -277,7 +277,7 @@ const Config: FC = () => {
{/* Text Generation config */}{ {/* Text Generation config */}{
hasCompletionConfig && ( hasCompletionConfig && (
<ExperienceEnchanceGroup <ExperienceEnhanceGroup
isShowMoreLike={moreLikeThisConfig.enabled} isShowMoreLike={moreLikeThisConfig.enabled}
isShowTextToSpeech={featureConfig.textToSpeech && !!text2speechDefaultModel} isShowTextToSpeech={featureConfig.textToSpeech && !!text2speechDefaultModel}
/> />

View File

@ -70,13 +70,13 @@ const ParamsConfig = ({
const { const {
defaultModel: rerankDefaultModel, defaultModel: rerankDefaultModel,
currentModel: isRerankDefaultModelVaild, currentModel: isRerankDefaultModelValid,
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank) } = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
const isValid = () => { const isValid = () => {
let errMsg = '' let errMsg = ''
if (tempDataSetConfigs.retrieval_model === RETRIEVE_TYPE.multiWay) { if (tempDataSetConfigs.retrieval_model === RETRIEVE_TYPE.multiWay) {
if (!tempDataSetConfigs.reranking_model?.reranking_model_name && (!rerankDefaultModel && isRerankDefaultModelVaild)) if (!tempDataSetConfigs.reranking_model?.reranking_model_name && (!rerankDefaultModel && isRerankDefaultModelValid))
errMsg = t('appDebug.datasetConfig.rerankModelRequired') errMsg = t('appDebug.datasetConfig.rerankModelRequired')
} }
if (errMsg) { if (errMsg) {

View File

@ -135,7 +135,7 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
</div> </div>
<div className={cn('max-w-[200px] text-[13px] font-medium text-gray-800 overflow-hidden text-ellipsis whitespace-nowrap', !item.embedding_available && 'opacity-50 !max-w-[120px]')}>{item.name}</div> <div className={cn('max-w-[200px] text-[13px] font-medium text-gray-800 overflow-hidden text-ellipsis whitespace-nowrap', !item.embedding_available && 'opacity-50 !max-w-[120px]')}>{item.name}</div>
{!item.embedding_available && ( {!item.embedding_available && (
<span className='ml-1 shrink-0 px-1 border boder-gray-200 rounded-md text-gray-500 text-xs font-normal leading-[18px]'>{t('dataset.unavailable')}</span> <span className='ml-1 shrink-0 px-1 border border-gray-200 rounded-md text-gray-500 text-xs font-normal leading-[18px]'>{t('dataset.unavailable')}</span>
)} )}
</div> </div>
{ {

View File

@ -51,7 +51,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
const { const {
modelList: rerankModelList, modelList: rerankModelList,
defaultModel: rerankDefaultModel, defaultModel: rerankDefaultModel,
currentModel: isRerankDefaultModelVaild, currentModel: isRerankDefaultModelValid,
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank) } = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank)
const { t } = useTranslation() const { t } = useTranslation()
const { notify } = useToastContext() const { notify } = useToastContext()
@ -83,7 +83,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
if ( if (
!isReRankModelSelected({ !isReRankModelSelected({
rerankDefaultModel, rerankDefaultModel,
isRerankDefaultModelVaild: !!isRerankDefaultModelVaild, isRerankDefaultModelValid: !!isRerankDefaultModelValid,
rerankModelList, rerankModelList,
retrievalConfig, retrievalConfig,
indexMethod, indexMethod,

View File

@ -89,7 +89,7 @@ const ChatItem: FC<ChatItemProps> = ({
`apps/${appId}/chat-messages`, `apps/${appId}/chat-messages`,
data, data,
{ {
onGetConvesationMessages: (conversationId, getAbortController) => fetchConversationMessages(appId, conversationId, getAbortController), onGetConversationMessages: (conversationId, getAbortController) => fetchConversationMessages(appId, conversationId, getAbortController),
onGetSuggestedQuestions: (responseItemId, getAbortController) => fetchSuggestedQuestions(appId, responseItemId, getAbortController), onGetSuggestedQuestions: (responseItemId, getAbortController) => fetchSuggestedQuestions(appId, responseItemId, getAbortController),
}, },
) )

View File

@ -94,7 +94,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
`apps/${appId}/chat-messages`, `apps/${appId}/chat-messages`,
data, data,
{ {
onGetConvesationMessages: (conversationId, getAbortController) => fetchConversationMessages(appId, conversationId, getAbortController), onGetConversationMessages: (conversationId, getAbortController) => fetchConversationMessages(appId, conversationId, getAbortController),
onGetSuggestedQuestions: (responseItemId, getAbortController) => fetchSuggestedQuestions(appId, responseItemId, getAbortController), onGetSuggestedQuestions: (responseItemId, getAbortController) => fetchSuggestedQuestions(appId, responseItemId, getAbortController),
}, },
) )

View File

@ -287,7 +287,7 @@ const OpeningStatement: FC<IOpeningStatementProps> = ({
{isShowConfirmAddVar && ( {isShowConfirmAddVar && (
<ConfirmAddVar <ConfirmAddVar
varNameArr={notIncludeKeys} varNameArr={notIncludeKeys}
onConfrim={autoAddVar} onConfirm={autoAddVar}
onCancel={cancelAutoAddVar} onCancel={cancelAutoAddVar}
onHide={hideConfirmAddVar} onHide={hideConfirmAddVar}
/> />

View File

@ -16,7 +16,7 @@ type ExperienceGroupProps = {
isShowMoreLike: boolean isShowMoreLike: boolean
} }
const ExperienceEnchanceGroup: FC<ExperienceGroupProps> = ({ const ExperienceEnhanceGroup: FC<ExperienceGroupProps> = ({
isShowTextToSpeech, isShowTextToSpeech,
isShowMoreLike, isShowMoreLike,
}) => { }) => {
@ -40,4 +40,4 @@ const ExperienceEnchanceGroup: FC<ExperienceGroupProps> = ({
</div> </div>
) )
} }
export default React.memo(ExperienceEnchanceGroup) export default React.memo(ExperienceEnhanceGroup)

View File

@ -14,7 +14,7 @@ import Loading from '../../base/loading'
import AppPublisher from '../app-publisher' import AppPublisher from '../app-publisher'
import AgentSettingButton from './config/agent-setting-button' import AgentSettingButton from './config/agent-setting-button'
import useAdvancedPromptConfig from './hooks/use-advanced-prompt-config' import useAdvancedPromptConfig from './hooks/use-advanced-prompt-config'
import EditHistoryModal from './config-prompt/conversation-histroy/edit-modal' import EditHistoryModal from './config-prompt/conversation-history/edit-modal'
import { import {
useDebugWithSingleOrMultipleModel, useDebugWithSingleOrMultipleModel,
useFormattingChangedDispatcher, useFormattingChangedDispatcher,

View File

@ -64,7 +64,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
const systemOpenaiProviderQuota = systemOpenaiProviderEnabled ? openaiProvider?.system_configuration.quota_configurations.find(item => item.quota_type === openaiProvider.system_configuration.current_quota_type) : undefined const systemOpenaiProviderQuota = systemOpenaiProviderEnabled ? openaiProvider?.system_configuration.quota_configurations.find(item => item.quota_type === openaiProvider.system_configuration.current_quota_type) : undefined
const systemOpenaiProviderCanUse = systemOpenaiProviderQuota?.is_valid const systemOpenaiProviderCanUse = systemOpenaiProviderQuota?.is_valid
const customOpenaiProvidersCanUse = openaiProvider?.custom_configuration.status === CustomConfigurationStatusEnum.active const customOpenaiProvidersCanUse = openaiProvider?.custom_configuration.status === CustomConfigurationStatusEnum.active
const openaiProviderConfiged = customOpenaiProvidersCanUse || systemOpenaiProviderCanUse const isOpenAIProviderConfigured = customOpenaiProvidersCanUse || systemOpenaiProviderCanUse
const providers: Provider[] = [ const providers: Provider[] = [
{ {
key: 'openai_moderation', key: 'openai_moderation',
@ -190,7 +190,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
} }
const handleSave = () => { const handleSave = () => {
if (localeData.type === 'openai_moderation' && !openaiProviderConfiged) if (localeData.type === 'openai_moderation' && !isOpenAIProviderConfigured)
return return
if (!localeData.config?.inputs_config?.enabled && !localeData.config?.outputs_config?.enabled) { if (!localeData.config?.inputs_config?.enabled && !localeData.config?.outputs_config?.enabled) {
@ -254,7 +254,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
className={` className={`
flex items-center px-3 py-2 rounded-lg text-sm text-gray-900 cursor-pointer flex items-center px-3 py-2 rounded-lg text-sm text-gray-900 cursor-pointer
${localeData.type === provider.key ? 'bg-white border-[1.5px] border-primary-400 shadow-sm' : 'border border-gray-100 bg-gray-25'} ${localeData.type === provider.key ? 'bg-white border-[1.5px] border-primary-400 shadow-sm' : 'border border-gray-100 bg-gray-25'}
${localeData.type === 'openai_moderation' && provider.key === 'openai_moderation' && !openaiProviderConfiged && 'opacity-50'} ${localeData.type === 'openai_moderation' && provider.key === 'openai_moderation' && !isOpenAIProviderConfigured && 'opacity-50'}
`} `}
onClick={() => handleDataTypeChange(provider.key)} onClick={() => handleDataTypeChange(provider.key)}
> >
@ -267,7 +267,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
} }
</div> </div>
{ {
!isLoading && !openaiProviderConfiged && localeData.type === 'openai_moderation' && ( !isLoading && !isOpenAIProviderConfigured && localeData.type === 'openai_moderation' && (
<div className='flex items-center mt-2 px-3 py-2 bg-[#FFFAEB] rounded-lg border border-[#FEF0C7]'> <div className='flex items-center mt-2 px-3 py-2 bg-[#FFFAEB] rounded-lg border border-[#FEF0C7]'>
<InfoCircle className='mr-1 w-4 h-4 text-[#F79009]' /> <InfoCircle className='mr-1 w-4 h-4 text-[#F79009]' />
<div className='flex items-center text-xs font-medium text-gray-700'> <div className='flex items-center text-xs font-medium text-gray-700'>
@ -361,7 +361,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
<Button <Button
variant='primary' variant='primary'
onClick={handleSave} onClick={handleSave}
disabled={localeData.type === 'openai_moderation' && !openaiProviderConfiged} disabled={localeData.type === 'openai_moderation' && !isOpenAIProviderConfigured}
> >
{t('common.operation.save')} {t('common.operation.save')}
</Button> </Button>

View File

@ -172,12 +172,12 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
} }
} }
const formatedData = formatData(localeData) const formattedData = formatData(localeData)
if (onValidateBeforeSave && !onValidateBeforeSave(formatedData)) if (onValidateBeforeSave && !onValidateBeforeSave(formattedData))
return return
onSave(formatData(formatedData)) onSave(formatData(formattedData))
} }
const action = data.type ? t('common.operation.edit') : t('common.operation.add') const action = data.type ? t('common.operation.edit') : t('common.operation.add')

View File

@ -21,7 +21,7 @@ import Modal from '@/app/components/base/modal'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import AppIcon from '@/app/components/base/app-icon' import AppIcon from '@/app/components/base/app-icon'
import AppsFull from '@/app/components/billing/apps-full-in-dialog' import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import { AiText, ChatBot, CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
@ -158,7 +158,7 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => {
setShowChatBotType(false) setShowChatBotType(false)
}} }}
> >
<CuteRobote className='w-6 h-6 text-indigo-600' /> <CuteRobot className='w-6 h-6 text-indigo-600' />
<div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.types.agent')}</div> <div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.types.agent')}</div>
</div> </div>
</Tooltip> </Tooltip>

View File

@ -119,8 +119,8 @@ const Logs: FC<ILogsProps> = ({ appDetail }) => {
middlePagesSiblingCount={1} middlePagesSiblingCount={1}
setCurrentPage={setCurrPage} setCurrentPage={setCurrPage}
totalPages={Math.ceil(total / APP_PAGE_LIMIT)} totalPages={Math.ceil(total / APP_PAGE_LIMIT)}
truncableClassName="w-8 px-0.5 text-center" truncatableClassName="w-8 px-0.5 text-center"
truncableText="..." truncatableText="..."
> >
<Pagination.PrevButton <Pagination.PrevButton
disabled={currPage === 0} disabled={currPage === 0}

View File

@ -19,7 +19,7 @@ import { useTranslation } from 'react-i18next'
import s from './style.module.css' import s from './style.module.css'
import VarPanel from './var-panel' import VarPanel from './var-panel'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import type { FeedbackFunc, Feedbacktype, IChatItem, SubmitAnnotationFunc } from '@/app/components/base/chat/chat/type' import type { FeedbackFunc, FeedbackType, IChatItem, SubmitAnnotationFunc } from '@/app/components/base/chat/chat/type'
import type { Annotation, ChatConversationFullDetailResponse, ChatConversationGeneralDetail, ChatConversationsResponse, ChatMessage, ChatMessagesRequest, CompletionConversationFullDetailResponse, CompletionConversationGeneralDetail, CompletionConversationsResponse, LogAnnotation } from '@/models/log' import type { Annotation, ChatConversationFullDetailResponse, ChatConversationGeneralDetail, ChatConversationsResponse, ChatMessage, ChatMessagesRequest, CompletionConversationFullDetailResponse, CompletionConversationGeneralDetail, CompletionConversationsResponse, LogAnnotation } from '@/models/log'
import type { App } from '@/types/app' import type { App } from '@/types/app'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
@ -541,7 +541,7 @@ const CompletionConversationDetailComp: FC<{ appId?: string; conversationId?: st
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const { t } = useTranslation() const { t } = useTranslation()
const handleFeedback = async (mid: string, { rating }: Feedbacktype): Promise<boolean> => { const handleFeedback = async (mid: string, { rating }: FeedbackType): Promise<boolean> => {
try { try {
await updateLogMessageFeedbacks({ url: `/apps/${appId}/feedbacks`, body: { message_id: mid, rating } }) await updateLogMessageFeedbacks({ url: `/apps/${appId}/feedbacks`, body: { message_id: mid, rating } })
conversationDetailMutate() conversationDetailMutate()
@ -586,7 +586,7 @@ const ChatConversationDetailComp: FC<{ appId?: string; conversationId?: string }
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const { t } = useTranslation() const { t } = useTranslation()
const handleFeedback = async (mid: string, { rating }: Feedbacktype): Promise<boolean> => { const handleFeedback = async (mid: string, { rating }: FeedbackType): Promise<boolean> => {
try { try {
await updateLogMessageFeedbacks({ url: `/apps/${appId}/feedbacks`, body: { message_id: mid, rating } }) await updateLogMessageFeedbacks({ url: `/apps/${appId}/feedbacks`, body: { message_id: mid, rating } })
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })

View File

@ -16,13 +16,13 @@ import { Markdown } from '@/app/components/base/markdown'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'
import AudioBtn from '@/app/components/base/audio-btn' import AudioBtn from '@/app/components/base/audio-btn'
import type { Feedbacktype } from '@/app/components/base/chat/chat/type' import type { FeedbackType } from '@/app/components/base/chat/chat/type'
import { fetchMoreLikeThis, updateFeedback } from '@/service/share' import { fetchMoreLikeThis, updateFeedback } from '@/service/share'
import { File02 } from '@/app/components/base/icons/src/vender/line/files' import { File02 } from '@/app/components/base/icons/src/vender/line/files'
import { Bookmark } from '@/app/components/base/icons/src/vender/line/general' import { Bookmark } from '@/app/components/base/icons/src/vender/line/general'
import { Stars02 } from '@/app/components/base/icons/src/vender/line/weather' import { Stars02 } from '@/app/components/base/icons/src/vender/line/weather'
import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows' import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
import { fetchTextGenerationMessge } from '@/service/debug' import { fetchTextGenerationMessage } from '@/service/debug'
import AnnotationCtrlBtn from '@/app/components/app/configuration/toolbox/annotation/annotation-ctrl-btn' import AnnotationCtrlBtn from '@/app/components/app/configuration/toolbox/annotation/annotation-ctrl-btn'
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal' import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
@ -47,8 +47,8 @@ export type IGenerationItemProps = {
isInWebApp?: boolean isInWebApp?: boolean
moreLikeThis?: boolean moreLikeThis?: boolean
depth?: number depth?: number
feedback?: Feedbacktype feedback?: FeedbackType
onFeedback?: (feedback: Feedbacktype) => void onFeedback?: (feedback: FeedbackType) => void
onSave?: (messageId: string) => void onSave?: (messageId: string) => void
isMobile?: boolean isMobile?: boolean
isInstalledApp: boolean isInstalledApp: boolean
@ -125,7 +125,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
const [completionRes, setCompletionRes] = useState('') const [completionRes, setCompletionRes] = useState('')
const [childMessageId, setChildMessageId] = useState<string | null>(null) const [childMessageId, setChildMessageId] = useState<string | null>(null)
const hasChild = !!childMessageId const hasChild = !!childMessageId
const [childFeedback, setChildFeedback] = useState<Feedbacktype>({ const [childFeedback, setChildFeedback] = useState<FeedbackType>({
rating: null, rating: null,
}) })
const { const {
@ -135,7 +135,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem) const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem)
const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal) const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal)
const handleFeedback = async (childFeedback: Feedbacktype) => { const handleFeedback = async (childFeedback: FeedbackType) => {
await updateFeedback({ url: `/messages/${childMessageId}/feedbacks`, body: { rating: childFeedback.rating } }, isInstalledApp, installedAppId) await updateFeedback({ url: `/messages/${childMessageId}/feedbacks`, body: { rating: childFeedback.rating } }, isInstalledApp, installedAppId)
setChildFeedback(childFeedback) setChildFeedback(childFeedback)
} }
@ -205,7 +205,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
}, [isLoading]) }, [isLoading])
const handleOpenLogModal = async () => { const handleOpenLogModal = async () => {
const data = await fetchTextGenerationMessge({ const data = await fetchTextGenerationMessage({
appId: params.appId as string, appId: params.appId as string,
messageId: messageId!, messageId: messageId!,
}) })

View File

@ -9,7 +9,7 @@ import {
} from '@/app/components/base/portal-to-follow-elem' } from '@/app/components/base/portal-to-follow-elem'
import { Check, DotsGrid } from '@/app/components/base/icons/src/vender/line/general' import { Check, DotsGrid } from '@/app/components/base/icons/src/vender/line/general'
import { XCircle } from '@/app/components/base/icons/src/vender/solid/general' import { XCircle } from '@/app/components/base/icons/src/vender/solid/general'
import { ChatBot, CuteRobote } from '@/app/components/base/icons/src/vender/solid/communication' import { ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
export type AppSelectorProps = { export type AppSelectorProps = {
value: string value: string
@ -65,7 +65,7 @@ const AppTypeSelector = ({ value, onChange }: AppSelectorProps) => {
{value === 'agent' && ( {value === 'agent' && (
<> <>
<div className='w-4 h-4 p-[1px]'> <div className='w-4 h-4 p-[1px]'>
<CuteRobote className='w-3.5 h-3.5 text-indigo-600' /> <CuteRobot className='w-3.5 h-3.5 text-indigo-600' />
</div> </div>
<div className=''>{t('app.typeSelector.agent')}</div> <div className=''>{t('app.typeSelector.agent')}</div>
<div className='w-4 h-4 p-[1px]' onClick={(e) => { <div className='w-4 h-4 p-[1px]' onClick={(e) => {
@ -106,7 +106,7 @@ const AppTypeSelector = ({ value, onChange }: AppSelectorProps) => {
onChange('agent') onChange('agent')
setOpen(false) setOpen(false)
}}> }}>
<CuteRobote className='mr-2 w-4 h-4 text-indigo-600' /> <CuteRobot className='mr-2 w-4 h-4 text-indigo-600' />
<div className='grow text-gray-700 text-[13px] font-medium leading-[18px]'>{t('app.typeSelector.agent')}</div> <div className='grow text-gray-700 text-[13px] font-medium leading-[18px]'>{t('app.typeSelector.agent')}</div>
{value === 'agent' && <Check className='w-4 h-4 text-primary-600' />} {value === 'agent' && <Check className='w-4 h-4 text-primary-600' />}
</div> </div>

View File

@ -93,8 +93,8 @@ const Logs: FC<ILogsProps> = ({ appDetail }) => {
middlePagesSiblingCount={1} middlePagesSiblingCount={1}
setCurrentPage={setCurrPage} setCurrentPage={setCurrPage}
totalPages={Math.ceil(total / APP_PAGE_LIMIT)} totalPages={Math.ceil(total / APP_PAGE_LIMIT)}
truncableClassName="w-8 px-0.5 text-center" truncatableClassName="w-8 px-0.5 text-center"
truncableText="..." truncatableText="..."
> >
<Pagination.PrevButton <Pagination.PrevButton
disabled={currPage === 0} disabled={currPage === 0}

View File

@ -97,7 +97,7 @@ const AgentLogDetail: FC<AgentLogDetailProps> = ({
onClick={() => switchTab('TRACING')} onClick={() => switchTab('TRACING')}
>{t('runLog.tracing')}</div> >{t('runLog.tracing')}</div>
</div> </div>
{/* panel detal */} {/* panel detail */}
<div className={cn('grow bg-white h-0 overflow-y-auto rounded-b-2xl', currentTab !== 'DETAIL' && '!bg-gray-50')}> <div className={cn('grow bg-white h-0 overflow-y-auto rounded-b-2xl', currentTab !== 'DETAIL' && '!bg-gray-50')}>
{loading && ( {loading && (
<div className='flex h-full items-center justify-center bg-white'> <div className='flex h-full items-center justify-center bg-white'>

View File

@ -53,7 +53,7 @@ const BlockInput: FC<IBlockInputProps> = ({
const [isEditing, setIsEditing] = useState<boolean>(false) const [isEditing, setIsEditing] = useState<boolean>(false)
useEffect(() => { useEffect(() => {
if (isEditing && contentEditableRef.current) { if (isEditing && contentEditableRef.current) {
// TODO: Focus at the click positon // TODO: Focus at the click position
if (currentValue) if (currentValue)
contentEditableRef.current.setSelectionRange(currentValue.length, currentValue.length) contentEditableRef.current.setSelectionRange(currentValue.length, currentValue.length)
@ -119,7 +119,7 @@ const BlockInput: FC<IBlockInputProps> = ({
onBlur={() => { onBlur={() => {
blur() blur()
setIsEditing(false) setIsEditing(false)
// click confirm also make blur. Then outter value is change. So below code has problem. // click confirm also make blur. Then outer value is change. So below code has problem.
// setTimeout(() => { // setTimeout(() => {
// handleCancel() // handleCancel()
// }, 1000) // }, 1000)

View File

@ -217,12 +217,12 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
}, [newConversation]) }, [newConversation])
const currentConversationItem = useMemo(() => { const currentConversationItem = useMemo(() => {
let coversationItem = conversationList.find(item => item.id === currentConversationId) let conversationItem = conversationList.find(item => item.id === currentConversationId)
if (!coversationItem && pinnedConversationList.length) if (!conversationItem && pinnedConversationList.length)
coversationItem = pinnedConversationList.find(item => item.id === currentConversationId) conversationItem = pinnedConversationList.find(item => item.id === currentConversationId)
return coversationItem return conversationItem
}, [conversationList, currentConversationId, pinnedConversationList]) }, [conversationList, currentConversationId, pinnedConversationList])
const { notify } = useToastContext() const { notify } = useToastContext()

View File

@ -24,7 +24,7 @@ const Citation: FC<CitationProps> = ({
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const elesRef = useRef<HTMLDivElement[]>([]) const elesRef = useRef<HTMLDivElement[]>([])
const [limitNumberInOneLine, setlimitNumberInOneLine] = useState(0) const [limitNumberInOneLine, setLimitNumberInOneLine] = useState(0)
const [showMore, setShowMore] = useState(false) const [showMore, setShowMore] = useState(false)
const resources = useMemo(() => data.reduce((prev: Resources[], next) => { const resources = useMemo(() => data.reduce((prev: Resources[], next) => {
const documentId = next.document_id const documentId = next.document_id
@ -57,14 +57,14 @@ const Citation: FC<CitationProps> = ({
totalWidth -= elesRef.current[i].clientWidth totalWidth -= elesRef.current[i].clientWidth
if (totalWidth + 34 > containerWidth!) if (totalWidth + 34 > containerWidth!)
setlimitNumberInOneLine(i - 1) setLimitNumberInOneLine(i - 1)
else else
setlimitNumberInOneLine(i) setLimitNumberInOneLine(i)
break break
} }
else { else {
setlimitNumberInOneLine(i + 1) setLimitNumberInOneLine(i + 1)
} }
} }
} }

View File

@ -26,7 +26,7 @@ import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player
type GetAbortController = (abortController: AbortController) => void type GetAbortController = (abortController: AbortController) => void
type SendCallback = { type SendCallback = {
onGetConvesationMessages?: (conversationId: string, getAbortController: GetAbortController) => Promise<any> onGetConversationMessages?: (conversationId: string, getAbortController: GetAbortController) => Promise<any>
onGetSuggestedQuestions?: (responseItemId: string, getAbortController: GetAbortController) => Promise<any> onGetSuggestedQuestions?: (responseItemId: string, getAbortController: GetAbortController) => Promise<any>
onConversationComplete?: (conversationId: string) => void onConversationComplete?: (conversationId: string) => void
isPublicAPI?: boolean isPublicAPI?: boolean
@ -198,7 +198,7 @@ export const useChat = (
url: string, url: string,
data: any, data: any,
{ {
onGetConvesationMessages, onGetConversationMessages,
onGetSuggestedQuestions, onGetSuggestedQuestions,
onConversationComplete, onConversationComplete,
isPublicAPI, isPublicAPI,
@ -324,8 +324,8 @@ export const useChat = (
if (onConversationComplete) if (onConversationComplete)
onConversationComplete(conversationId.current) onConversationComplete(conversationId.current)
if (conversationId.current && !hasStopResponded.current && onGetConvesationMessages) { if (conversationId.current && !hasStopResponded.current && onGetConversationMessages) {
const { data }: any = await onGetConvesationMessages( const { data }: any = await onGetConversationMessages(
conversationId.current, conversationId.current,
newAbortController => conversationMessagesAbortControllerRef.current = newAbortController, newAbortController => conversationMessagesAbortControllerRef.current = newAbortController,
) )

Some files were not shown because too many files have changed in this diff Show More