This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Configuration, OpenAIApi } from 'openai'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i openai@3.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ng g s open-ai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { environment } from '../environments/environment'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Project files | |
/src/environments/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const environment = { | |
production: false, | |
apiKey: 'api-key' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import { Configuration, OpenAIApi } from 'openai'; | |
import './Chat.css' | |
function Chat() { | |
const [newMsg, setNewMsg] = useState(''); | |
const [countMsg, setCountMsg]= useState(0); | |
const [msg, setMsg]= useState({'me': [], 'bot': []}) | |
const configuration = new Configuration({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Chat() { | |
const [newMsg, setNewMsg] = useState(''); | |
const [countMsg, setCountMsg]= useState(0); | |
const [msg, setMsg]= useState({'me': [], 'bot': []}) | |
const configuration = new Configuration({ | |
apiKey: process.env.REACT_APP_OPENAI_API_KEY, | |
}); | |
const openai = new OpenAIApi(configuration); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import { Configuration, OpenAIApi } from 'openai'; | |
import './Chat.css' | |
function Chat() { | |
// variables d'états qui stockent le message à envoyer, le nombre de messages envoyés et le dernier message combiné à la réponse du bot. | |
const [newMsg, setNewMsg] = useState(''); | |
const [countMsg, setCountMsg]= useState(0); | |
const [msg, setMsg]= useState({'me': [], 'bot': []}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import { Configuration, OpenAIApi } from 'openai'; | |
import './Chat.css' |