File size: 511 Bytes
9481d20
 
 
 
 
ab46848
 
 
 
 
9481d20
ab46848
9481d20
ab46848
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import os

def run_ollama(prompt):
    # 使用 Ollama 运行命令
    try:
        response = os.popen(f"ollama run hf.co/{prompt}").read()
        return response.strip()  # 确保返回值没有多余空格
    except Exception as e:
        return f"Error: {str(e)}"  # 捕获并返回错误信息

# 定义 Gradio 接口
iface = gr.Interface(fn=run_ollama, inputs="text", outputs="text", title="Ollama Model Runner")

# 启动应用程序
if __name__ == "__main__":
    iface.launch()