(self, requests)
| 117 | ) |
| 118 | |
| 119 | def greedy_until(self, requests): |
| 120 | if not requests: |
| 121 | return [] |
| 122 | |
| 123 | res = [] |
| 124 | for request in tqdm(requests): |
| 125 | inp = request[0] |
| 126 | request_args = request[1] |
| 127 | until = request_args["until"] |
| 128 | response = textsynth_completion( |
| 129 | url=self.api_url + "/v1/engines/" + self.engine + "/completions", |
| 130 | headers={"Authorization": "Bearer " + self.api_key}, |
| 131 | json={ |
| 132 | "prompt": inp, |
| 133 | "max_tokens": self.max_gen_toks, |
| 134 | "top_k": 1, |
| 135 | "stop": until, |
| 136 | }, |
| 137 | ) |
| 138 | resp = response.json() |
| 139 | if "text" in resp: |
| 140 | s = resp["text"] |
| 141 | res.append(s) |
| 142 | else: |
| 143 | logger.error( |
| 144 | f"The following response does not contain generated `text`. " |
| 145 | "Got:\n{resp}" |
| 146 | ) |
| 147 | assert False |
| 148 | return res |
| 149 | |
| 150 | def _model_call(self, inps): |
| 151 | # Isn't used because we override _loglikelihood_tokens |
nothing calls this directly
no test coverage detected