Validators
OpenAI API request validators.
- smarter.apps.provider.services.text_completion.validators.is_tool_call_message(message)[source]
Whether the message is an assistant message that calls tools.
As in the OpenAI chat completion api, such a message may omit its
content, or set it to null. Every other message must have acontent.
- smarter.apps.provider.services.text_completion.validators.validate_completion_request(request_body, version='v1')[source]
Validate a chat completion request body.
See openai.chat.completion.request.json.
- Parameters:
request_body – The decoded request body.
version (
str) – The api version. Forv1, the body must also containmodel,temperatureandmax_completion_tokens.
- Raises:
TypeError – If the request body is not a dict.
SmarterValueError – If
messagesis missing or invalid, or a key thatversionrequires is missing.
- Return type:
- smarter.apps.provider.services.text_completion.validators.validate_embedding_request(request_body)[source]
See openai.embedding.request.json.
- Return type:
- smarter.apps.provider.services.text_completion.validators.validate_endpoint(end_point)[source]
Ensure that end_point is a valid endpoint based on the OpenAIEndPoint enum.
- Return type:
- smarter.apps.provider.services.text_completion.validators.validate_max_completion_tokens(max_completion_tokens)[source]
Ensure that max_completion_tokens is an int between 1 and 2048.
- Return type:
- smarter.apps.provider.services.text_completion.validators.validate_messages(request_body)[source]
See openai.chat.completion.request.json.
- smarter.apps.provider.services.text_completion.validators.validate_object_types(object_type)[source]
Ensure that object_type is a valid object type based on the OpenAIObjectTypes enum.
- Return type: