Add OpenAI streaming support and enhance provider properties

This commit is contained in:
2024-11-02 16:34:47 -04:00
parent b6b1a4f9f3
commit 27d30ccfe8
4 changed files with 6 additions and 0 deletions
+3
View File
@@ -3,7 +3,10 @@ Release History
## 0.2.2 (2024-11-02)
- Add openai streaming support (set `stream=True` to `generate_text`).
- `conv.prepend_system_message` now uses system role by default.
- Add `provider.supports_streaming` property.
- Add `provider.supports_structured_response` property.
- General improvements.
## 0.2.1 (2024-11-01)
+1
View File
@@ -17,6 +17,7 @@ class BaseProvider(ABC):
NAME: str
DEFAULT_MODEL: str
supports_streaming: bool = False
supports_structured_responses: bool = True
@cached_property
@abstractmethod
+1
View File
@@ -24,6 +24,7 @@ class OpenAI(BaseProvider):
DEFAULT_MODEL = DEFAULT_MODEL
DEFAULT_KWARGS = DEFAULT_KWARGS
supports_streaming = True
def __init__(self, api_key: str | None = None):
self.api_key = api_key or settings.get_api_key(PROVIDER_NAME)
+1
View File
@@ -25,6 +25,7 @@ class XAI(BaseProvider):
NAME = PROVIDER_NAME
DEFAULT_MODEL = DEFAULT_MODEL
DEFAULT_KWARGS = DEFAULT_KWARGS
supports_structured_responses = False
def __init__(self, api_key: str | None = None):
self.api_key = api_key or settings.get_api_key(PROVIDER_NAME)