(self)
| 1710 | self.usage = ChatCompletionUsage(**response_dict["usage"]) |
| 1711 | |
| 1712 | def model_dump(self) -> Dict: |
| 1713 | return { |
| 1714 | "id": self.id, |
| 1715 | "object": self.object, |
| 1716 | "created": self.created, |
| 1717 | "model": self.model, |
| 1718 | "choices": [ |
| 1719 | { |
| 1720 | "index": choice.index, |
| 1721 | "message": { |
| 1722 | "role": choice.message.role, |
| 1723 | "content": choice.message.content, |
| 1724 | "logprobs": choice.message.logprobs |
| 1725 | } if choice.message.logprobs else { |
| 1726 | "role": choice.message.role, |
| 1727 | "content": choice.message.content |
| 1728 | }, |
| 1729 | "finish_reason": choice.finish_reason |
| 1730 | } |
| 1731 | for choice in self.choices |
| 1732 | ], |
| 1733 | "usage": { |
| 1734 | "prompt_tokens": self.usage.prompt_tokens, |
| 1735 | "completion_tokens": self.usage.completion_tokens, |
| 1736 | "total_tokens": self.usage.total_tokens, |
| 1737 | "completion_tokens_details": { |
| 1738 | "reasoning_tokens": getattr(self.usage, 'reasoning_tokens', 0) |
| 1739 | } |
| 1740 | } |
| 1741 | } |
| 1742 | |
| 1743 | class InferenceClient: |
| 1744 | """OpenAI SDK Compatible client for local inference with dynamic model support""" |
no outgoing calls