Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boucle inf on javascript call to Dalai #465

Open
nbeny opened this issue Jul 28, 2023 · 0 comments
Open

boucle inf on javascript call to Dalai #465

nbeny opened this issue Jul 28, 2023 · 0 comments

Comments

@nbeny
Copy link

nbeny commented Jul 28, 2023

Hello,

I currently try to integrate the solution to an API.

I testing the Dalai javascript livrary for made it.

Here is my code:

const Dalai = require('dalai')

const test = () => {
  return new Promise((resolve, reject) => {
    let answer = ''
    new Dalai().request(
      {
        model: 'llama.7B',
        prompt:
          "listes 5 domaines ou ils y a le plus de chance de creer une boite avec l'IA ?",
      },
      (token) => {
        answer += token

        // Vérifier si le token est '<end>'
        if (token.includes('<end>')) {
          resolve(answer)
        }
      },
      (error) => {
        reject(error)
      }
    )
  })
}

;(async () => {
  try {
    const result = await test()
    console.log(result)
  } catch (error) {
    console.error("Une erreur s'est produite :", error)
  }
})()

This is fonctionnaly work I see the console.log(result) at the end. But the program never stop, I have to ctrl + C. So something run when the script should finish. Do you know why ?

This break the possibility to integrate with an API REST so...

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant