Repository: koishijs/novelai-bot
File: src/index.ts (TypeScript)

Code before:
          noise: options.noise ?? 0.2,
          strength: options.strength ?? 0.7,
        })
      }

      const id = Math.random().toString(36).slice(2)
      if (config.maxConcurrency) {
        const store = tasks[session.cid] ||= new Set()
        if (store.size >= config.maxConcurrency) {
          return session.text('.concurrent-jobs')
        } else {
          store.add(id)
        }
      }

      session.send(globalTasks.size > 1
        ? session.text('.pending', [globalTasks.size - 1])
        : session.text('.waiting'))

      globalTasks.add(id)
      const cleanUp = () => {
        tasks[session.cid]?.delete(id)
        globalTasks.delete(id)
      }

      const path = config.type === 'weiui' ? '/sdapi/v1/txt2img' : config.type === 'naifu' ? '/generate-stream' : '/ai/generate-image'
      const request = () => ctx.http.axios(trimSlash(config.endpoint) + path, {
        method: 'POST',
        timeout: config.requestTimeout,
        headers: {
          ...config.headers,
          authorization: 'Bearer ' + token,
        },
        data: config.type === 'webui'
          ? { prompt: input, n_samples: parameters.n_samples, sampler_index: parameters.sampler, negative_prompt: parameters.uc, seed: parameters.seed } as StableDiffusionWebuiReq
          : config.type === 'naifu'
          ? { ...parameters, prompt: input }
          : { model, input, parameters },
      }).then((res) => {
        if (config.type === 'webui') {
          return (res.data as StableDiffusionWebuiRes).images[0]
        }
        // event: newImage
        // id: 1
        // data:
        return res.data.slice(27)
      })

      let base64: string, count = 0
      while (true) {
        try {

Review comment (suggestion):
```suggestion
      const path = config.type === 'webui' ? '/sdapi/v1/txt2img' : config.type === 'naifu' ? '/generate-stream' : '/ai/generate-image'
```

Code after:
          noise: options.noise ?? 0.2,
          strength: options.strength ?? 0.7,
        })
      }

      const id = Math.random().toString(36).slice(2)
      if (config.maxConcurrency) {
        const store = tasks[session.cid] ||= new Set()
        if (store.size >= config.maxConcurrency) {
          return session.text('.concurrent-jobs')
        } else {
          store.add(id)
        }
      }

      session.send(globalTasks.size > 1
        ? session.text('.pending', [globalTasks.size - 1])
        : session.text('.waiting'))

      globalTasks.add(id)
      const cleanUp = () => {
        tasks[session.cid]?.delete(id)
        globalTasks.delete(id)
      }

      const path = config.type === 'sd-webui' ? '/sdapi/v1/txt2img' : config.type === 'naifu' ? '/generate-stream' : '/ai/generate-image'
      const request = () => ctx.http.axios(trimSlash(config.endpoint) + path, {
        method: 'POST',
        timeout: config.requestTimeout,
        headers: {
          ...config.headers,
          authorization: 'Bearer ' + token,
        },
        data: config.type === 'sd-webui'
          ? { prompt: input, n_samples: parameters.n_samples, sampler_index: parameters.sampler, negative_prompt: parameters.uc, seed: parameters.seed } as StableDiffusionWebuiReq
          : config.type === 'naifu'
          ? { ...parameters, prompt: input }
          : { model, input, parameters },
      }).then((res) => {
        if (config.type === 'sd-webui') {
          return (res.data as StableDiffusionWebuiRes).images[0]
        }
        // event: newImage
        // id: 1
        // data:
        return res.data.slice(27)
      })

      let base64: string, count = 0
      while (true) {
        try {