o
    hW                     @  sh  d dl mZ d dlmZmZmZmZmZmZ d dl	m
Z
 d dlZddlmZmZmZmZmZ ddlmZmZ ddlmZ dd	lmZmZ dd
lmZmZmZmZ ddlm Z m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddgZ0G dd deZ1G dd deZ2G dd dZ3G dd dZ4G dd dZ5G dd dZ6dS )    )annotations)DictListUnionIterableOptionaloverload)LiteralN   )	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperto_streamed_response_wrapperasync_to_raw_response_wrapper"async_to_streamed_response_wrapper)StreamAsyncStream)completion_create_params)make_request_options)ChatCompletion)ChatCompletionChunk)ChatCompletionToolParam)ChatCompletionMessageParam)#ChatCompletionToolChoiceOptionParamCompletionsAsyncCompletionsc                   @  8  e Zd ZedGddZedHddZeeeeeeeeeeeeeeeeeeeeeeeddded	dId;d<Zeeeeeeeeeeeeeeeeeeeeeeddded=dJd@d<Zeeeeeeeeeeeeeeeeeeeeeeddded=dKdCd<Zeeeeeeeeeeeeeeeeeeeeeeddded	dLdFd<ZdS )Mr"   returnCompletionsWithRawResponsec                 C     t | S a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/groq/groq-python#accessing-raw-response-data-eg-headers
        )r&   self r+   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/groq/resources/chat/completions.pywith_raw_response$      zCompletions.with_raw_response CompletionsWithStreamingResponsec                 C  r'   z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/groq/groq-python#with_streaming_response
        )r/   r)   r+   r+   r,   with_streaming_response.      z#Completions.with_streaming_responseNfrequency_penaltyfunction_call	functions
logit_biaslogprobsmax_completion_tokens
max_tokensnparallel_tool_callspresence_penaltyreasoning_formatresponse_formatseedservice_tierstopstreamtemperaturetool_choicetoolstop_logprobstop_puserextra_headersextra_query
extra_bodytimeoutmessages$Iterable[ChatCompletionMessageParam]modelstrr4   Optional[float] | NotGivenr5   :Optional[completion_create_params.FunctionCall] | NotGivenr6   @Optional[Iterable[completion_create_params.Function]] | NotGivenr7   #Optional[Dict[str, int]] | NotGivenr8   Optional[bool] | NotGivenr9   Optional[int] | NotGivenr:   r;   r<   r=   r>   7Optional[Literal['hidden', 'raw', 'parsed']] | NotGivenr?   <Optional[completion_create_params.ResponseFormat] | NotGivenr@   rA   9Optional[Literal['auto', 'on_demand', 'flex']] | NotGivenrB   0Union[Optional[str], List[str], None] | NotGivenrC   #Optional[Literal[False]] | NotGivenrD   rE   8Optional[ChatCompletionToolChoiceOptionParam] | NotGivenrF   6Optional[Iterable[ChatCompletionToolParam]] | NotGivenrG   rH   rI   Optional[str] | NotGivenrJ   Headers | NonerK   Query | NonerL   Body | NonerM   'float | httpx.Timeout | None | NotGivenr   c                C     d S Nr+   r*   rN   rP   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   r+   r+   r,   create7      #zCompletions.creater4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   Literal[True]Stream[ChatCompletionChunk]c                C  rd   re   r+   rf   r+   r+   r,   rg   \   rh   bool,ChatCompletion | Stream[ChatCompletionChunk]c                C  rd   re   r+   rf   r+   r+   r,   rg      rh   ]Union[str, Literal['gemma-7b-it', 'llama3-70b-8192', 'llama3-8b-8192', 'mixtral-8x7b-32768']]3Optional[Literal[False]] | Literal[True] | NotGivenc                C  s   | j dti d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d||||||||dtjt||||dt|pPdtt dS )9  
        Creates a model response for the given chat conversation.

        Args:
          messages: A list of messages comprising the conversation so far.

          model: ID of the model to use. For details on which models are compatible with the Chat
              API, see available [models](/docs/models)

          frequency_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on their
              existing frequency in the text so far, decreasing the model's likelihood to
              repeat the same line verbatim.

          function_call: Deprecated in favor of `tool_choice`.

              Controls which (if any) function is called by the model. `none` means the model
              will not call a function and instead generates a message. `auto` means the model
              can pick between generating a message or calling a function. Specifying a
              particular function via `{"name": "my_function"}` forces the model to call that
              function.

              `none` is the default when no functions are present. `auto` is the default if
              functions are present.

          functions: Deprecated in favor of `tools`.

              A list of functions the model may generate JSON inputs for.

          logit_bias: This is not yet supported by any of our models. Modify the likelihood of
              specified tokens appearing in the completion.

          logprobs: This is not yet supported by any of our models. Whether to return log
              probabilities of the output tokens or not. If true, returns the log
              probabilities of each output token returned in the `content` of `message`.

          max_completion_tokens: The maximum number of tokens that can be generated in the chat completion. The
              total length of input tokens and generated tokens is limited by the model's
              context length.

          max_tokens: Deprecated in favor of `max_completion_tokens`. The maximum number of tokens
              that can be generated in the chat completion. The total length of input tokens
              and generated tokens is limited by the model's context length.

          n: How many chat completion choices to generate for each input message. Note that
              the current moment, only n=1 is supported. Other values will result in a 400
              response.

          parallel_tool_calls: Whether to enable parallel function calling during tool use.

          presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on
              whether they appear in the text so far, increasing the model's likelihood to
              talk about new topics.

          reasoning_format: Specifies how to output reasoning tokens

          response_format: An object specifying the format that the model must output.

              Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
              message the model generates is valid JSON.

              **Important:** when using JSON mode, you **must** also instruct the model to
              produce JSON yourself via a system or user message.

          seed: If specified, our system will make a best effort to sample deterministically,
              such that repeated requests with the same `seed` and parameters should return
              the same result. Determinism is not guaranteed, and you should refer to the
              `system_fingerprint` response parameter to monitor changes in the backend.

          service_tier: The service tier to use for the request. Defaults to `on_demand`.

              - `auto` will automatically select the highest tier available within the rate
                limits of your organization.
              - `flex` uses the flex tier, which will succeed or fail quickly.

          stop: Up to 4 sequences where the API will stop generating further tokens. The
              returned text will not contain the stop sequence.

          stream: If set, partial message deltas will be sent. Tokens will be sent as data-only
              [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
              as they become available, with the stream terminated by a `data: [DONE]`
              message. [Example code](/docs/text-chat#streaming-a-chat-completion).

          temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
              make the output more random, while lower values like 0.2 will make it more
              focused and deterministic. We generally recommend altering this or top_p but not
              both

          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
              not call any tool and instead generates a message. `auto` means the model can
              pick between generating a message or calling one or more tools. `required` means
              the model must call one or more tools. Specifying a particular tool via
              `{"type": "function", "function": {"name": "my_function"}}` forces the model to
              call that tool.

              `none` is the default when no tools are present. `auto` is the default if tools
              are present.

          tools: A list of tools the model may call. Currently, only functions are supported as a
              tool. Use this to provide a list of functions the model may generate JSON inputs
              for. A max of 128 functions are supported.

          top_logprobs: This is not yet supported by any of our models. An integer between 0 and 20
              specifying the number of most likely tokens to return at each token position,
              each with an associated log probability. `logprobs` must be set to `true` if
              this parameter is used.

          top_p: An alternative to sampling with temperature, called nucleus sampling, where the
              model considers the results of the tokens with top_p probability mass. So 0.1
              means only the tokens comprising the top 10% probability mass are considered. We
              generally recommend altering this or temperature but not both.

          user: A unique identifier representing your end-user, which can help us monitor and
              detect abuse.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        /openai/v1/chat/completionsrN   rP   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   Fbodyoptionscast_torC   
stream_cls)_postr   r   CompletionCreateParamsr   r   r   r   rf   r+   r+   r,   rg      sp    	
)r%   r&   )r%   r/   :rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   r\   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   r   ):rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   rj   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   rk   ):rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   rl   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   rm   ):rN   rO   rP   rn   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   ro   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   rm   	__name__
__module____qualname__r   r-   r1   r   r   rg   r+   r+   r+   r,   r"   #       	$$)c                   @  r$   )Mr#   r%   AsyncCompletionsWithRawResponsec                 C  r'   r(   )r   r)   r+   r+   r,   r-   k  r.   z"AsyncCompletions.with_raw_response%AsyncCompletionsWithStreamingResponsec                 C  r'   r0   )r   r)   r+   r+   r,   r1   u  r2   z(AsyncCompletions.with_streaming_responseNr3   rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   r;   r<   r=   r>   rX   r?   rY   r@   rA   rZ   rB   r[   rC   r\   rD   rE   r]   rF   r^   rG   rH   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r   c                     d S re   r+   rf   r+   r+   r,   rg   ~     #zAsyncCompletions.createri   rj    AsyncStream[ChatCompletionChunk]c                  r   re   r+   rf   r+   r+   r,   rg     r   rl   1ChatCompletion | AsyncStream[ChatCompletionChunk]c                  r   re   r+   rf   r+   r+   r,   rg     r   rn   ro   c                  s   | j dti d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d||||||||dtjI dH t||||dt|pTdtt dI dH S )rp   rq   rN   rP   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rr   Nrs   Frt   )ry   r   r   rz   r   r   r   r   rf   r+   r+   r,   rg     sr    	
)r%   r   )r%   r   r{   ):rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   rj   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   r   ):rN   rO   rP   rQ   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   rl   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   r   ):rN   rO   rP   rn   r4   rR   r5   rS   r6   rT   r7   rU   r8   rV   r9   rW   r:   rW   r;   rW   r<   rV   r=   rR   r>   rX   r?   rY   r@   rW   rA   rZ   rB   r[   rC   ro   rD   rR   rE   r]   rF   r^   rG   rW   rH   rR   rI   r_   rJ   r`   rK   ra   rL   rb   rM   rc   r%   r   r|   r+   r+   r+   r,   r#   j  r   c                   @     e Zd ZdddZdS )	r&   completionsr"   r%   Nonec                 C     || _ t|j| _d S re   )_completionsr   rg   r*   r   r+   r+   r,   __init__     
z#CompletionsWithRawResponse.__init__Nr   r"   r%   r   r}   r~   r   r   r+   r+   r+   r,   r&         r&   c                   @  r   )	r   r   r#   r%   r   c                 C  r   re   )r   r   rg   r   r+   r+   r,   r     r   z(AsyncCompletionsWithRawResponse.__init__Nr   r#   r%   r   r   r+   r+   r+   r,   r     r   r   c                   @  r   )	r/   r   r"   r%   r   c                 C  r   re   )r   r   rg   r   r+   r+   r,   r     r   z)CompletionsWithStreamingResponse.__init__Nr   r   r+   r+   r+   r,   r/     r   r/   c                   @  r   )	r   r   r#   r%   r   c                 C  r   re   )r   r   rg   r   r+   r+   r,   r     r   z.AsyncCompletionsWithStreamingResponse.__init__Nr   r   r+   r+   r+   r,   r     r   r   )7
__future__r   typingr   r   r   r   r   r   typing_extensionsr	   httpx_typesr   r   r   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   r   r   
_streamingr   r   
types.chatr   _base_clientr   types.chat.chat_completionr    types.chat.chat_completion_chunkr   %types.chat.chat_completion_tool_paramr   (types.chat.chat_completion_message_paramr    3types.chat.chat_completion_tool_choice_option_paramr!   __all__r"   r#   r&   r   r/   r   r+   r+   r+   r,   <module>   s8      I  I			