# CallChatGPT

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.OpenAI/tree/main/Frends.OpenAI.CallChatGPT>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                        | Description                                                                                                                                                                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Model : `String`            | <p>Chat GPT model to use.</p><p>Find a list of available models from <https://platform.openai.com/docs/models>.</p><p><br>Default: <code>gpt-3.5-turbo</code><br>Example: <code>gpt-3.5-turbo</code></p>                                                                         |
| 🗝ApiKey : `String`         | <p>Chat GPT API key.</p><p><br>Default: <code>-</code><br>Example: <code>1234567qwerty</code></p>                                                                                                                                                                                |
| Messages : `InputMessage[]` | <p>Array of messages to send to Chat GPT.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { "Content": "How are you?", "Role": "User" }, { "Content": "I'm fine, thanks. How about you?", "Role": "System" }, { "Content": "I'm fine too.", "Role": "User" } ]</code></p> |
| {% endtab %}                |                                                                                                                                                                                                                                                                                  |

{% tab title="Parameter: Options" %}

| Name                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| MaxTokens : `Nullable<Int32>`             | <p>The maximum number of tokens that can be generated in the chat</p><p>completion. Set to 0 for unlimited tokens.</p><p>The total length of input tokens and generated tokens is still limited</p><p>by the model's context length.</p><p><br>Default: <code>-</code><br>Example: <code>100</code></p>                                                                                                                                                              |
| N : `Int32`                               | <p>How many chat completion choices to generate for each input message.</p><p>Note that you will be charged based on the number of generated tokens</p><p>across all of the choices. Keep n as 1 to minimize costs.</p><p><br>Default: <code>1</code><br>Example: <code>3</code></p>                                                                                                                                                                                 |
| Seed : `Nullable<Int32>`                  | <p>If specified, ChatGPT system will make a best effort to sample</p><p>deterministically, such that repeated requests with the same seed and</p><p>parameters should return the same result. Determinism is not guaranteed,</p><p>and you should refer to the system\_fingerprint response parameter to</p><p>monitor changes in the backend.</p><p>Set to null for non-deterministic results.</p><p><br>Default: <code>-</code><br>Example: <code>12345</code></p> |
| User : `String`                           | <p>A unique identifier representing your end-user, which can help OpenAI to</p><p>monitor and detect abuse.</p><p><br>Default: <code>-</code><br>Example: <code>User12345</code></p>                                                                                                                                                                                                                                                                                 |
| ThrowExceptionOnErrorResponse : `Boolean` | <p>Whether to throw an exception if the API returns an error. Otherwise</p><p>the error is returned as part of the result.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                    |
| {% endtab %}                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

{% tab title="Result: Result" %}

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ChatCompletion : `ChatCompletion` | <p>Contains the input repeated the specified number of times.<br>Example: <code>{ Id: "chatcmpl-123", Created: 1677652288, Model: "gpt-3.5-turbo-0613", SystemFingerprint: "fp\_44709d6fcb", Choices: \[ { Index: 0, Message: { Role: "assistant", Content: "\n\nHello there, how may I assist you today?" }, FinishReason: "stop" } ], Usage: { PromptTokens: 9, CompletionTokens: 12, TotalTokens: 21 } }</code></p> |
| Success : `Boolean`               | <p>Indicates whether the operation was successful.<br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                   |
| Error : `String`                  | <p>Error message, if the operation was not successful. Otherwise null.<br>Example: <code>OpenAI API call failed with status code 500 and content ...</code></p>                                                                                                                                                                                                                                                        |
| {% endtab %}                      |                                                                                                                                                                                                                                                                                                                                                                                                                        |

{% tab title="Changelog" %}

## Changelog

### \[1.1.0] - 2025-02-17

#### Changed

* Update packages:
* RestSharp 110.2.0 -> 112.1.0
* SonarAnalyzer.CSharp 9.8.0.76515 -> 10.7.0.110445
* System.ComponentModel.Annotations 4.7.0 -> 5.0.0

### \[1.0.1] - 2024-01-05

#### Changed

* Moved some input parameters to options
* Moved API key from options to input

### \[1.0.0] - 2023-12-28

#### Changed

* Initial implementation
  {% endtab %}
  {% endtabs %}
