Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复Assistant非流式调用BUG #537

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appbuilder/core/assistant/type/thread_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class LastError(BaseModel):

class FinalAnswerMessage(BaseModel):
message_id: Optional[str] = ""
content: Optional[AssistantContent] = None
content: Optional[list[AssistantContent]] = []

class FinalAnswer(BaseModel):
type: Optional[str] = "message"
Expand Down
32 changes: 29 additions & 3 deletions appbuilder/tests/test_assistant_class_runs.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import unittest
import os
import appbuilder
from tests.pytest_utils import Utils
# from tests.pytest_utils import Utils

import random
import string
import os

class Utils(object):
"""
utils 方法父类
"""
@staticmethod
def get_random_string(str_len, prefix=None):
"""
生成随机字符串,可指定前缀
"""
gen_name = ''.join(
random.choice(string.ascii_letters + string.digits) for _ in range(str_len)
)
if prefix:
name = str(prefix) + gen_name
else:
name = gen_name
return name

@staticmethod
def get_data_file(filename):
current_dir = os.path.dirname(os.path.abspath(__file__))
full_file_path = os.path.join(current_dir, "data", filename)
return full_file_path

def get_cur_whether(location:str, unit:str):
return "{} 的当前温度是30 {}".format(location, unit)

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "")
# @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "")
class TestFunctionCall(unittest.TestCase):
def setUp(self):
os.environ["APPBUILDER_TOKEN"] = os.environ["APPBUILDER_TOKEN_V2"]
Expand Down Expand Up @@ -55,7 +81,7 @@ def test_run_create_v1(self):
self.assertEqual(run_result.assistant_id, assistant.id)
self.assertEqual(run_result.thread_id, thread.id)
self.assertEqual(run_result.status, "completed")
self.assertIn("秦始皇", run_result.final_answer.message.content.text.value)
self.assertIn("我是秦始皇", run_result.final_answer.message.content[0].text.value)

def test_run_create_v2(self):
assistant = appbuilder.assistant.assistants.create(
Expand Down
2 changes: 1 addition & 1 deletion appbuilder/tests/test_doc_format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setUpClass(cls):
pass

def setUp(self):
os.environ["APPBUILDER_TOKEN"] = os.environ["APPBUILDER_TOKEN_DOC_FORMAT"]
pass

@classmethod
def test_doc_format_url(cls):
Expand Down
2 changes: 1 addition & 1 deletion appbuilder/tests/test_image_understand.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from appbuilder.core.message import Message
from appbuilder.core._exception import AppBuilderServerException

@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_SERIAL", "")
@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
class TestImageUnderstand(unittest.TestCase):
def setUp(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion appbuilder/tests/test_ppt_generation_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skip("暂时跳过")
class TestPPTGenerationFromFileComponent(unittest.TestCase):
def setUp(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion appbuilder/tests/test_ppt_generation_from_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}


@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
@unittest.skip("暂时跳过")
class TestPPTGenerationComponent(unittest.TestCase):
def setUp(self):
"""
Expand Down
Loading