Update app.py
Browse files
app.py
CHANGED
|
@@ -38,16 +38,25 @@ def respond(
|
|
| 38 |
# パラメータを適切な型に変換(API呼び出し時の文字列対策)
|
| 39 |
try:
|
| 40 |
max_tokens = int(max_tokens) if max_tokens is not None else 512
|
|
|
|
|
|
|
|
|
|
| 41 |
except (ValueError, TypeError):
|
| 42 |
max_tokens = 512
|
| 43 |
|
| 44 |
try:
|
| 45 |
temperature = float(temperature) if temperature is not None else 0.7
|
|
|
|
|
|
|
|
|
|
| 46 |
except (ValueError, TypeError):
|
| 47 |
temperature = 0.7
|
| 48 |
|
| 49 |
try:
|
| 50 |
top_p = float(top_p) if top_p is not None else 0.95
|
|
|
|
|
|
|
|
|
|
| 51 |
except (ValueError, TypeError):
|
| 52 |
top_p = 0.95
|
| 53 |
|
|
|
|
| 38 |
# パラメータを適切な型に変換(API呼び出し時の文字列対策)
|
| 39 |
try:
|
| 40 |
max_tokens = int(max_tokens) if max_tokens is not None else 512
|
| 41 |
+
# max_tokensが0以下の場合は512に設定
|
| 42 |
+
if max_tokens <= 0:
|
| 43 |
+
max_tokens = 1
|
| 44 |
except (ValueError, TypeError):
|
| 45 |
max_tokens = 512
|
| 46 |
|
| 47 |
try:
|
| 48 |
temperature = float(temperature) if temperature is not None else 0.7
|
| 49 |
+
# temperatureが0以下の場合は0.7に設定
|
| 50 |
+
if temperature <= 0:
|
| 51 |
+
temperature = 0.7
|
| 52 |
except (ValueError, TypeError):
|
| 53 |
temperature = 0.7
|
| 54 |
|
| 55 |
try:
|
| 56 |
top_p = float(top_p) if top_p is not None else 0.95
|
| 57 |
+
# top_pが0以下の場合は0.95に設定
|
| 58 |
+
if top_p <= 0:
|
| 59 |
+
top_p = 0.95
|
| 60 |
except (ValueError, TypeError):
|
| 61 |
top_p = 0.95
|
| 62 |
|