Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 'logprobs' and 'max_completion_tokens' to ChatRequest #973

Open
Omer-ler opened this issue Sep 26, 2024 · 2 comments · May be fixed by #974
Open

feat: add 'logprobs' and 'max_completion_tokens' to ChatRequest #973

Omer-ler opened this issue Sep 26, 2024 · 2 comments · May be fixed by #974

Comments

@Omer-ler
Copy link

Hi friends,
regarding -

marvin/src/marvin/types.py

Lines 163 to 179 in 24402ee

class ChatRequest(Prompt[T]):
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)]
] = 0
n: Optional[Annotated[int, Field(strict=True, ge=1)]] = 1
presence_penalty: Optional[
Annotated[float, Field(strict=True, ge=-2.0, le=2.0)]
] = 0
seed: Optional[int] = None
stop: Optional[Union[str, list[str]]] = None
stream: Optional[bool] = False
temperature: Optional[Annotated[float, Field(strict=True, ge=0, le=2)]] = Field(
default_factory=lambda: settings.openai.chat.completions.temperature
)
top_p: Optional[Annotated[float, Field(strict=True, ge=0, le=1)]] = 1
user: Optional[str] = None

IMO, ChatRequest class should also accept:

  1. logprobs: (Optional[bool]=None)
  2. max_completion_tokens (Optional[int]=None)

See OAI documentation for more details:
https://platform.openai.com/docs/api-reference/chat/create

Because of the lack of the above arguments, I met the following error:

  File "/usr/local/lib/python3.11/site-packages/marvin/ai/text.py", line 118, in generate_llm_response
    request = ChatRequest(messages=messages, **model_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 212, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ChatRequest
logprobs
  Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
max_completion_tokens
  Extra inputs are not permitted [type=extra_forbidden, input_value=1, input_type=int]
    For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
@zzstoatzz zzstoatzz linked a pull request Sep 30, 2024 that will close this issue
@zzstoatzz
Copy link
Collaborator

hi @Omer-ler - how does the PR linked above look? you can try it by pip installing from the branch (with pip or uv)

uv pip install git+https://github.com/prefecthq/marvin.git@extras

@Omer-ler
Copy link
Author

Looks great, Thanks @zzstoatzz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants