Closed LYB030 closed 1 year ago
is now works with change below code
/*
* Project ChatGPT Client For ESP32
* Description: For HTTPS connection using WiFiClientSecure
* Author: Eric Nam
* Date: 04-02-2023
*/
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
#include "WiFiS3.h"
#include "DHT.h"
#include "WiFiSSLClient.h"
static const char *ssid = "B746 Hyperoptic Fibre 2.4";
static const char *password = "fwo541888";
WiFiSSLClient client;
ChatGPT<WiFiSSLClient> chat_gpt(&client, "v1", "<OpenAI_API_KEY>");
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi network: ");
Serial.print(ssid);
Serial.println("'...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting...");
delay(500);
}
Serial.println("Connected!");
// Ignore SSL certificate validation
String result;
Serial.println("[ChatGPT] Only print a content message");
if (chat_gpt.simple_message("gpt-3.5-turbo-0301", "user", "Planning a 3-day trip to San Diego", result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
Serial.println("\n\n[ChatGPT] Print full message(JSON Type)");
if (chat_gpt.full_message("gpt-3.5-turbo", "user", "What is the OpenAI mission?", result)) {
Serial.println("===OK===");
Serial.println(result);
} else {
Serial.println("===ERROR===");
Serial.println(result);
}
}
void loop() {}
but only works by using chat_gpt.full_message ,the sample is just connection faild
@LYB030 Thank you for your code. I haven't been able to test it because I don't have the UNO R4 WiFi device yet. Why doesn't simple_message in the code above work? It's the same internally. Any ideas?
hi i find that i even could not run the example