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
:nth-child(An+B [of S]?) | |
:nth-last-child(An+B [of S]?) |
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
:nth-child(2n) | |
:nth-child(2n+1) |
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
.nesting { | |
color: hotpink; | |
> .is { | |
color: rebeccapurple; | |
> .awesome { | |
color: deeppink; | |
} | |
} |
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
.nesting { | |
color: hotpink; | |
} | |
.nesting > .is { | |
color: rebeccapurple; | |
} | |
.nesting > .is > .awesome { | |
color: deeppink; |
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
<div> | |
<h1 class="title">Chat Bot with GPT</h1> | |
<div class="chat_bot" id="chat_bot"> | |
<div class="chat_bot_content-msg" id="chat_bot_content-msg"> | |
<h2 class="chat_bot-msg">Bot :</h2> | |
<p class="chat_bot-msg" *ngIf="botResponse">{{botResponse}}</p> | |
<p class="chat_bot-msg" *ngIf="!botResponse">Bonjour, Je suis un bot codé en Angular et utilisant GPT3 d'Open AI</p> | |
</div> | |
</div> | |
<form class="form"> |
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 { Component } from '@angular/core'; | |
import { OpenAiService } from '../open-ai.service' | |
@Component({ | |
selector: 'app-chat', | |
templateUrl: './chat.component.html', | |
styleUrls: ['./chat.component.scss'] | |
}) | |
export class ChatComponent { | |
newMsg: string = ''; |
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
handleClick() { | |
this.openAiService.getDataFromOpenAI(this.newMsg).subscribe(data => { | |
this.botResponse = data; | |
}); | |
this.newMsg = ''; | |
} |
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 { Component } from '@angular/core'; | |
import { FormControl } from '@angular/forms'; | |
import { OpenAiService } from '../open-ai.service' | |
@Component({ | |
selector: 'app-chat', | |
templateUrl: './chat.component.html', | |
styleUrls: ['./chat.component.scss'] | |
}) | |
export class ChatComponent { |
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
getDataFromOpenAI(text: string): Observable<string> { | |
return from(this.openai.createCompletion({ | |
model: "text-davinci-003", | |
prompt: text, | |
max_tokens: 7 | |
})).pipe( | |
filter(resp => !!resp && !!resp.data), | |
map(resp => resp.data), | |
filter((data: any) => data.choices && data.choices.length > 0 && data.choices[0].text), | |
map(data => data.choices[0].text) |
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 { Injectable } from '@angular/core'; | |
import { Configuration, OpenAIApi } from 'openai'; | |
import { environment } from '../environments/environment'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class OpenAiService { | |
constructor() { } |