tsengiii's picture
Update app.py
01ce0b2 verified
raw
history blame contribute delete
809 Bytes
import time
import gradio as gi
import openai
import os
import requests
import json
# 從 Hugging Face secrets 中讀取 OpenAI API 金鑰
api_key = os.getenv('OPENAI_API_KEY')
if not api_key:
raise ValueError("請設置 'OPENAI_API_KEY' 環境變數")
# OpenAI API key
openai_api_key = api_key
\
# Define a function for your model's functionality
def generate_image(prompt):
# 這裡應該是你的模型運行邏輯,你可以調用原本的模型功能
return "生成的圖片(這裡應該放你生成的圖片)"
# 自定義介面
interface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="輸入"),
outputs=gr.Image(label="輸出"),
title="最棒第一組",
description="歡迎來到第一組的小天地"
)
# Launch the interface
interface.launch()