Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,12 +17,12 @@ def get_client(space_id: str) -> Client:
|
|
17 |
|
18 |
|
19 |
@mcp.tool()
|
20 |
-
async def generate_image(prompt: str, space_id: str = "
|
21 |
"""Generate an image using Flux.
|
22 |
|
23 |
Args:
|
24 |
prompt: Text prompt describing the image to generate
|
25 |
-
space_id:
|
26 |
"""
|
27 |
client = get_client(space_id)
|
28 |
result = client.predict(
|
@@ -37,92 +37,3 @@ async def generate_image(prompt: str, space_id: str = "ysharma/SanaSprint") -> s
|
|
37 |
api_name="/infer"
|
38 |
)
|
39 |
return result
|
40 |
-
|
41 |
-
|
42 |
-
@mcp.tool()
|
43 |
-
async def run_dia_tts(prompt: str, space_id: str = "ysharma/Dia-1.6B") -> str:
|
44 |
-
"""Text-to-Speech Synthesis.
|
45 |
-
|
46 |
-
Args:
|
47 |
-
prompt: Text prompt describing the conversation between speakers S1, S2
|
48 |
-
space_id: HuggingFace Space ID to use
|
49 |
-
"""
|
50 |
-
client = get_client(space_id)
|
51 |
-
result = client.predict(
|
52 |
-
text_input=f"""{prompt}""",
|
53 |
-
audio_prompt_input=None,
|
54 |
-
max_new_tokens=3072,
|
55 |
-
cfg_scale=3,
|
56 |
-
temperature=1.3,
|
57 |
-
top_p=0.95,
|
58 |
-
cfg_filter_top_k=30,
|
59 |
-
speed_factor=0.94,
|
60 |
-
api_name="/generate_audio"
|
61 |
-
)
|
62 |
-
return result
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
67 |
-
|
68 |
-
|
69 |
-
def respond(
|
70 |
-
message,
|
71 |
-
history: list[tuple[str, str]],
|
72 |
-
system_message,
|
73 |
-
max_tokens,
|
74 |
-
temperature,
|
75 |
-
top_p,
|
76 |
-
):
|
77 |
-
messages = [{"role": "system", "content": system_message}]
|
78 |
-
|
79 |
-
for val in history:
|
80 |
-
if val[0]:
|
81 |
-
messages.append({"role": "user", "content": val[0]})
|
82 |
-
if val[1]:
|
83 |
-
messages.append({"role": "assistant", "content": val[1]})
|
84 |
-
|
85 |
-
messages.append({"role": "user", "content": message})
|
86 |
-
|
87 |
-
response = ""
|
88 |
-
|
89 |
-
for message in client.chat_completion(
|
90 |
-
messages,
|
91 |
-
max_tokens=max_tokens,
|
92 |
-
stream=True,
|
93 |
-
temperature=temperature,
|
94 |
-
top_p=top_p,
|
95 |
-
):
|
96 |
-
token = message.choices[0].delta.content
|
97 |
-
|
98 |
-
response += token
|
99 |
-
yield response
|
100 |
-
|
101 |
-
|
102 |
-
"""
|
103 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
104 |
-
"""
|
105 |
-
demo = gr.ChatInterface(
|
106 |
-
respond,
|
107 |
-
additional_inputs=[
|
108 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
109 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
110 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
111 |
-
gr.Slider(
|
112 |
-
minimum=0.1,
|
113 |
-
maximum=1.0,
|
114 |
-
value=0.95,
|
115 |
-
step=0.05,
|
116 |
-
label="Top-p (nucleus sampling)",
|
117 |
-
),
|
118 |
-
],
|
119 |
-
)
|
120 |
-
|
121 |
-
|
122 |
-
if __name__ == "__main__":
|
123 |
-
import sys
|
124 |
-
import io
|
125 |
-
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
126 |
-
|
127 |
-
mcp.run(transport='stdio')
|
128 |
-
demo.launch()
|
|
|
17 |
|
18 |
|
19 |
@mcp.tool()
|
20 |
+
async def generate_image(prompt: str, space_id: str = "inoculatemedia/FramePack-F1") -> str:
|
21 |
"""Generate an image using Flux.
|
22 |
|
23 |
Args:
|
24 |
prompt: Text prompt describing the image to generate
|
25 |
+
space_id: inoculatemedia/FramePack-F1
|
26 |
"""
|
27 |
client = get_client(space_id)
|
28 |
result = client.predict(
|
|
|
37 |
api_name="/infer"
|
38 |
)
|
39 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|