Skip to content

Commit 3be6921

Browse files
authored
Update Docs.md
1 parent 8d9cd52 commit 3be6921

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

Docs.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1+
# 🤖AI Chat Library for Arduino💬
12

3+
AI Chat Library for Arduino allows you to easily integrate AI chatbot capabilities into your Arduino projects. This library supports multiple AI services, including OpenAI's ChatGPT and Hugging Face APIs, making it versatile and powerful for creating intelligent interactions.
4+
5+
## 📋 Project Overview
6+
7+
The AI Chat Library simplifies the process of connecting your Arduino projects to AI chatbots. It handles API communication, enabling your devices to send messages and receive responses from AI services over the internet.
8+
9+
## 🛠️Installation
10+
11+
1. **Download the Library**: Clone or download the repository from [GitHub](https://github.com/bayeggex/Arduino-AI-Chat-Library).
12+
13+
2. **Import into Arduino IDE**:
14+
- Open Arduino IDE.
15+
- Navigate to **Sketch > Include Library > Add .ZIP Library...** and select the downloaded ZIP file.
16+
17+
3. **Install Dependencies**:
18+
- Ensure you have the `WiFi` and `HTTPClient` libraries installed in your Arduino IDE via the Library Manager.
19+
20+
## 🚀Usage
21+
22+
### 🗝️Setting Up AI Keys
23+
24+
Before using the AI Chat Library, you need to set your API keys for the respective AI services. Here’s how you can do it in your Arduino sketch:
25+
26+
```cpp
27+
#include <AIChatbot.h>
28+
29+
AIChatbot chatbot;
30+
31+
void setup() {
32+
Serial.begin(115200);
33+
34+
// Set API keys
35+
chatbot.setKey("YOUR_CHATGPT_API_KEY", "chatgpt");
36+
chatbot.setKey("YOUR_HUGGING_FACE_API_KEY", "huggingface");
37+
38+
// Begin WiFi connection
39+
WiFi.begin("SSID", "PASSWORD");
40+
while (WiFi.status() != WL_CONNECTED) {
41+
delay(1000);
42+
Serial.println("Connecting to WiFi...");
43+
}
44+
Serial.println("Connected to WiFi");
45+
46+
// Select AI and optionally specify version
47+
chatbot.selectAI("chatgpt", "gpt-3.5-turbo");
48+
}
49+
50+
void loop() {
51+
// Update and handle incoming messages
52+
chatbot.update();
53+
}
54+
```
55+
56+
### 📄Functions
57+
58+
#### `selectAI(const String& aiName, const String& aiVersion = "gpt-3.5-turbo")`
59+
60+
- **Description**: Selects the AI service to use.
61+
- **Parameters**:
62+
- `aiName`: Name of the AI service (e.g., "chatgpt", "huggingface").
63+
- `aiVersion` (optional): Version of the AI model to use (default: "gpt-3.5-turbo").
64+
- **Example**:
65+
```cpp
66+
chatbot.selectAI("chatgpt", "gpt-4");
67+
68+
#### `setKey(const String& apiKey, const String& apiName)`
69+
70+
- **Description**: Sets the API key for a specific AI service.
71+
- **Parameters**:
72+
- `apiKey`: API key for the AI service.
73+
- `apiName` (optional): Name of the AI service (e.g., "chatgpt", "huggingface").
74+
- **Example**:
75+
```cpp
76+
chatbot.setKey("YOUR_CHATGPT_API_KEY", "chatgpt");
77+
78+
#### `send(const String& message)`
79+
80+
- **Description**: Sends a message to the selected AI service manually.
81+
- **Parameters**:
82+
- `message`: Message to send to the AI service.
83+
- **Example**:
84+
```cpp
85+
String response = chatbot.send("Hello, how are you?");
86+
Serial.println("Response from AI: " + response);
87+
88+
#### `update()`
89+
90+
- **Description**: Updates the AI Chatbot instance to handle incoming messages and maintain communication.
91+
- **Example**:
92+
```cpp
93+
void loop() {
94+
chatbot.update();
95+
}

0 commit comments

Comments
 (0)