Skip to content

Commit

Permalink
Merge pull request #974 from PrefectHQ/extras
Browse files Browse the repository at this point in the history
allow extra chat request params
  • Loading branch information
zzstoatzz authored Oct 26, 2024
2 parents 69a35c7 + b8a3bb7 commit 5a49a50
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/marvin/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class ResponseModel(MarvinType):


class ChatRequest(Prompt[T]):
model_config = dict(extra="allow")

model: str = Field(default_factory=lambda: settings.openai.chat.completions.model)
frequency_penalty: Optional[
Annotated[float, Field(strict=True, ge=-2.0, le=2.0)]
Expand All @@ -177,6 +179,8 @@ class ChatRequest(Prompt[T]):
)
top_p: Optional[Annotated[float, Field(strict=True, ge=0, le=1)]] = 1
user: Optional[str] = None
logprobs: Optional[bool] = None
max_completion_tokens: Optional[Annotated[int, Field(strict=True, ge=1)]] = None


class TranscriptRequest(MarvinType):
Expand Down
7 changes: 5 additions & 2 deletions tests/ai/vision/test_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ def test_two_cities(self):
"https://images.unsplash.com/photo-1617581629397-a72507c3de9e"
)

result = marvin.caption([img_ny, img_dc], instructions="what city is this?")
result = marvin.caption([img_ny, img_dc], instructions="what cities are these?")

assert_equal(
result,
"New York City; Washington DC",
instructions="A caption was generated for two images. Ensure it mentions both cities.",
instructions=(
"A caption was generated for two images. Ensure it mentions both cities"
" but don't enforce the exact text, i.e. D.C. ~= Washington DC"
),
)
3 changes: 3 additions & 0 deletions tests/beta/assistants/test_assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def mocked_client():
return client


pytest.skip("Assistants API is not stable", allow_module_level=True)


@pytest.fixture(autouse=True)
def mock_get_client(monkeypatch):
# Use monkeypatch to replace get_client with special_get_client
Expand Down

0 comments on commit 5a49a50

Please sign in to comment.