|
10 | 10 | * |
11 | 11 | * Author: AvantMaker <admin@avantmaker.com> |
12 | 12 | * Author Website: https://www.AvantMaker.com |
13 | | - * Date: May 8, 2025 |
14 | | - * Version: 1.0.3 |
| 13 | + * Date: May 15, 2025 |
| 14 | + * Version: 1.0.7 |
15 | 15 | * |
16 | 16 | * Hardware Requirements: |
17 | 17 | * - ESP32-based microcontroller (e.g., ESP32 DevKitC, DOIT ESP32 DevKit) |
|
29 | 29 | * Repository: https://github.com/AvantMaker/ESP32_AI_Connect |
30 | 30 | * |
31 | 31 | * Usage Notes: |
32 | | - * - Adjust `setChatSystemRole`, `setChatTemperature`, and `setChatMaxTokens` in `setup()` to customize AI behavior. |
| 32 | + * - Adjust optional parameters with `setChatSystemRole`, `setChatTemperature`, and `setChatMaxTokens` in `setup()` to customize AI behavior. |
33 | 33 | * - Use getter methods like `getChatSystemRole`, `getChatTemperature`, and `getChatMaxTokens` to retrieve current settings. |
34 | 34 | * - Enter messages via the Serial Monitor to interact with the AI; responses are displayed with error details if applicable. |
35 | 35 | * |
@@ -73,20 +73,30 @@ void setup() { |
73 | 73 | while(1) delay(1000); // Halt on failure |
74 | 74 | } |
75 | 75 |
|
76 | | - // --- Configure the AI Client --- |
| 76 | + // --- Configure the AI Client's optional parameters --- |
77 | 77 | aiClient.setChatSystemRole("You are a helpful assistant."); |
78 | 78 | aiClient.setChatTemperature(0.7); // Set creativity/randomness |
79 | 79 | aiClient.setChatMaxTokens(150); // Limit response length |
80 | | - |
81 | | - // Display configuration settings |
82 | | - Serial.println("\nAI Client Configuration:"); |
| 80 | + // You can set optional custom parameters with setChatParameters() |
| 81 | + // Note that if a parameter is already set by a method above, it will NOT be overwritten |
| 82 | + if (aiClient.setChatParameters(R"({"top_p":0.95})")){ |
| 83 | + Serial.println("Request Parameters Set Successfully"); |
| 84 | + Serial.print("Custom Parameters: "); |
| 85 | + Serial.println(aiClient.getChatParameters()); |
| 86 | + } else { |
| 87 | + Serial.println("Setting Request Parameters Failed"); |
| 88 | + Serial.println("Error details: " + aiClient.getLastError()); |
| 89 | + } |
| 90 | + |
| 91 | +// Display the configured parameters set by setChatSystemRole/setChatTemperature/setChatMaxTokens |
| 92 | + Serial.println("\nDisplay the configured parameters set by"); |
| 93 | + Serial.println("\nsetChatSystemRole / setChatTemperature / setChatMaxTokens:"); |
83 | 94 | Serial.print("System Role: "); |
84 | 95 | Serial.println(aiClient.getChatSystemRole()); |
85 | 96 | Serial.print("Temperature: "); |
86 | 97 | Serial.println(aiClient.getChatTemperature()); |
87 | 98 | Serial.print("Max Tokens: "); |
88 | 99 | Serial.println(aiClient.getChatMaxTokens()); |
89 | | - Serial.println("Ready to chat!"); |
90 | 100 | } |
91 | 101 |
|
92 | 102 | void loop() { |
|
0 commit comments