Skip to content

Commit

Permalink
Make type hints backwards compatible
Browse files Browse the repository at this point in the history
includes preparing 2.13 release
  • Loading branch information
volkerstampa committed Feb 14, 2023
1 parent b17ea26 commit 6ba8e38
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.13.0

- Add attention manipulation parameters on character level

## 2.12.0

- Introduce offline tokenizer
Expand Down
2 changes: 1 addition & 1 deletion aleph_alpha_client/aleph_alpha_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def from_model_name(
def complete(self, request: CompletionRequest) -> CompletionResponse:
"""
Examples:
>>> prompt = Prompt(["Provide a short description of AI:"])
>>> prompt = Prompt.from_text("Provide a short description of AI:")
>>> request = CompletionRequest(prompt=prompt, maximum_tokens=20)
>>> result = model.complete(request)
"""
Expand Down
4 changes: 2 additions & 2 deletions aleph_alpha_client/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def from_text(text: str) -> "Text":
return Text(text, [])


PromptItem = Union[Text, Tokens, Image]
PromptItem = Union[Text, Tokens, Image, str, Sequence[int]]


class Prompt(NamedTuple):
Expand All @@ -130,7 +130,7 @@ class Prompt(NamedTuple):
>>> prompt = Prompt.from_text("Provide a short description of AI:")
>>> prompt = Prompt([
Image.from_url(url),
"Provide a short description of AI:",
Text.from_text("Provide a short description of AI:"),
])
"""

Expand Down
2 changes: 1 addition & 1 deletion aleph_alpha_client/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.12.0"
__version__ = "2.13.0"
11 changes: 9 additions & 2 deletions tests/test_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from aleph_alpha_client.aleph_alpha_client import AlephAlphaClient, AsyncClient, Client
from aleph_alpha_client.aleph_alpha_model import AlephAlphaModel
from aleph_alpha_client.completion import CompletionRequest
from aleph_alpha_client.prompt import Prompt
from aleph_alpha_client.prompt import Prompt, Text, TextControl

from tests.common import (
client,
Expand Down Expand Up @@ -36,7 +36,14 @@ async def test_can_complete_with_async_client(
@pytest.mark.system_test
def test_complete(sync_client: Client, model_name: str):
request = CompletionRequest(
prompt=Prompt.from_text(""),
prompt=Prompt(
[
Text(
"Hello, World!",
controls=[TextControl(start=1, length=5, factor=0.5)],
)
]
),
maximum_tokens=7,
tokens=False,
log_probs=0,
Expand Down

0 comments on commit 6ba8e38

Please sign in to comment.