Spaces:
Runtime error
Runtime error
Update
Browse files
app.py
CHANGED
|
@@ -11,14 +11,14 @@ def completion(model_engine, prompt, max_tokens, temperature, top_p, top_k, n, s
|
|
| 11 |
if model_engine == "davinci-003":
|
| 12 |
model = "text-davinci-003"
|
| 13 |
|
| 14 |
-
|
| 15 |
model=model, prompt=prompt, temperature=temperature, max_tokens=max_tokens, top_p=top_p, n=n,
|
| 16 |
-
stop=list(stop_tokens)
|
| 17 |
)
|
| 18 |
-
for idx, choice in enumerate(
|
| 19 |
text = choice['text']
|
| 20 |
st.success(f'生成结果#{idx}: {text}')
|
| 21 |
-
st.json(
|
| 22 |
|
| 23 |
elif model_engine == "WeLM":
|
| 24 |
resp = requests.post("https://welm.weixin.qq.com/v1/completions", json={
|
|
@@ -45,7 +45,7 @@ def completion(model_engine, prompt, max_tokens, temperature, top_p, top_k, n, s
|
|
| 45 |
st.info(f'生成结果#{idx}: 结果为空,可能的原因:生成的第一个字符为stop字符,请合理配置prompt或stop')
|
| 46 |
else:
|
| 47 |
st.success(f'生成结果#{idx}: {text}')
|
| 48 |
-
st.json(
|
| 49 |
|
| 50 |
|
| 51 |
# Streamlit应用程序
|
|
|
|
| 11 |
if model_engine == "davinci-003":
|
| 12 |
model = "text-davinci-003"
|
| 13 |
|
| 14 |
+
answer = openai.Completion.create(
|
| 15 |
model=model, prompt=prompt, temperature=temperature, max_tokens=max_tokens, top_p=top_p, n=n,
|
| 16 |
+
stop=list(stop_tokens), frequency_penalty=0, presence_penalty=0.6,
|
| 17 |
)
|
| 18 |
+
for idx, choice in enumerate(answer['choices']):
|
| 19 |
text = choice['text']
|
| 20 |
st.success(f'生成结果#{idx}: {text}')
|
| 21 |
+
st.json(answer, expanded=False)
|
| 22 |
|
| 23 |
elif model_engine == "WeLM":
|
| 24 |
resp = requests.post("https://welm.weixin.qq.com/v1/completions", json={
|
|
|
|
| 45 |
st.info(f'生成结果#{idx}: 结果为空,可能的原因:生成的第一个字符为stop字符,请合理配置prompt或stop')
|
| 46 |
else:
|
| 47 |
st.success(f'生成结果#{idx}: {text}')
|
| 48 |
+
st.json(answer, expanded=False)
|
| 49 |
|
| 50 |
|
| 51 |
# Streamlit应用程序
|