jbilcke-hf HF staff commited on
Commit
a44c1b5
·
1 Parent(s): e62f50c

workaround for llama2

Browse files
src/app/queries/getBackground.ts CHANGED
@@ -54,10 +54,16 @@ Here is the original scene in which the user was located at first, which will in
54
  let result = ""
55
  try {
56
  result = await predict(prompt)
 
 
 
57
  } catch (err) {
58
  console.log(`prediction of the background failed, trying again..`)
59
  try {
60
- result = await predict(prompt)
 
 
 
61
  } catch (err) {
62
  console.error(`prediction of the background failed again!`)
63
  throw new Error(`failed to generate the background ${err}`)
 
54
  let result = ""
55
  try {
56
  result = await predict(prompt)
57
+ if (!result.trim().length) {
58
+ throw new Error("empty result!")
59
+ }
60
  } catch (err) {
61
  console.log(`prediction of the background failed, trying again..`)
62
  try {
63
+ result = await predict(prompt+".")
64
+ if (!result.trim().length) {
65
+ throw new Error("empty result!")
66
+ }
67
  } catch (err) {
68
  console.error(`prediction of the background failed again!`)
69
  throw new Error(`failed to generate the background ${err}`)
src/app/queries/getDialogue.ts CHANGED
@@ -58,10 +58,13 @@ Here is the original situation, which will inform you about the general game moo
58
  let result = ""
59
  try {
60
  result = await predict(prompt)
 
 
 
61
  } catch (err) {
62
  console.log(`prediction of the dialogue failed, trying again..`)
63
  try {
64
- result = await predict(prompt)
65
  } catch (err) {
66
  console.error(`prediction of the dialogue failed again!`)
67
  throw new Error(`failed to generate the dialogue ${err}`)
 
58
  let result = ""
59
  try {
60
  result = await predict(prompt)
61
+ if (!result.trim().length) {
62
+ throw new Error("empty dialogue!")
63
+ }
64
  } catch (err) {
65
  console.log(`prediction of the dialogue failed, trying again..`)
66
  try {
67
+ result = await predict(prompt+".")
68
  } catch (err) {
69
  console.error(`prediction of the dialogue failed again!`)
70
  throw new Error(`failed to generate the dialogue ${err}`)