(self, requests)
| 130 | ) |
| 131 | |
| 132 | def generate_until(self, requests): |
| 133 | if not requests: |
| 134 | return [] |
| 135 | |
| 136 | res = [] |
| 137 | for request in tqdm(requests): |
| 138 | inp = request[0] |
| 139 | request_args = request[1] |
| 140 | until = request_args["until"] |
| 141 | response = textsynth_completion( |
| 142 | url=self.api_url + "/v1/engines/" + self.engine + "/completions", |
| 143 | headers={"Authorization": "Bearer " + self.api_key}, |
| 144 | json={ |
| 145 | "prompt": inp, |
| 146 | "max_tokens": self.max_gen_toks, |
| 147 | "top_k": 1, |
| 148 | "stop": until, |
| 149 | }, |
| 150 | ) |
| 151 | resp = response.json() |
| 152 | if "text" in resp: |
| 153 | s = resp["text"] |
| 154 | res.append(s) |
| 155 | |
| 156 | self.cache_hook.add_partial("generate_until", (inp, request_args), s) |
| 157 | else: |
| 158 | logger.error( |
| 159 | "The following response does not contain generated `text`. " |
| 160 | "Got:\n{resp}" |
| 161 | ) |
| 162 | assert False |
| 163 | return res |
| 164 | |
| 165 | def _model_call(self, inps): |
| 166 | # Isn't used because we override _loglikelihood_tokens |
nothing calls this directly
no test coverage detected