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

feat:use xinference tts stream mode #8616

Merged
merged 122 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
d3c0d19
add ignore
leslie2046 Apr 8, 2024
6ff72ac
Merge branch 'main' of https://github.com/leslie2046/dify into main
leslie2046 Apr 8, 2024
ee7df7a
Merge branch 'langgenius:main' into main
leslie2046 Apr 9, 2024
9eed048
modify ignore
leslie2046 Apr 9, 2024
abf9e37
Merge branch 'langgenius:main' into main
leslie2046 Apr 9, 2024
635a203
Merge branch 'langgenius:main' into main
leslie2046 Apr 9, 2024
555e56a
Merge branch 'langgenius:main' into main
leslie2046 Apr 10, 2024
9efda0a
Merge branch 'langgenius:main' into main
leslie2046 Apr 10, 2024
2083fc3
Merge branch 'langgenius:main' into main
leslie2046 Apr 10, 2024
7a8873d
Merge branch 'langgenius:main' into main
leslie2046 Apr 10, 2024
eb7bbff
Merge branch 'langgenius:main' into main
leslie2046 Apr 11, 2024
01e8ca2
Merge branch 'langgenius:main' into main
leslie2046 Apr 11, 2024
c6cfb7b
Merge branch 'langgenius:main' into main
leslie2046 Apr 11, 2024
61dd836
Merge branch 'langgenius:main' into main
leslie2046 Apr 12, 2024
0f4685a
Merge branch 'langgenius:main' into main
leslie2046 Apr 14, 2024
2731299
Merge branch 'langgenius:main' into main
leslie2046 Apr 16, 2024
b513209
Merge branch 'langgenius:main' into main
leslie2046 Apr 17, 2024
8684808
Merge branch 'langgenius:main' into main
leslie2046 Apr 17, 2024
2b0dbdf
Merge branch 'langgenius:main' into main
leslie2046 Apr 18, 2024
3f81e50
Merge branch 'langgenius:main' into main
leslie2046 Apr 18, 2024
80dbef1
Merge branch 'langgenius:main' into main
leslie2046 Apr 18, 2024
10ba37d
Merge branch 'langgenius:main' into main
leslie2046 Apr 18, 2024
2f09b7f
Merge branch 'langgenius:main' into main
leslie2046 Apr 19, 2024
1d8e4bb
Merge branch 'langgenius:main' into main
leslie2046 Apr 19, 2024
1751420
Merge branch 'langgenius:main' into main
leslie2046 Apr 19, 2024
7f8cbcc
Merge branch 'langgenius:main' into main
leslie2046 Apr 19, 2024
7b27500
Merge branch 'langgenius:main' into main
leslie2046 Apr 20, 2024
dda32fc
Merge branch 'langgenius:main' into main
leslie2046 Apr 21, 2024
5a56fcd
Merge branch 'langgenius:main' into main
leslie2046 Apr 22, 2024
f6a4473
Merge branch 'langgenius:main' into main
leslie2046 Apr 22, 2024
220449a
Merge branch 'langgenius:main' into main
leslie2046 Apr 22, 2024
c0d2acc
Merge branch 'langgenius:main' into main
leslie2046 Apr 23, 2024
1f7b745
Merge branch 'langgenius:main' into main
leslie2046 Apr 24, 2024
23a36fb
Merge branch 'langgenius:main' into main
leslie2046 Apr 24, 2024
5f16609
Merge branch 'langgenius:main' into main
leslie2046 Apr 24, 2024
dd27778
Merge branch 'langgenius:main' into main
leslie2046 Apr 24, 2024
e2a2162
Merge branch 'langgenius:main' into main
leslie2046 Apr 24, 2024
c716a26
Merge branch 'langgenius:main' into main
leslie2046 Apr 25, 2024
1238c5b
Merge branch 'langgenius:main' into main
leslie2046 Apr 25, 2024
db1e462
Merge branch 'langgenius:main' into main
leslie2046 Apr 25, 2024
9a837e0
Merge branch 'langgenius:main' into main
leslie2046 Apr 26, 2024
ebe3cc2
Merge branch 'langgenius:main' into main
leslie2046 Apr 26, 2024
c1c5c99
Merge branch 'langgenius:main' into main
leslie2046 Apr 27, 2024
31a7fe7
Merge branch 'langgenius:main' into main
leslie2046 Apr 27, 2024
1ca9684
Merge branch 'langgenius:main' into main
leslie2046 Apr 28, 2024
3540b4c
Merge branch 'langgenius:main' into main
leslie2046 Apr 28, 2024
3c1994e
Merge branch 'langgenius:main' into main
leslie2046 Apr 28, 2024
48ba5b1
Merge branch 'langgenius:main' into main
leslie2046 Apr 28, 2024
c25d30b
Merge branch 'langgenius:main' into main
leslie2046 Apr 29, 2024
73cb8f3
Merge branch 'langgenius:main' into main
leslie2046 Apr 29, 2024
0ecdb58
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
6c4b304
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
62ae80f
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
ba6c0cf
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
6f8af62
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
5f686d0
Merge branch 'langgenius:main' into main
leslie2046 Apr 30, 2024
9efca0e
Merge branch 'langgenius:main' into main
leslie2046 May 2, 2024
5e3562c
Merge branch 'langgenius:main' into main
leslie2046 May 6, 2024
258a752
Merge branch 'langgenius:main' into main
leslie2046 May 6, 2024
c6df700
Merge branch 'langgenius:main' into main
leslie2046 May 8, 2024
2b9c211
Merge branch 'langgenius:main' into main
leslie2046 May 9, 2024
1dd42e5
Merge branch 'langgenius:main' into main
leslie2046 May 9, 2024
5949e6c
Merge branch 'langgenius:main' into main
leslie2046 May 9, 2024
4077e39
Merge branch 'langgenius:main' into main
leslie2046 May 11, 2024
e7def60
Merge branch 'langgenius:main' into main
leslie2046 May 11, 2024
8c10bec
Merge branch 'langgenius:main' into main
leslie2046 May 13, 2024
e7cd1bf
Merge branch 'langgenius:main' into main
leslie2046 May 14, 2024
237ccca
Merge branch 'langgenius:main' into main
leslie2046 May 16, 2024
d7ad2ee
Merge branch 'langgenius:main' into main
leslie2046 May 17, 2024
a254ac2
Merge branch 'langgenius:main' into main
leslie2046 May 21, 2024
3182f68
Merge branch 'langgenius:main' into main
leslie2046 May 22, 2024
efff7b3
Merge branch 'langgenius:main' into main
leslie2046 May 23, 2024
d843c8c
Merge branch 'langgenius:main' into main
leslie2046 May 24, 2024
f2744a5
Merge branch 'langgenius:main' into main
leslie2046 May 24, 2024
c5210a8
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 27, 2024
ee15a02
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 27, 2024
720254b
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 28, 2024
d89a3b6
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 28, 2024
e3e0538
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 28, 2024
043c6de
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 28, 2024
068ac4c
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 May 31, 2024
a383118
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 5, 2024
eb246cd
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 13, 2024
4f7cde6
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 15, 2024
4dea264
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 24, 2024
018b360
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 28, 2024
4e583ff
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 29, 2024
6552fe7
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 29, 2024
3b8269c
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jun 29, 2024
125bfa8
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jul 2, 2024
035e873
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jul 3, 2024
8c72e39
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jul 12, 2024
8544d5a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jul 15, 2024
31f8d48
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Jul 20, 2024
a8a230a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 1, 2024
26dd042
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 1, 2024
9ec5f5a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 1, 2024
d812bc9
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 1, 2024
fc93503
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 1, 2024
dcbfed9
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 6, 2024
a05854c
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 19, 2024
9fb098a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 20, 2024
5ac21d7
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 22, 2024
28b8a02
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 22, 2024
6d3d10a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 23, 2024
7c834dc
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 24, 2024
5f26afc
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Aug 26, 2024
30132be
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 3, 2024
d088c6b
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 4, 2024
47ca9fb
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 4, 2024
7cee29a
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 4, 2024
e9e7fda
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 5, 2024
ab853b2
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 14, 2024
53578fb
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 21, 2024
00962c8
Merge branch 'main' of https://github.com/leslie2046/dify
leslie2046 Sep 22, 2024
ddcb524
support tts stream mode
leslie2046 Sep 12, 2024
d6a03d4
update xinference-client to 0.15.1
leslie2046 Sep 14, 2024
50fce47
update xinference-client
leslie2046 Sep 14, 2024
2b1fc7a
update xinference-client version
leslie2046 Sep 21, 2024
8fd7067
remove deprecate feature
leslie2046 Sep 21, 2024
a3b61b7
fix ci
leslie2046 Sep 21, 2024
be21228
fix ruff
leslie2046 Sep 21, 2024
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
3 changes: 1 addition & 2 deletions api/core/model_runtime/model_providers/xinference/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from openai.types.completion import Completion
from xinference_client.client.restful.restful_client import (
Client,
RESTfulChatglmCppChatModelHandle,
RESTfulChatModelHandle,
RESTfulGenerateModelHandle,
)
Expand Down Expand Up @@ -491,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],
Expand Down
12 changes: 6 additions & 6 deletions api/core/model_runtime/model_providers/xinference/tts/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
8 changes: 4 additions & 4 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2"
yarl = "~1.9.4"
zhipuai = "1.0.7"
# Before adding new dependency, consider place it in alphabet order (a-z) and suitable group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from requests.sessions import Session
from xinference_client.client.restful.restful_client import (
Client,
RESTfulChatglmCppChatModelHandle,
RESTfulChatModelHandle,
RESTfulEmbeddingModelHandle,
RESTfulGenerateModelHandle,
Expand All @@ -19,9 +18,7 @@


class MockXinferenceClass:
def get_chat_model(
self: Client, model_uid: str
) -> Union[RESTfulChatglmCppChatModelHandle, 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")

Expand Down