lollms-client 1.4.5__tar.gz → 1.4.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lollms-client might be problematic. Click here for more details.
- {lollms_client-1.4.5/src/lollms_client.egg-info → lollms_client-1.4.7}/PKG-INFO +204 -2
- {lollms_client-1.4.5 → lollms_client-1.4.7}/pyproject.toml +3 -2
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/__init__.py +1 -1
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_discussion.py +11 -1
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_personality.py +5 -2
- lollms_client-1.4.7/src/lollms_client/ttm_bindings/beatoven_ai/__init__.py +125 -0
- lollms_client-1.4.7/src/lollms_client/ttm_bindings/replicate/__init__.py +112 -0
- lollms_client-1.4.7/src/lollms_client/ttm_bindings/stability_ai/__init__.py +114 -0
- lollms_client-1.4.7/src/lollms_client/ttm_bindings/topmediai/__init__.py +93 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7/src/lollms_client.egg-info}/PKG-INFO +204 -2
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client.egg-info/SOURCES.txt +4 -1
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client.egg-info/requires.txt +1 -0
- lollms_client-1.4.5/src/lollms_client/ttm_bindings/bark/__init__.py +0 -339
- {lollms_client-1.4.5 → lollms_client-1.4.7}/LICENSE +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/README.md +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/setup.cfg +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/assets/models_ctx_sizes.json +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/azure_openai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/claude/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/gemini/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/grok/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/groq/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/hugging_face_inference_api/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/litellm/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/llamacpp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/lollms_webui/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/mistral/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/novita_ai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/ollama/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/open_router/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/openai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/openllm/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/perplexity/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/pythonllamacpp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/tensor_rt/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/transformers/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/llm_bindings/vllm/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_agentic.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_config.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_core.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_js_analyzer.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_llm_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_mcp_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_mcp_security.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_python_analyzer.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_stt_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_tti_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_ttm_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_tts_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_ttv_binding.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_types.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/lollms_utilities.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/local_mcp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/local_mcp/default_tools/file_writer/file_writer.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/local_mcp/default_tools/generate_image_from_prompt/generate_image_from_prompt.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/local_mcp/default_tools/internet_search/internet_search.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/local_mcp/default_tools/python_interpreter/python_interpreter.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/remote_mcp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/mcp_bindings/standard_mcp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/stt_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/stt_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/stt_bindings/whisper/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/stt_bindings/whispercpp/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/diffusers/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/gemini/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/leonardo_ai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/novita_ai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/openai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tti_bindings/stability_ai/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/ttm_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/ttm_bindings/audiocraft/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/ttm_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/bark/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/bark/server/install_bark.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/bark/server/main.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/piper_tts/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/piper_tts/server/install_piper.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/piper_tts/server/main.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/piper_tts/server/setup_voices.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/xtts/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/xtts/server/main.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/tts_bindings/xtts/server/setup_voices.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/ttv_bindings/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client/ttv_bindings/lollms/__init__.py +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client.egg-info/dependency_links.txt +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/src/lollms_client.egg-info/top_level.txt +0 -0
- {lollms_client-1.4.5 → lollms_client-1.4.7}/test/test_lollms_discussion.py +0 -0
|
@@ -1,9 +1,210 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lollms_client
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.7
|
|
4
4
|
Summary: A client library for LoLLMs generate endpoint
|
|
5
5
|
Author-email: ParisNeo <parisneoai@gmail.com>
|
|
6
|
-
License:
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
184
|
+
|
|
185
|
+
To apply the Apache License to your work, attach the following
|
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
187
|
+
replaced with your own identifying information. (Don't include
|
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
189
|
+
comment syntax for the file format. We also recommend that a
|
|
190
|
+
file or class name and description of purpose be included on the
|
|
191
|
+
same "printed page" as the copyright notice for easier
|
|
192
|
+
identification within third-party archives.
|
|
193
|
+
|
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
|
195
|
+
|
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
+
you may not use this file except in compliance with the License.
|
|
198
|
+
You may obtain a copy of the License at
|
|
199
|
+
|
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
+
|
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
+
See the License for the specific language governing permissions and
|
|
206
|
+
limitations under the License.
|
|
207
|
+
|
|
7
208
|
Project-URL: Homepage, https://github.com/ParisNeo/lollms_client
|
|
8
209
|
Classifier: Programming Language :: Python :: 3
|
|
9
210
|
Classifier: Programming Language :: Python :: 3.8
|
|
@@ -18,6 +219,7 @@ Classifier: Intended Audience :: Science/Research
|
|
|
18
219
|
Requires-Python: >=3.7
|
|
19
220
|
Description-Content-Type: text/markdown
|
|
20
221
|
License-File: LICENSE
|
|
222
|
+
Requires-Dist: httpx
|
|
21
223
|
Requires-Dist: requests
|
|
22
224
|
Requires-Dist: ascii-colors
|
|
23
225
|
Requires-Dist: pipmaster
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=80.9", "wheel"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
# REMOVE THE LINE BELOW:
|
|
5
5
|
# backend-path = ["."]
|
|
@@ -13,7 +13,7 @@ authors = [
|
|
|
13
13
|
description = "A client library for LoLLMs generate endpoint"
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
requires-python = ">=3.7"
|
|
16
|
-
license = {
|
|
16
|
+
license = { file = "LICENSE" }
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Programming Language :: Python :: 3",
|
|
19
19
|
"Programming Language :: Python :: 3.8",
|
|
@@ -27,6 +27,7 @@ classifiers = [
|
|
|
27
27
|
"Intended Audience :: Science/Research",
|
|
28
28
|
]
|
|
29
29
|
dependencies = [
|
|
30
|
+
"httpx",
|
|
30
31
|
"requests",
|
|
31
32
|
"ascii-colors",
|
|
32
33
|
"pipmaster",
|
|
@@ -8,7 +8,7 @@ from lollms_client.lollms_utilities import PromptReshaper # Keep general utiliti
|
|
|
8
8
|
from lollms_client.lollms_mcp_binding import LollmsMCPBinding, LollmsMCPBindingManager
|
|
9
9
|
from lollms_client.lollms_llm_binding import LollmsLLMBindingManager
|
|
10
10
|
|
|
11
|
-
__version__ = "1.4.
|
|
11
|
+
__version__ = "1.4.7" # Updated version
|
|
12
12
|
|
|
13
13
|
# Optionally, you could define __all__ if you want to be explicit about exports
|
|
14
14
|
__all__ = [
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
#lollms_client/lollms_discussion.py
|
|
2
|
+
#author : ParisNeo
|
|
3
|
+
|
|
1
4
|
import base64
|
|
2
5
|
import json
|
|
3
6
|
import re
|
|
@@ -1000,6 +1003,13 @@ class LollmsDiscussion:
|
|
|
1000
1003
|
self._rebuild_message_index() # Ensure index is fresh
|
|
1001
1004
|
return [LollmsMessage(self, msg_obj) for msg_obj in self._message_index.values()]
|
|
1002
1005
|
|
|
1006
|
+
def setMemory(self, memory:str):
|
|
1007
|
+
"""sets memory content
|
|
1008
|
+
|
|
1009
|
+
Args:
|
|
1010
|
+
memory (str): _description_
|
|
1011
|
+
"""
|
|
1012
|
+
self.memory = memory
|
|
1003
1013
|
|
|
1004
1014
|
def get_full_data_zone(self):
|
|
1005
1015
|
"""Assembles all data zones into a single, formatted string for the prompt."""
|
|
@@ -2585,4 +2595,4 @@ class LollmsDiscussion:
|
|
|
2585
2595
|
if db_manager:
|
|
2586
2596
|
new_discussion.commit()
|
|
2587
2597
|
|
|
2588
|
-
return new_discussion
|
|
2598
|
+
return new_discussion
|
|
@@ -84,7 +84,10 @@ class LollmsPersonality:
|
|
|
84
84
|
"""
|
|
85
85
|
Creates a filesystem-safe, unique ID based on the author and name.
|
|
86
86
|
"""
|
|
87
|
-
|
|
87
|
+
if self.author:
|
|
88
|
+
safe_author = "".join(c if c.isalnum() else '_' for c in self.author)
|
|
89
|
+
else:
|
|
90
|
+
safe_author = "".join(c if c.isalnum() else '_' for c in "ParisNeo")
|
|
88
91
|
safe_name = "".join(c if c.isalnum() else '_' for c in self.name)
|
|
89
92
|
return f"{safe_author}_{safe_name}"
|
|
90
93
|
|
|
@@ -187,4 +190,4 @@ class LollmsPersonality:
|
|
|
187
190
|
"has_data_source": self.data_source is not None,
|
|
188
191
|
"data_files": [str(p) for p in self.data_files],
|
|
189
192
|
"has_script": self.script is not None
|
|
190
|
-
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import time
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional, List, Dict, Any
|
|
6
|
+
|
|
7
|
+
from lollms_client.lollms_ttm_binding import LollmsTTMBinding
|
|
8
|
+
from ascii_colors import trace_exception, ASCIIColors
|
|
9
|
+
import pipmaster as pm
|
|
10
|
+
|
|
11
|
+
# Ensure required packages are installed
|
|
12
|
+
pm.ensure_packages(["requests"])
|
|
13
|
+
|
|
14
|
+
BindingName = "BeatovenAITTMBinding"
|
|
15
|
+
|
|
16
|
+
class BeatovenAITTMBinding(LollmsTTMBinding):
|
|
17
|
+
"""A Text-to-Music binding for the Beatoven.ai API."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, **kwargs):
|
|
20
|
+
super().__init__(binding_name=BindingName, **kwargs)
|
|
21
|
+
self.api_key = self.settings.get("api_key") or os.environ.get("BEATOVEN_API_KEY")
|
|
22
|
+
if not self.api_key:
|
|
23
|
+
raise ValueError("Beatoven.ai API key is required. Please set it in config or as BEATOVEN_API_KEY env var.")
|
|
24
|
+
self.base_url = "https://api.beatoven.ai/api/v1"
|
|
25
|
+
self.headers = {"Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json"}
|
|
26
|
+
|
|
27
|
+
def list_models(self, **kwargs) -> List[str]:
|
|
28
|
+
# Beatoven.ai does not expose different models via the API.
|
|
29
|
+
# Customization is done via genre, mood, and tempo.
|
|
30
|
+
return ["default"]
|
|
31
|
+
|
|
32
|
+
def _poll_for_completion(self, task_id: str) -> Dict[str, Any]:
|
|
33
|
+
"""Polls the tasks endpoint until the composition is complete."""
|
|
34
|
+
poll_url = f"{self.base_url}/tasks/{task_id}"
|
|
35
|
+
while True:
|
|
36
|
+
try:
|
|
37
|
+
response = requests.get(poll_url, headers=self.headers)
|
|
38
|
+
response.raise_for_status()
|
|
39
|
+
data = response.json()
|
|
40
|
+
status = data.get("status")
|
|
41
|
+
|
|
42
|
+
if status == "success":
|
|
43
|
+
ASCIIColors.green("Composition task successful.")
|
|
44
|
+
return data
|
|
45
|
+
elif status == "failed":
|
|
46
|
+
error_info = data.get("error", "Unknown error.")
|
|
47
|
+
raise Exception(f"Beatoven.ai task failed: {error_info}")
|
|
48
|
+
else:
|
|
49
|
+
ASCIIColors.info(f"Task status is '{status}'. Waiting...")
|
|
50
|
+
time.sleep(5)
|
|
51
|
+
except requests.exceptions.HTTPError as e:
|
|
52
|
+
raise Exception(f"Failed to poll task status: {e.response.text}")
|
|
53
|
+
|
|
54
|
+
def generate_music(self, prompt: str, **kwargs) -> bytes:
|
|
55
|
+
"""
|
|
56
|
+
Generates music by creating a track, waiting for composition, and downloading the result.
|
|
57
|
+
"""
|
|
58
|
+
# Step 1: Create a track
|
|
59
|
+
create_track_url = f"{self.base_url}/tracks"
|
|
60
|
+
payload = {
|
|
61
|
+
"title": prompt[:100], # Use prompt as title, truncated
|
|
62
|
+
"duration_in_seconds": kwargs.get("duration", 30),
|
|
63
|
+
"genre": kwargs.get("genre", "Cinematic"),
|
|
64
|
+
"tempo": kwargs.get("tempo", "medium"),
|
|
65
|
+
"prompt": prompt
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
ASCIIColors.info("Submitting music track request to Beatoven.ai...")
|
|
70
|
+
create_response = requests.post(create_track_url, json=payload, headers=self.headers)
|
|
71
|
+
create_response.raise_for_status()
|
|
72
|
+
task_id = create_response.json().get("task_id")
|
|
73
|
+
ASCIIColors.info(f"Track creation submitted. Task ID: {task_id}")
|
|
74
|
+
|
|
75
|
+
# Step 2: Poll for task completion
|
|
76
|
+
task_result = self._poll_for_completion(task_id)
|
|
77
|
+
track_id = task_result.get("track_id")
|
|
78
|
+
if not track_id:
|
|
79
|
+
raise Exception("Task completed but did not return a track_id.")
|
|
80
|
+
|
|
81
|
+
# Step 3: Get track details to find the audio URL
|
|
82
|
+
track_url = f"{self.base_url}/tracks/{track_id}"
|
|
83
|
+
track_response = requests.get(track_url, headers=self.headers)
|
|
84
|
+
track_response.raise_for_status()
|
|
85
|
+
|
|
86
|
+
audio_url = track_response.json().get("renders", {}).get("wav")
|
|
87
|
+
if not audio_url:
|
|
88
|
+
raise Exception("Could not find WAV render URL in the completed track details.")
|
|
89
|
+
|
|
90
|
+
# Step 4: Download the audio file
|
|
91
|
+
ASCIIColors.info(f"Downloading generated audio from {audio_url}")
|
|
92
|
+
audio_response = requests.get(audio_url)
|
|
93
|
+
audio_response.raise_for_status()
|
|
94
|
+
|
|
95
|
+
return audio_response.content
|
|
96
|
+
|
|
97
|
+
except requests.exceptions.HTTPError as e:
|
|
98
|
+
error_details = e.response.json()
|
|
99
|
+
raise Exception(f"Beatoven.ai API HTTP Error: {error_details}") from e
|
|
100
|
+
except Exception as e:
|
|
101
|
+
trace_exception(e)
|
|
102
|
+
raise
|
|
103
|
+
|
|
104
|
+
if __name__ == '__main__':
|
|
105
|
+
ASCIIColors.magenta("--- Beatoven.ai TTM Binding Test ---")
|
|
106
|
+
if "BEATOVEN_API_KEY" not in os.environ:
|
|
107
|
+
ASCIIColors.error("BEATOVEN_API_KEY environment variable not set. Cannot run test.")
|
|
108
|
+
exit(1)
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
binding = BeatovenAITTMBinding()
|
|
112
|
+
|
|
113
|
+
ASCIIColors.cyan("\n--- Test: Music Generation ---")
|
|
114
|
+
prompt = "A mysterious and suspenseful cinematic track with soft piano and eerie strings, building tension."
|
|
115
|
+
music_bytes = binding.generate_music(prompt, duration=45, genre="Cinematic", tempo="slow")
|
|
116
|
+
|
|
117
|
+
assert len(music_bytes) > 1000, "Generated music bytes are too small."
|
|
118
|
+
output_path = Path(__file__).parent / "tmp_beatoven_music.wav"
|
|
119
|
+
with open(output_path, "wb") as f:
|
|
120
|
+
f.write(music_bytes)
|
|
121
|
+
ASCIIColors.green(f"Music generation OK. Audio saved to {output_path}")
|
|
122
|
+
|
|
123
|
+
except Exception as e:
|
|
124
|
+
trace_exception(e)
|
|
125
|
+
ASCIIColors.error(f"Beatoven.ai TTM binding test failed: {e}")
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import base64
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional, List, Dict, Any
|
|
6
|
+
|
|
7
|
+
from lollms_client.lollms_ttm_binding import LollmsTTMBinding
|
|
8
|
+
from ascii_colors import trace_exception, ASCIIColors
|
|
9
|
+
import pipmaster as pm
|
|
10
|
+
|
|
11
|
+
# Ensure required packages are installed
|
|
12
|
+
pm.ensure_packages(["requests"])
|
|
13
|
+
|
|
14
|
+
BindingName = "StabilityAITTMBinding"
|
|
15
|
+
|
|
16
|
+
# Models available via the Stability AI Audio API
|
|
17
|
+
# Sourced from: https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v1~1generation~1stable-audio-2.0~1text-to-audio/post
|
|
18
|
+
STABILITY_AI_MODELS = [
|
|
19
|
+
{"model_name": "stable-audio-2.0", "display_name": "Stable Audio 2.0", "description": "High-quality, full-track music generation up to 3 minutes."},
|
|
20
|
+
{"model_name": "stable-audio-1.0", "display_name": "Stable Audio 1.0", "description": "Original model, best for short clips and sound effects."},
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
class StabilityAITTMBinding(LollmsTTMBinding):
|
|
24
|
+
"""A Text-to-Music binding for Stability AI's Stable Audio API."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, **kwargs):
|
|
27
|
+
super().__init__(binding_name=BindingName, **kwargs)
|
|
28
|
+
self.api_key = self.settings.get("api_key") or os.environ.get("STABILITY_API_KEY")
|
|
29
|
+
if not self.api_key:
|
|
30
|
+
raise ValueError("Stability AI API key is required. Please set it in the configuration or as STABILITY_API_KEY environment variable.")
|
|
31
|
+
self.model_name = self.settings.get("model_name", "stable-audio-2.0")
|
|
32
|
+
|
|
33
|
+
def list_models(self, **kwargs) -> List[Dict[str, str]]:
|
|
34
|
+
return STABILITY_AI_MODELS
|
|
35
|
+
|
|
36
|
+
def generate_music(self, prompt: str, **kwargs) -> bytes:
|
|
37
|
+
"""
|
|
38
|
+
Generates music using the Stable Audio API.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
prompt (str): The text prompt describing the desired music.
|
|
42
|
+
duration (int): The duration of the audio in seconds. Defaults to 29.
|
|
43
|
+
**kwargs: Additional parameters for the API.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
bytes: The generated audio data in WAV format.
|
|
47
|
+
"""
|
|
48
|
+
url = f"https://api.stability.ai/v1/generation/{self.model_name}/text-to-audio"
|
|
49
|
+
headers = {
|
|
50
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
51
|
+
"Accept": "audio/wav",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Get duration, with a default of 29 seconds as it's a common value
|
|
55
|
+
duration = kwargs.get("duration", 29)
|
|
56
|
+
|
|
57
|
+
payload = {
|
|
58
|
+
"text_prompts[0][text]": prompt,
|
|
59
|
+
"text_prompts[0][weight]": 1.0,
|
|
60
|
+
"seed": kwargs.get("seed", 0), # 0 for random in API
|
|
61
|
+
"steps": kwargs.get("steps", 100),
|
|
62
|
+
"cfg_scale": kwargs.get("cfg_scale", 7.0),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Handle different parameter names for duration
|
|
66
|
+
if self.model_name == "stable-audio-2.0":
|
|
67
|
+
payload["duration"] = duration
|
|
68
|
+
else: # stable-audio-1.0
|
|
69
|
+
payload["sample_length"] = duration * 44100 # v1 uses sample length
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
ASCIIColors.info(f"Requesting music from Stability AI ({self.model_name})...")
|
|
73
|
+
response = requests.post(url, headers=headers, data=payload)
|
|
74
|
+
response.raise_for_status()
|
|
75
|
+
|
|
76
|
+
ASCIIColors.green("Successfully generated music from Stability AI.")
|
|
77
|
+
return response.content
|
|
78
|
+
except requests.exceptions.HTTPError as e:
|
|
79
|
+
try:
|
|
80
|
+
error_details = e.response.json()
|
|
81
|
+
error_message = error_details.get("message", e.response.text)
|
|
82
|
+
except:
|
|
83
|
+
error_message = e.response.text
|
|
84
|
+
ASCIIColors.error(f"HTTP Error from Stability AI: {e.response.status_code} - {error_message}")
|
|
85
|
+
raise Exception(f"Stability AI API Error: {error_message}") from e
|
|
86
|
+
except Exception as e:
|
|
87
|
+
trace_exception(e)
|
|
88
|
+
raise Exception(f"An unexpected error occurred: {e}")
|
|
89
|
+
|
|
90
|
+
if __name__ == '__main__':
|
|
91
|
+
ASCIIColors.magenta("--- Stability AI TTM Binding Test ---")
|
|
92
|
+
if "STABILITY_API_KEY" not in os.environ:
|
|
93
|
+
ASCIIColors.error("STABILITY_API_KEY environment variable not set. Cannot run test.")
|
|
94
|
+
exit(1)
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
# Test with default settings
|
|
98
|
+
binding = StabilityAITTMBinding()
|
|
99
|
+
|
|
100
|
+
ASCIIColors.cyan("\n--- Test: Music Generation ---")
|
|
101
|
+
prompt = "80s synthwave, retro futuristic, driving beat, cinematic"
|
|
102
|
+
music_bytes = binding.generate_music(prompt, duration=10)
|
|
103
|
+
|
|
104
|
+
assert len(music_bytes) > 1000, "Generated music bytes are too small."
|
|
105
|
+
output_path = Path(__file__).parent / "tmp_stability_music.wav"
|
|
106
|
+
with open(output_path, "wb") as f:
|
|
107
|
+
f.write(music_bytes)
|
|
108
|
+
ASCIIColors.green(f"Music generation OK. Audio saved to {output_path}")
|
|
109
|
+
|
|
110
|
+
except Exception as e:
|
|
111
|
+
trace_exception(e)
|
|
112
|
+
ASCIIColors.error(f"Stability AI TTM binding test failed: {e}")
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import time
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional, List, Dict, Any
|
|
6
|
+
|
|
7
|
+
from lollms_client.lollms_ttm_binding import LollmsTTMBinding
|
|
8
|
+
from ascii_colors import trace_exception, ASCIIColors
|
|
9
|
+
import pipmaster as pm
|
|
10
|
+
|
|
11
|
+
# Ensure required packages are installed
|
|
12
|
+
pm.ensure_packages(["requests"])
|
|
13
|
+
|
|
14
|
+
BindingName = "ReplicateTTMBinding"
|
|
15
|
+
|
|
16
|
+
# Popular music models available on Replicate
|
|
17
|
+
# Sourced from: https://replicate.com/collections/text-to-music
|
|
18
|
+
REPLICATE_MODELS = [
|
|
19
|
+
{"model_name": "meta/musicgen:b05b1dff1d8c6ac63d42422dd565e23b63869bf2d51acda751e04b5dd304535d", "display_name": "Meta - MusicGen", "description": "State-of-the-art controllable text-to-music model from Meta."},
|
|
20
|
+
{"model_name": "suno-ai/bark:b76242b40d67c76ab6742e987628a2a9ac019e11d56ab96c4e91ce03b79b2787", "display_name": "Suno - Bark", "description": "Text-to-audio model capable of music, voice, and sound effects."},
|
|
21
|
+
{"model_name": "joehoover/musicgen-melody:7a76a8258b23fae65c5a24debbe88414f9bed22c2422a63465731103f6990803", "display_name": "MusicGen Melody", "description": "MusicGen fine-tuned for generating melodies."},
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
class ReplicateTTMBinding(LollmsTTMBinding):
|
|
25
|
+
"""A Text-to-Music binding for models hosted on Replicate."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, **kwargs):
|
|
28
|
+
super().__init__(binding_name=BindingName, **kwargs)
|
|
29
|
+
self.api_key = self.settings.get("api_key") or os.environ.get("REPLICATE_API_TOKEN")
|
|
30
|
+
if not self.api_key:
|
|
31
|
+
raise ValueError("Replicate API token is required. Please set it in config or as REPLICATE_API_TOKEN env var.")
|
|
32
|
+
self.model_version = self.settings.get("model_name", "meta/musicgen:b05b1dff1d8c6ac63d42422dd565e23b63869bf2d51acda751e04b5dd304535d")
|
|
33
|
+
self.base_url = "https://api.replicate.com/v1"
|
|
34
|
+
self.headers = {"Authorization": f"Token {self.api_key}", "Content-Type": "application/json"}
|
|
35
|
+
|
|
36
|
+
def list_models(self, **kwargs) -> List[Dict[str, str]]:
|
|
37
|
+
return REPLICATE_MODELS
|
|
38
|
+
|
|
39
|
+
def generate_music(self, prompt: str, **kwargs) -> bytes:
|
|
40
|
+
"""
|
|
41
|
+
Generates music via Replicate by starting a prediction and polling for the result.
|
|
42
|
+
"""
|
|
43
|
+
model_id, version_id = self.model_version.split(":")
|
|
44
|
+
|
|
45
|
+
payload = {
|
|
46
|
+
"version": version_id,
|
|
47
|
+
"input": {
|
|
48
|
+
"prompt": prompt,
|
|
49
|
+
"duration": kwargs.get("duration", 8),
|
|
50
|
+
"temperature": kwargs.get("temperature", 1.0),
|
|
51
|
+
"top_p": kwargs.get("top_p", 0.9),
|
|
52
|
+
# Add other model-specific parameters here
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
# 1. Start the prediction
|
|
58
|
+
ASCIIColors.info(f"Submitting music generation job to Replicate ({model_id})...")
|
|
59
|
+
start_response = requests.post(f"{self.base_url}/predictions", json=payload, headers=self.headers)
|
|
60
|
+
start_response.raise_for_status()
|
|
61
|
+
job_data = start_response.json()
|
|
62
|
+
get_url = job_data["urls"]["get"]
|
|
63
|
+
ASCIIColors.info(f"Job submitted. Polling for results at: {get_url}")
|
|
64
|
+
|
|
65
|
+
# 2. Poll for the result
|
|
66
|
+
while True:
|
|
67
|
+
poll_response = requests.get(get_url, headers=self.headers)
|
|
68
|
+
poll_response.raise_for_status()
|
|
69
|
+
poll_data = poll_response.json()
|
|
70
|
+
status = poll_data["status"]
|
|
71
|
+
|
|
72
|
+
if status == "succeeded":
|
|
73
|
+
ASCIIColors.green("Generation successful!")
|
|
74
|
+
output_url = poll_data["output"]
|
|
75
|
+
# Download the resulting audio file
|
|
76
|
+
audio_response = requests.get(output_url)
|
|
77
|
+
audio_response.raise_for_status()
|
|
78
|
+
return audio_response.content
|
|
79
|
+
elif status in ["starting", "processing"]:
|
|
80
|
+
ASCIIColors.info(f"Job status: {status}. Waiting...")
|
|
81
|
+
time.sleep(3)
|
|
82
|
+
else: # failed, canceled
|
|
83
|
+
error_log = poll_data.get("logs", "No logs available.")
|
|
84
|
+
raise Exception(f"Replicate job failed with status '{status}'. Log: {error_log}")
|
|
85
|
+
|
|
86
|
+
except requests.exceptions.HTTPError as e:
|
|
87
|
+
error_details = e.response.json().get("detail", e.response.text)
|
|
88
|
+
raise Exception(f"Replicate API HTTP Error: {error_details}") from e
|
|
89
|
+
except Exception as e:
|
|
90
|
+
trace_exception(e)
|
|
91
|
+
raise
|
|
92
|
+
|
|
93
|
+
if __name__ == '__main__':
|
|
94
|
+
ASCIIColors.magenta("--- Replicate TTM Binding Test ---")
|
|
95
|
+
if "REPLICATE_API_TOKEN" not in os.environ:
|
|
96
|
+
ASCIIColors.error("REPLICATE_API_TOKEN environment variable not set. Cannot run test.")
|
|
97
|
+
exit(1)
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
binding = ReplicateTTMBinding()
|
|
101
|
+
|
|
102
|
+
ASCIIColors.cyan("\n--- Test: Music Generation with MusicGen ---")
|
|
103
|
+
prompt = "An epic cinematic orchestral piece, with soaring strings and dramatic percussion, fit for a movie trailer"
|
|
104
|
+
music_bytes = binding.generate_music(prompt, duration=10)
|
|
105
|
+
|
|
106
|
+
assert len(music_bytes) > 1000, "Generated music bytes are too small."
|
|
107
|
+
output_path = Path(__file__).parent / "tmp_replicate_music.wav"
|
|
108
|
+
with open(output_path, "wb") as f:
|
|
109
|
+
f.write(music_bytes)
|
|
110
|
+
ASCIIColors.green(f"Music generation OK. Audio saved to {output_path}")
|
|
111
|
+
|
|
112
|
+
except Exception as e:
|
|
113
|
+
trace_exception(e)
|
|
114
|
+
ASCIIColors.error(f"Replicate TTM binding test failed: {e}")
|