Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,9 @@ import json
|
|
| 4 |
import openai
|
| 5 |
|
| 6 |
# OpenAI APIキーを設定(あなたのAPIキーをここに入力してください)
|
| 7 |
-
openai.api_key = '
|
| 8 |
|
| 9 |
-
def excel_to_json_and_convert(file,
|
| 10 |
# エクセルファイルを読み込み
|
| 11 |
df = pd.read_excel(file)
|
| 12 |
|
|
@@ -21,7 +21,7 @@ def excel_to_json_and_convert(file, engine):
|
|
| 21 |
|
| 22 |
# OpenAI GPT-3にリクエストを送信
|
| 23 |
response = openai.ChatCompletion.create(
|
| 24 |
-
model=
|
| 25 |
messages=[
|
| 26 |
{"role": "system", "content": "You are a helpful assistant."},
|
| 27 |
{"role": "user", "content": prompt}
|
|
@@ -29,7 +29,7 @@ def excel_to_json_and_convert(file, engine):
|
|
| 29 |
)
|
| 30 |
|
| 31 |
# レスポンスからテキストを抽出
|
| 32 |
-
converted_text = response
|
| 33 |
|
| 34 |
return converted_text
|
| 35 |
|
|
@@ -38,10 +38,10 @@ interface = gr.Interface(
|
|
| 38 |
fn=excel_to_json_and_convert,
|
| 39 |
inputs=[
|
| 40 |
gr.File(label="Upload Excel File"),
|
| 41 |
-
gr.Radio(choices=["gpt-3.5-turbo", "gpt-
|
| 42 |
],
|
| 43 |
outputs=gr.Textbox(label="Converted Output"),
|
| 44 |
-
title="Excel to JSON Converter and OpenAI GPT-3/
|
| 45 |
description="Upload an Excel file and get JSON output of column C values converted to half-width Katakana by OpenAI GPT-3/4."
|
| 46 |
)
|
| 47 |
|
|
|
|
| 4 |
import openai
|
| 5 |
|
| 6 |
# OpenAI APIキーを設定(あなたのAPIキーをここに入力してください)
|
| 7 |
+
openai.api_key = 'sk-proj-O9Qlw9lhCqMrWx4TNtLCT3BlbkFJDqrx6zKPfAv3ljoutKhi'
|
| 8 |
|
| 9 |
+
def excel_to_json_and_convert(file, model):
|
| 10 |
# エクセルファイルを読み込み
|
| 11 |
df = pd.read_excel(file)
|
| 12 |
|
|
|
|
| 21 |
|
| 22 |
# OpenAI GPT-3にリクエストを送信
|
| 23 |
response = openai.ChatCompletion.create(
|
| 24 |
+
model=model,
|
| 25 |
messages=[
|
| 26 |
{"role": "system", "content": "You are a helpful assistant."},
|
| 27 |
{"role": "user", "content": prompt}
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
# レスポンスからテキストを抽出
|
| 32 |
+
converted_text = response.choices[0].message['content'].strip()
|
| 33 |
|
| 34 |
return converted_text
|
| 35 |
|
|
|
|
| 38 |
fn=excel_to_json_and_convert,
|
| 39 |
inputs=[
|
| 40 |
gr.File(label="Upload Excel File"),
|
| 41 |
+
gr.Radio(choices=["gpt-3.5-turbo", "gpt-4o"], label="Select OpenAI Model")
|
| 42 |
],
|
| 43 |
outputs=gr.Textbox(label="Converted Output"),
|
| 44 |
+
title="Excel to JSON Converter and OpenAI GPT-3/4o Converter",
|
| 45 |
description="Upload an Excel file and get JSON output of column C values converted to half-width Katakana by OpenAI GPT-3/4."
|
| 46 |
)
|
| 47 |
|