000 / app.py
Seunggg's picture
Update app.py
a3a3430 verified
raw
history blame
708 Bytes
import os, gradio as gr, openai
openai.api_key = os.getenv("DEEPSEEK_API_KEY")
def analyze_env(temperature, light, soil_humidity):
msg = [
{"role": "system", "content": "You are a plant care assistant."},
{"role": "user", "content": f"Temperature: {temperature}°C, Light: {light} lux, Soil Humidity: {soil_humidity}%."}
]
resp = openai.ChatCompletion.create(model="deepseek-chat", messages=msg, temperature=0.7)
return resp.choices[0].message.content
demo = gr.Interface(fn=analyze_env,
inputs=[gr.Number(label="Temperature (°C)"), gr.Number(label="Light (lux)"), gr.Number(label="Soil Humidity (%)")],
outputs="text",
title="植物环境分析"
)
demo.launch()