Skip to content

Commit b49e292

Browse files
update the api_key to use the system enviroment, update for gpt-4 and readme update
1 parent 4ebb1be commit b49e292

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

my-chatbot.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from openai import OpenAI
22
import os
33

4-
client = OpenAI(
5-
api_key="YOUR-API-KEY"
6-
)
4+
# Load the API key from an environment variable
5+
api_key = os.getenv("OPENAI_API_KEY")
6+
if not api_key:
7+
raise ValueError("No OpenAI API key found. Set the OPENAI_API_KEY environment variable.")
8+
9+
client = OpenAI(api_key=api_key)
710

811

912
def chat_with_gpt(prompt):
@@ -14,7 +17,7 @@ def chat_with_gpt(prompt):
1417
"content": prompt,
1518
}
1619
],
17-
model="gpt-3.5-turbo",
20+
model="gpt-4",
1821
)
1922

2023
return response.choices[0].message.content.strip()

readme.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# my-chatboot
22

33
## Overview
4-
This project integrates OpenAI's GPT technology to create an interactive chatbot. As of the last update, the code is compatible with the latest version of ChatGPT, ensuring up-to-date interactions and features.
4+
This project I show how to integrate GPT-4 in a python project as a chatbot. I'll be implementing upload and files generations by prompt in the chatbot.
55

66
## Features
77
- Interactive ChatGPT-based chatbot.
@@ -28,5 +28,11 @@ python my-chatbot.py
2828
### Using ChatGpt 4
2929
To use chatgpt 4 instead 3.5 you need to change this part of code:
3030
```
31-
model="gpt-4.0-turbo", # Updated to ChatGPT-4 model
31+
model="gpt-4-vision-preview", # Updated to ChatGPT-4 model
32+
```
33+
34+
### Using ChatGpt 3.5
35+
To use chatgpt 4 instead 3.5 you need to change this part of code:
36+
```
37+
model="gpt-3.5-turbo", # Updated to ChatGPT-3.5 model
3238
```

0 commit comments

Comments
 (0)