Spaces:
Runtime error
Runtime error
新しいエンドポイントを追加し、テキスト処理機能を実装。特定の文字を置換する機能とフィラーを削除する機能を追加し、全体の前処理を行うエンドポイントを作成。
Browse files
app.py
CHANGED
|
@@ -12,9 +12,21 @@ load_dotenv()
|
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# 環境変数からHUGGING_FACE_TOKENを取得
|
| 20 |
HUGGING_FACE_TOKEN = os.environ.get('HUGGING_FACE_TOKEN')
|
|
@@ -70,10 +82,6 @@ examples = [
|
|
| 70 |
'少し待ってください。',
|
| 71 |
]
|
| 72 |
|
| 73 |
-
def preprocess(text):
|
| 74 |
-
text = text.replace('◯', '0')
|
| 75 |
-
return text
|
| 76 |
-
|
| 77 |
from enum import Enum
|
| 78 |
|
| 79 |
class InferenceEndpointErrorCode(Enum):
|
|
|
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
+
@app.post("/replace-circle")
|
| 16 |
+
def replace_circle(input_text):
|
| 17 |
+
output_text = input_text.replace('◯', '0')
|
| 18 |
+
return output_text
|
| 19 |
+
|
| 20 |
+
@app.post("/remove-filler")
|
| 21 |
+
def remove_filler(input_text):
|
| 22 |
+
output_text = input_text
|
| 23 |
+
return output_text
|
| 24 |
+
|
| 25 |
+
@app.post("/preprocess")
|
| 26 |
+
def preprocess(input_text):
|
| 27 |
+
output_text = replace_circle(input_text)
|
| 28 |
+
output_text = remove_filler(output_text)
|
| 29 |
+
return output_text
|
| 30 |
|
| 31 |
# 環境変数からHUGGING_FACE_TOKENを取得
|
| 32 |
HUGGING_FACE_TOKEN = os.environ.get('HUGGING_FACE_TOKEN')
|
|
|
|
| 82 |
'少し待ってください。',
|
| 83 |
]
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
from enum import Enum
|
| 86 |
|
| 87 |
class InferenceEndpointErrorCode(Enum):
|