Skip to content

Commit 7170e15

Browse files
Merge branch 'v2' into virtualized-tree@v2
2 parents c005998 + 40b9c7d commit 7170e15

16 files changed

Lines changed: 50 additions & 25 deletions

File tree

apps/application/flow/compare/not_contain_compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def support(self, node_id, fields: List[str], source_value, compare, target_valu
2020
def compare(self, source_value, compare, target_value):
2121
if isinstance(source_value, str):
2222
return str(target_value) not in source_value
23-
elif isinstance(self, list):
23+
elif isinstance(source_value, list):
2424
return not any([str(item) == str(target_value) for item in source_value])
2525
else:
2626
return str(target_value) not in str(source_value)

apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def convert_value(name: str, value, _type, is_required, source, node):
110110
if _type == 'int':
111111
return int(value)
112112
if _type == 'boolean':
113-
value = 0 if ['0', '[]'].__contains__(value) else value
113+
if isinstance(value, str) and value.lower() in ('false', '0', '[]', ''):
114+
return False
114115
return bool(value)
115116
if _type == 'float':
116117
return float(value)

apps/application/flow/step_node/tool_node/impl/base_tool_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ def convert_value(name: str, value, _type, is_required, source, node):
8585
if _type == 'int':
8686
return int(value)
8787
if _type == 'boolean':
88-
value = 0 if ['0', '[]'].__contains__(value) else value
88+
if isinstance(value, str) and value.lower() in ('false', '0', '[]', ''):
89+
return False
8990
return bool(value)
9091
if _type == 'float':
9192
return float(value)

apps/application/flow/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def generate_tool_message_complete(icon, name, input_content, output_content):
303303
"output": output_content
304304
}
305305
}
306-
return f'<tool_calls_render>{json.dumps(content)}</tool_calls_render>'
306+
return f'<tool_calls_render>{json.dumps(content, ensure_ascii=False)}</tool_calls_render>'
307307

308308

309309
# 全局单例事件循环

apps/application/long_term_memory/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
import uuid_utils.compat as uuid
3-
from django.db.models import QuerySet
3+
from django.db.models import Count, QuerySet
44
from langchain_core.messages import HumanMessage
55

66
from application.models import Chat, ChatRecord, Application, ApplicationLongTermMemory
@@ -228,8 +228,10 @@ def _execute_scheduled_extract(workspace_id, application_id):
228228
chat_user_ids = list(
229229
QuerySet(Chat).filter(application_id=application_id)
230230
.exclude(chat_user_id__isnull=True)
231+
.values('chat_user_id')
232+
.annotate(count=Count('chat_user_id'))
233+
.filter(count__gt=1)
231234
.values_list('chat_user_id', flat=True)
232-
.distinct()
233235
)
234236
for chat_user_id in chat_user_ids:
235237
config = _get_long_term_config(application, chat_user_id)

apps/knowledge/views/paragraph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def get(self, request: Request, workspace_id: str, knowledge_id: str, document_i
6464
@log(
6565
menu='Paragraph', operate='Create Paragraph',
6666
get_operation_object=lambda r, keywords: get_knowledge_document_operation_object(
67-
get_knowledge_operation_object(keywords.get('knowledge_id')),
6867
get_knowledge_operation_object(keywords.get('knowledge_id')),
6968
get_document_operation_object(keywords.get('document_id'))
7069
),

apps/models_provider/impl/aliyun_bai_lian_model_provider/model/embedding.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@date:2024/10/16 16:34
77
@desc:
88
"""
9+
from http import HTTPStatus
910
from typing import Dict, List
1011

1112
from openai import OpenAI
@@ -16,11 +17,15 @@
1617
class AliyunBaiLianEmbedding(MaxKBBaseModel):
1718
model_name: str
1819
optional_params: dict
20+
api_base: str
21+
api_key: str
1922

2023
def __init__(self, api_key, model_name: str, api_base: str, optional_params: dict):
2124
self.client = OpenAI(api_key=api_key, base_url=api_base).embeddings
2225
self.model_name = model_name
2326
self.optional_params = optional_params
27+
self.api_key = api_key
28+
self.api_base = api_base
2429

2530
def is_cache_model(self):
2631
return False
@@ -42,6 +47,24 @@ def embed_query(self, text: str):
4247
def embed_documents(
4348
self, texts: List[str], chunk_size: int | None = None
4449
) -> List[List[float]]:
50+
# 处理多模态的向量化
51+
if any(k in self.model_name for k in ("vl-embedding", "embedding-vision", "multimodal")):
52+
import dashscope
53+
dashscope.api_key = self.api_key
54+
dashscope.base_http_api_url = self.api_base
55+
multimodal_input = [{"text": text} for text in texts]
56+
resp = dashscope.MultiModalEmbedding.call(
57+
model="tongyi-embedding-vision-plus",
58+
input=multimodal_input, # type: ignore
59+
**self.optional_params
60+
)
61+
62+
if resp.status_code == HTTPStatus.OK:
63+
embeddings_data = resp.output.get('embeddings', [])
64+
return [item.get('embedding', []) for item in embeddings_data]
65+
else:
66+
raise Exception(f'MultiModalEmbedding call failed: status={resp.status_code}, message={resp.message}')
67+
4568
if len(self.optional_params) > 0:
4669
res = self.client.create(
4770
input=texts, model=self.model_name, encoding_format="float",
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
2-
<rect width="100%" height="100%" rx="4" fill="#1A1A2E"/>
3-
<text x="12" y="16" text-anchor="middle" font-family="Arial, sans-serif" font-weight="bold" font-size="10" fill="#E94560">M</text>
4-
</svg>
1+
<svg t="1776929669814" class="icon" viewBox="0 0 1169 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4810" width="100%" height="100%"><path d="M474.173841 470.682521V847.403039c-25.441562 127.572805-194.68465 94.674371-195.416638 2.192962-0.802986-116.24 0-231.750012 0-347.113027V368.697276c0-16.740712-3.654937-29.973484-18.275685-40.428305-28.512509-21.346633-62.725921 3.728936-63.456908 34.507407-1.608972 41.305289-0.804986 81.733594-1.608973 122.453893 0 32.167446 0 63.384909 0.730988 95.478357C175.164986 722.025196 3.947932 698.5576 0 581.512614V483.5493c0-32.021449 62.725921-39.551319 59.655973 8.406855-2.046965 23.759591-0.731987 48.25117-1.535973 71.791765-0.729987 42.036277 63.530907 70.32879 78.663646 1.607972 0.730987-56.658025 0.730987-113.31605 0.730988-170.486067 0-71.644767 20.32365-129.984763 96.282343-135.39467 32.898434-2.92395 54.757058 10.819814 75.738697 34.579405 8.042862 8.407855 27.049535 35.092396 27.781522 64.115897 0 26.75754 0.729987 53.368082 0.729987 80.418616 0 53.367082-0.729987 107.028158-0.729987 160.39724 0 34.579405 0.729987 68.792816 0.729987 102.568235 0 42.841263 0 86.267516-0.729987 129.180778-0.730987 55.78104 67.111845 54.977054 78.005658-0.876985 0-65.796868 0.729987-130.78875 0.729987-196.585618 0-162.078211-0.729987-324.157422-0.729987-486.163634 0-16.814711-2.33996-63.456908 6.579886-80.417617C469.274925-48.744541 613.003452 1.625592 614.319429 97.176948c2.777952 195.781631 0 393.756225 0.730988 589.975848 0 68.062829-55.269049 53.44208-58.338996 26.830538 0-204.188487 0-409.180959 0.729987-613.07745-2.703953-51.175119-78.589648-44.229239-82.976572-7.529871-1.461975 42.109275-0.729987 84.950538-1.461975 126.987815v250.025698h0.730987l0.511992 0.292995z" fill="#D4367A" p-id="4811"></path><path d="M696.347018 467.684573v276.638239-652.848766c24.709575-128.44779 193.880664-95.038365 194.611651-2.484957 0.803986 115.437014 0 231.677014 0.803986 347.040028 0 44.303238 0 88.752473-0.730987 133.055711 0 17.545698 4.312926 29.900486 19.007673 41.159292 27.780522 20.835641 61.921935-3.654937 63.456908-34.945399 1.535974-40.501303 0.731987-81.002606 0.731987-122.527892v-94.893367c21.200635-141.315568 191.906698-117.847972 195.488637-0.803986V711.645375c0 32.166447-61.994933 39.769316-59.216981-8.334857 1.680971-24.490579 0-304.930753 0.876985-329.49433 1.461975-41.305289-63.602906-70.402789-78.663647-0.876985v169.609081c0 72.66875-20.396649 130.057762-97.013331 136.271656-72.228757 1.680971-101.253258-48.25117-103.593217-98.695302V237.250538c0-43.645249 0-86.266516 0.731987-129.107779 0.729987-55.78004-67.112845-55.78004-78.663646 0.804986v767.626792c0 16.667713 2.33996 63.383909-5.921898 80.417616-47.300186 115.363015-191.7607 64.918883-193.076678-30.559474v-90.871437c3.582938-61.190947 55.269049-46.643197 57.609009-20.762642V922.631744c2.777952 51.321117 78.663646 45.107224 82.245585 7.602869 1.534974-42.109275 1.534974-84.146552 1.534973-127.059813V467.757571h-0.219996v-0.072998z" fill="#ED6D48" p-id="4812"></path></svg>

apps/tools/serializers/tool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ def convert_value(name: str, value: str, _type: str, is_required: bool):
536536
if _type == 'int':
537537
return int(value)
538538
if _type == 'boolean':
539-
value = 0 if ['0', '[]'].__contains__(value) else value
539+
if isinstance(value, str) and value.lower() in ('false', '0', '[]', ''):
540+
return False
540541
return bool(value)
541542
if _type == 'float':
542543
return float(value)

apps/trigger/handler/impl/task/tool_task/base_tool_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def _convert_value(_type, value):
5050
if _type == 'int':
5151
return int(value)
5252
if _type == 'boolean':
53-
value = 0 if ['0', '[]'].__contains__(value) else value
53+
if isinstance(value, str) and value.lower() in ('false', '0', '[]', ''):
54+
return False
5455
return bool(value)
5556
if _type == 'float':
5657
return float(value)

0 commit comments

Comments
 (0)