Skip to content

Commit

Permalink
Merge branch 'baidubce:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
userpj authored Dec 20, 2024
2 parents 8726783 + bbaca94 commit 3e42a69
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
4 changes: 0 additions & 4 deletions python/core/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,18 @@ async def build_curl(self, method, url, data=None, json_data=None, **kwargs) ->

return curl

@session_post
async def post(self, url, data=None, json=None, **kwargs):
logger.debug("Curl Command:\n" + await self.build_curl(hdrs.METH_POST, url, data=data, json_data=json, **kwargs) + "\n")
return await super().post(url=url, data=data, json=json, **kwargs)

@session_post
async def delete(self, url, **kwargs):
logger.debug("Curl Command:\n" + await self.build_curl(hdrs.METH_DELETE, url, **kwargs) + "\n")
return await super().delete(url=url, **kwargs)

@session_post
async def get(self, url, **kwargs):
logger.debug("Curl Command:\n" + await self.build_curl(hdrs.METH_GET, url, **kwargs) + "\n")
return await super().get(url=url, **kwargs)

@session_post
async def put(self, url, data=None, **kwargs):
logger.debug("Curl Command:\n" + await self.build_curl(hdrs.METH_PUT, url, data=data, **kwargs) + "\n")
return await super().put(url=url, data=data, **kwargs)
12 changes: 8 additions & 4 deletions python/tests/component_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
SKIP_COMPONENTS = [
]

V2_SKIP_COMPONENTS = [
"ASR",
]

# 白名单中的组件因历史原因,检查失败,但可以正常使用,因此加入白名单
COMPONENT_WHITE_LIST = [
"RagWithBaiduSearchPro",
Expand Down Expand Up @@ -75,10 +79,10 @@
def get_component_white_list():
return COMPONENT_WHITE_LIST

def get_components(components_list, import_prefix):
def get_components(components_list, import_prefix, skip_components):
components = {}
for component in components_list:
if component in SKIP_COMPONENTS:
if component.__name__ in skip_components:
continue

try:
Expand All @@ -98,12 +102,12 @@ def get_components(components_list, import_prefix):

def get_all_components():
from appbuilder import __COMPONENTS__
all_components = get_components(__COMPONENTS__, "appbuilder.")
all_components = get_components(__COMPONENTS__, "appbuilder.", SKIP_COMPONENTS)
return all_components

def get_v2_components():
from appbuilder.core.components.v2 import __V2_COMPONENTS__
v2_components = get_components(__V2_COMPONENTS__, "appbuilder.core.components.v2.")
v2_components = get_components(__V2_COMPONENTS__, "appbuilder.core.components.v2.", V2_SKIP_COMPONENTS)
return v2_components

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_all_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def write_error_data(txt_file_path, error_df, error_stats):
file.write(f"错误信息: {error}, 出现次数: {count}\n")
print(f"\n错误信息已写入: {txt_file_path}")

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "")
class TestComponentManifestsAndToolEval(unittest.TestCase):
"""
组件manifests和tool_eval入参测试类
Expand Down
15 changes: 7 additions & 8 deletions python/tests/test_appbuilder_components_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def setUp(self):
无返回值。
"""
self.audio_file_url = "https://bj.bcebos.com/v1/appbuilder/asr_test.pcm?authorization=bce-auth-v1" \
"%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-01-11T10%3A56%3A41Z%2F-1%2Fhost" \
"%2Fa6c4d2ca8a3f0259f4cae8ae3fa98a9f75afde1a063eaec04847c99ab7d1e411"
self.asr = appbuilder.ASR()
self.image_url = "https://bj.bcebos.com/v1/appbuilder/table_ocr_test.png?"\
"authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-01-24T12%3A37%3A09Z%2F-1%2Fhost%2Fab528a5a9120d328dc6d18c6"\
"064079145ff4698856f477b820147768fc2187d3"
self.table_ocr = appbuilder.TableOCR()
self.play = appbuilder.Playground(prompt_template="你好,{name},我是{bot_name},{bot_name}是一个{bot_type},我可以{bot_function},你可以问我{bot_question}。", model="ERNIE-3.5-8K")
model_name = "ERNIE-3.5-8K"
secret_key = os.getenv('SECRET_KEY', None)
Expand All @@ -77,10 +77,9 @@ def test_trace(self):
tracer.start_trace()

# test asr run and tool_eval
raw_audio = requests.get(self.audio_file_url).content
inp = appbuilder.Message(content={"raw_audio": raw_audio})
out = self.asr.run(inp)
result = self.asr.tool_eval(name="asr", streaming=True, file_url=self.audio_file_url)
out = self.table_ocr.run(appbuilder.Message(content={"url": self.image_url}))
print(out)
result = self.table_ocr.tool_eval(name="asr", streaming=True, file_names=[self.image_url])
for res in result:
print(res)

Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from appbuilder.core.components.asr.model import ShortSpeechRecognitionRequest, ShortSpeechRecognitionResponse
import os

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skip("测试API超限,暂时跳过")
class TestASRComponent(unittest.TestCase):
def setUp(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from appbuilder.core._exception import InvalidRequestArgumentError
import os

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skip("测试API超限,暂时跳过")
class TestTTS(unittest.TestCase):
def setUp(self):
self.tts = appbuilder.TTS()
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_v2_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from appbuilder.core.components.v2 import ASR
from appbuilder.core.components.v2.asr.component import _convert as convert

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skip("测试API超限,暂时跳过")
class TestASR(unittest.TestCase):
def setUp(self):
self.audio_file_url = "https://bj.bcebos.com/v1/appbuilder/asr_test.pcm?authorization=bce-auth-v1" \
Expand Down

0 comments on commit 3e42a69

Please sign in to comment.