nekoniii3 commited on
Commit
3426677
·
1 Parent(s): 3c43af7
Files changed (2) hide show
  1. app.py +5 -10
  2. requirements.txt +1 -1
app.py CHANGED
@@ -15,9 +15,6 @@ size_list = ["1024x1024" ,"1024x1792" ,"1792x1024"]
15
  quality_list = ["standard" ,"hd"]
16
  style_list = ["vivid", "natural"]
17
 
18
- # サンプルプロンプト用
19
- examples = ["1980s anime girl with straight bob-cut in school uniform, roughly drawn drawing"
20
- , "a minimalisit logo for a sporting goods company"]
21
 
22
  def set_state(state, openai_key, size, quality, style):
23
 
@@ -64,7 +61,7 @@ def request_dalle(client, prompt, size, quality, style, image_path):
64
  except Exception as e:
65
  print(e)
66
  out_image_path = ""
67
- err_msg = "その他のエラーが発生しました。"
68
  finally:
69
  return err_msg, revised_prompt
70
 
@@ -113,7 +110,7 @@ def create_image(state, text):
113
  if client is None:
114
 
115
  os.environ["OPENAI_API_KEY"] = state["openai_key"]
116
- os.environ["OPENAI_API_KEY"] = os.environ["TEST_API_KEY"]
117
  # クライアント作成
118
  client = OpenAI()
119
 
@@ -122,9 +119,6 @@ def create_image(state, text):
122
 
123
  state["client"] = client
124
 
125
- # テスト用
126
- # image_path = "cat.png"
127
-
128
  return_msg, prompt = request_dalle(client, text, size, quality, style, image_path)
129
 
130
  if return_msg == "":
@@ -203,9 +197,10 @@ with gr.Blocks() as demo:
203
 
204
  with gr.Tab("利用上の注意"):
205
 
206
- caution = "1枚当たりの料金はサイズ:1024x1024で0.04ドル、それ以外のサイズは0.080ドルです。<br>"
207
  caution += "・こちらはクオリティがStandardの場合で、hdの場合は1.5~2倍とかかります。"
208
- caution += "料金の詳細→https://openai.com/pricing"
 
209
  gr.Markdown("<h3>" + caution + "</h3>")
210
 
211
 
 
15
  quality_list = ["standard" ,"hd"]
16
  style_list = ["vivid", "natural"]
17
 
 
 
 
18
 
19
  def set_state(state, openai_key, size, quality, style):
20
 
 
61
  except Exception as e:
62
  print(e)
63
  out_image_path = ""
64
+ err_msg = "その他のエラーが発生しました。OpenAI APIキーが正しいか、クレジット残高があるか確認して下さい。"
65
  finally:
66
  return err_msg, revised_prompt
67
 
 
110
  if client is None:
111
 
112
  os.environ["OPENAI_API_KEY"] = state["openai_key"]
113
+
114
  # クライアント作成
115
  client = OpenAI()
116
 
 
119
 
120
  state["client"] = client
121
 
 
 
 
122
  return_msg, prompt = request_dalle(client, text, size, quality, style, image_path)
123
 
124
  if return_msg == "":
 
197
 
198
  with gr.Tab("利用上の注意"):
199
 
200
+ caution = "利用上の注意<br>・1枚当たりの料金はサイズ:1024x1024で0.04ドル、それ以外のサイズは0.080ドルです。<br>"
201
  caution += "・こちらはクオリティがStandardの場合で、hdの場合は1.5~2倍とかかります。"
202
+ caution += " 料金の詳細→https://openai.com/pricing<br>"
203
+ caution += "<br>免責事項<br>・本アプリはOpenAIのAPIで製作されており、利用で生じた損害について一切の責任を負えません。"
204
  gr.Markdown("<h3>" + caution + "</h3>")
205
 
206
 
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
  # gradio==4.0.2
2
- openai==1.6.1
 
1
  # gradio==4.0.2
2
+ openai==1.12.0