Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,21 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# 加载你的模型
|
| 5 |
+
model = pipeline("text-generation", model="Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled") # 替换为你的模型
|
| 6 |
|
| 7 |
+
def generate_text(prompt):
|
| 8 |
+
result = model(prompt, max_length=100, do_sample=True)
|
| 9 |
+
return result[0]['generated_text']
|
| 10 |
+
|
| 11 |
+
# 创建Gradio界面
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=generate_text,
|
| 14 |
+
inputs=gr.Textbox(label="输入文本"),
|
| 15 |
+
outputs=gr.Textbox(label="生成结果"),
|
| 16 |
+
title="我的AI模型API",
|
| 17 |
+
description="这是一个可以通过API调用的AI模型"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# 启动Gradio应用
|
| 21 |
+
iface.launch()
|