| 85 | ) |
| 86 | |
| 87 | def __call__(self, prompt: str): |
| 88 | # The line `prompt = truncate_tokens(prompt, encoding_name=self.config["model"], |
| 89 | # max_length=self.config["max_tokens"])` is calling a function named `truncate_tokens` with |
| 90 | # three arguments: `prompt`, `encoding_name`, and `max_length`. This function is likely used |
| 91 | # to truncate the input `prompt` to a specified maximum length based on the model being used |
| 92 | # and the maximum tokens allowed. |
| 93 | # prompt = truncate_tokens(prompt, encoding_name=self.config["model"], max_length=self.config["max_tokens"]) |
| 94 | response = self.client.chat.completions.create( |
| 95 | temperature=0, |
| 96 | model=self.config["model"], |
| 97 | messages=[ |
| 98 | {"role": "system", "content": self.system_prompt}, |
| 99 | {"role": "user", "content": prompt}, |
| 100 | ] |
| 101 | ) |
| 102 | return response.choices[0].message.content |
| 103 | |
| 104 | |
| 105 | class AzureLLM(LLM): |