From d3c0d1956e5d50e0b21e810691397ae0ac3c9492 Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Mon, 8 Apr 2024 19:48:44 +0800 Subject: [PATCH 1/9] add ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c957d631743cab..9fd515790a5fed 100644 --- a/.gitignore +++ b/.gitignore @@ -156,3 +156,5 @@ sdks/python-client/dify_client.egg-info .vscode/* !.vscode/launch.json pyrightconfig.json +nohup.out +docker/volumes*/* From 9eed0481ead6aac2fc70588e64f27decff250e0d Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Tue, 9 Apr 2024 08:54:00 +0800 Subject: [PATCH 2/9] modify ignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9fd515790a5fed..c957d631743cab 100644 --- a/.gitignore +++ b/.gitignore @@ -156,5 +156,3 @@ sdks/python-client/dify_client.egg-info .vscode/* !.vscode/launch.json pyrightconfig.json -nohup.out -docker/volumes*/* From ddcb524d7528499e11681d7ecd91306a9428e4d5 Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Thu, 12 Sep 2024 22:36:01 +0800 Subject: [PATCH 3/9] support tts stream mode --- .../model_providers/xinference/tts/tts.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/core/model_runtime/model_providers/xinference/tts/tts.py b/api/core/model_runtime/model_providers/xinference/tts/tts.py index 10538b5788a3cc..81dbe397d2f10c 100644 --- a/api/core/model_runtime/model_providers/xinference/tts/tts.py +++ b/api/core/model_runtime/model_providers/xinference/tts/tts.py @@ -208,21 +208,21 @@ def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str executor = concurrent.futures.ThreadPoolExecutor(max_workers=min(3, len(sentences))) futures = [ executor.submit( - handle.speech, input=sentences[i], voice=voice, response_format="mp3", speed=1.0, stream=False + handle.speech, input=sentences[i], voice=voice, response_format="mp3", speed=1.0, stream=True ) for i in range(len(sentences)) ] for future in futures: response = future.result() - for i in range(0, len(response), 1024): - yield response[i : i + 1024] + for chunk in response: + yield chunk else: response = handle.speech( - input=content_text.strip(), voice=voice, response_format="mp3", speed=1.0, stream=False + input=content_text.strip(), voice=voice, response_format="mp3", speed=1.0, stream=True ) - for i in range(0, len(response), 1024): - yield response[i : i + 1024] + for chunk in response: + yield chunk except Exception as ex: raise InvokeBadRequestError(str(ex)) From d6a03d41c6b561f64ea0c4c77223910c53051241 Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 14 Sep 2024 22:47:17 +0800 Subject: [PATCH 4/9] update xinference-client to 0.15.1 --- api/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pyproject.toml b/api/pyproject.toml index 829c39a12bf91f..c55aa6d25dec17 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -203,7 +203,7 @@ transformers = "~4.35.0" unstructured = { version = "~0.10.27", extras = ["docx", "epub", "md", "msg", "ppt", "pptx"] } websocket-client = "~1.7.0" werkzeug = "~3.0.1" -xinference-client = "0.13.3" +xinference-client = "0.15.1" yarl = "~1.9.4" zhipuai = "1.0.7" # Before adding new dependency, consider place it in alphabet order (a-z) and suitable group. From 50fce4741bb40e34bff848f45e2ce15f067e9aa8 Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 14 Sep 2024 23:15:50 +0800 Subject: [PATCH 5/9] update xinference-client --- api/poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/poetry.lock b/api/poetry.lock index 8d4d680031a7c2..4026279a45b03e 100644 --- a/api/poetry.lock +++ b/api/poetry.lock @@ -10014,13 +10014,13 @@ h11 = ">=0.9.0,<1" [[package]] name = "xinference-client" -version = "0.13.3" +version = "0.15.1" description = "Client for Xinference" optional = false python-versions = "*" files = [ - {file = "xinference-client-0.13.3.tar.gz", hash = "sha256:822b722100affdff049c27760be7d62ac92de58c87a40d3361066df446ba648f"}, - {file = "xinference_client-0.13.3-py3-none-any.whl", hash = "sha256:f0eff3858b1ebcef2129726f82b09259c177e11db466a7ca23def3d4849c419f"}, + {file = "xinference-client-0.15.1.tar.gz", hash = "sha256:d839c6d66642f5e88c3a53fd88f8811c89b932276e75af895cbbbc7ce189cfe9"}, + {file = "xinference_client-0.15.1-py3-none-any.whl", hash = "sha256:d09b10fb80a79124b55fde789097ff55558037cac7f4c0d1b9c77003645cfe34"}, ] [package.dependencies] From 2b1fc7a2188f52f2b1be122242b69c1ff16f79fe Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 21 Sep 2024 22:36:33 +0800 Subject: [PATCH 6/9] update xinference-client version --- api/poetry.lock | 8 ++++---- api/pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/poetry.lock b/api/poetry.lock index 4026279a45b03e..e532394a24e741 100644 --- a/api/poetry.lock +++ b/api/poetry.lock @@ -10014,13 +10014,13 @@ h11 = ">=0.9.0,<1" [[package]] name = "xinference-client" -version = "0.15.1" +version = "0.15.2" description = "Client for Xinference" optional = false python-versions = "*" files = [ - {file = "xinference-client-0.15.1.tar.gz", hash = "sha256:d839c6d66642f5e88c3a53fd88f8811c89b932276e75af895cbbbc7ce189cfe9"}, - {file = "xinference_client-0.15.1-py3-none-any.whl", hash = "sha256:d09b10fb80a79124b55fde789097ff55558037cac7f4c0d1b9c77003645cfe34"}, + {file = "xinference-client-0.15.2.tar.gz", hash = "sha256:5c2259bb133148d1cc9bd2b8ec6eb8b5bbeba7f11d6252959f4e6cd79baa53ed"}, + {file = "xinference_client-0.15.2-py3-none-any.whl", hash = "sha256:b6275adab695e75e75a33e21e0ad212488fc2d5a4d0f693d544c0e78469abbe3"}, ] [package.dependencies] @@ -10422,4 +10422,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "18924ae12a00bde4438a46168bc167ed69613ab1ab0c387f193cd47ac24379b2" +content-hash = "85aa4be7defee8fe6622cf95ba03e81895121502ebf6d666d6ce376ff019fac7" diff --git a/api/pyproject.toml b/api/pyproject.toml index c55aa6d25dec17..1f483fc49f0326 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -203,7 +203,7 @@ transformers = "~4.35.0" unstructured = { version = "~0.10.27", extras = ["docx", "epub", "md", "msg", "ppt", "pptx"] } websocket-client = "~1.7.0" werkzeug = "~3.0.1" -xinference-client = "0.15.1" +xinference-client = "0.15.2" yarl = "~1.9.4" zhipuai = "1.0.7" # Before adding new dependency, consider place it in alphabet order (a-z) and suitable group. From 8fd70679a0a4bcba43d5d7a976075395905b211b Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 21 Sep 2024 22:54:23 +0800 Subject: [PATCH 7/9] remove deprecate feature --- api/core/model_runtime/model_providers/xinference/llm/llm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/core/model_runtime/model_providers/xinference/llm/llm.py b/api/core/model_runtime/model_providers/xinference/llm/llm.py index 4fadda5df5d855..6c0aa8e2d9640e 100644 --- a/api/core/model_runtime/model_providers/xinference/llm/llm.py +++ b/api/core/model_runtime/model_providers/xinference/llm/llm.py @@ -19,7 +19,6 @@ from openai.types.completion import Completion from xinference_client.client.restful.restful_client import ( Client, - RESTfulChatglmCppChatModelHandle, RESTfulChatModelHandle, RESTfulGenerateModelHandle, ) From a3b61b7c0b76c493427eb3a7a90a20717b13dd4d Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 21 Sep 2024 23:15:47 +0800 Subject: [PATCH 8/9] fix ci --- api/core/model_runtime/model_providers/xinference/llm/llm.py | 2 +- api/tests/integration_tests/model_runtime/__mock/xinference.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api/core/model_runtime/model_providers/xinference/llm/llm.py b/api/core/model_runtime/model_providers/xinference/llm/llm.py index 6c0aa8e2d9640e..286640079b02a9 100644 --- a/api/core/model_runtime/model_providers/xinference/llm/llm.py +++ b/api/core/model_runtime/model_providers/xinference/llm/llm.py @@ -490,7 +490,7 @@ def _generate( if tools and len(tools) > 0: generate_config["tools"] = [{"type": "function", "function": helper.dump_model(tool)} for tool in tools] vision = credentials.get("support_vision", False) - if isinstance(xinference_model, RESTfulChatModelHandle | RESTfulChatglmCppChatModelHandle): + if isinstance(xinference_model, RESTfulChatModelHandle): resp = client.chat.completions.create( model=credentials["model_uid"], messages=[self._convert_prompt_message_to_dict(message) for message in prompt_messages], diff --git a/api/tests/integration_tests/model_runtime/__mock/xinference.py b/api/tests/integration_tests/model_runtime/__mock/xinference.py index 299523f4f5b7c2..d22794c0d61ec5 100644 --- a/api/tests/integration_tests/model_runtime/__mock/xinference.py +++ b/api/tests/integration_tests/model_runtime/__mock/xinference.py @@ -9,7 +9,6 @@ from requests.sessions import Session from xinference_client.client.restful.restful_client import ( Client, - RESTfulChatglmCppChatModelHandle, RESTfulChatModelHandle, RESTfulEmbeddingModelHandle, RESTfulGenerateModelHandle, @@ -21,7 +20,7 @@ class MockXinferenceClass: def get_chat_model( self: Client, model_uid: str - ) -> Union[RESTfulChatglmCppChatModelHandle, RESTfulGenerateModelHandle, RESTfulChatModelHandle]: + ) -> Union[RESTfulGenerateModelHandle, RESTfulChatModelHandle]: if not re.match(r"https?:\/\/[^\s\/$.?#].[^\s]*$", self.base_url): raise RuntimeError("404 Not Found") From be21228e74e190fafcc8a2635c45dcc88e40049f Mon Sep 17 00:00:00 2001 From: leslie2046 <253605712@qq.com> Date: Sat, 21 Sep 2024 23:19:53 +0800 Subject: [PATCH 9/9] fix ruff --- .../integration_tests/model_runtime/__mock/xinference.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/tests/integration_tests/model_runtime/__mock/xinference.py b/api/tests/integration_tests/model_runtime/__mock/xinference.py index d22794c0d61ec5..8deb50635f3d56 100644 --- a/api/tests/integration_tests/model_runtime/__mock/xinference.py +++ b/api/tests/integration_tests/model_runtime/__mock/xinference.py @@ -18,9 +18,7 @@ class MockXinferenceClass: - def get_chat_model( - self: Client, model_uid: str - ) -> Union[RESTfulGenerateModelHandle, RESTfulChatModelHandle]: + def get_chat_model(self: Client, model_uid: str) -> Union[RESTfulGenerateModelHandle, RESTfulChatModelHandle]: if not re.match(r"https?:\/\/[^\s\/$.?#].[^\s]*$", self.base_url): raise RuntimeError("404 Not Found")