Skip to content

Commit

Permalink
Merge pull request #3 from HoseaCodes/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
HoseaCodes authored Aug 3, 2023
2 parents 94a7f52 + ddd92d7 commit 66a7eb6
Show file tree
Hide file tree
Showing 17 changed files with 2,472 additions and 3,117 deletions.
5,012 changes: 2,047 additions & 2,965 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "blog",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@sentry/react": "^6.13.3",
"@sentry/tracing": "^6.13.3",
"@testing-library/jest-dom": "^5.14.1",
Expand Down Expand Up @@ -41,19 +41,15 @@
"mongoose": "^5.13.7",
"morgan": "^1.10.0",
"node-cache": "^5.1.2",
"node-sass": "^6.0.1",
"openai": "^3.2.1",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-card-with-image": "^1.1.3",
"react-dom": "^17.0.2",
"react-fontawesome": "^1.7.1",
"react-html-parser": "^2.0.2",
"react-icons": "^4.2.0",
"react-loading-skeleton": "^3.2.0",
"react-markdown": "^7.0.0",
"react-masonry-css": "^1.0.16",
"react-paypal-express-checkout": "^1.0.5",
"react-reactions": "^0.1.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
Expand Down Expand Up @@ -82,7 +78,7 @@
"build:dev": "env-cmd -e dev react-scripts build",
"build:qa": "env-cmd -e staging react-scripts build",
"build:prod": "env-cmd -e production react-scripts build",
"build": "react-scripts build",
"build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"analyze": "source-map-explorer 'build/static/js/*.js'"
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Article/MainContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {NamePlate, WarppedDate, GrayText, DisplayItem, BlogTitle, BlogSubTitle,
import {ArticleHr} from '../../Layout/Hr/styledHr';
import {AlertP} from '../../Layout/Paragraph/styledParagraph';
import {AlertLink} from '../../Layout/ATag/styledATag';
import TextToSpeech from './TextToSpeech';
import marked from 'marked';
import Newsletter from '../Subscribe/Newsletter';
import RelatedPosts from './RelatedPosts';
Expand Down Expand Up @@ -47,7 +48,7 @@ const MainContainer = (props) => {
<span>&nbsp;&#183;&nbsp;</span>
<DisplayItem>{readTime} min read &nbsp; <AiFillStar/></DisplayItem>
<span>&nbsp;&#183;&nbsp;</span>
<DisplayItem Green><AiFillPlayCircle style={{fontSize: 'larger'}}/> &nbsp; Listen</DisplayItem>
<TextToSpeech text={markdown} />
</WarppedDate>
</div>
</JustifyContent>
Expand Down
77 changes: 77 additions & 0 deletions src/Components/Article/TextToSpeech.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { useState, useEffect } from "react";
import { DisplayItem } from '../../Layout/Text/styledText';
import { AiFillPlayCircle, AiFillPauseCircle, AiFillStop } from 'react-icons/ai';

const TextToSpeech = ({ text }) => {
const [isPaused, setIsPaused] = useState(false);
const [utterance, setUtterance] = useState(null);

useEffect(() => {
const synth = window.speechSynthesis;
const u = new SpeechSynthesisUtterance(text);

setUtterance(u);
setIsPaused(true)

return () => {
synth.cancel();
};
}, [text]);

const handlePlay = () => {
const synth = window.speechSynthesis;
const voices = synth.getVoices();

utterance.voice = voices[15];
utterance.rate = 0.95;

if (isPaused) {
synth.resume();
}

synth.speak(utterance);

setIsPaused(false);
};

const handlePause = () => {
const synth = window.speechSynthesis;

synth.pause();

setIsPaused(true);
};

const handleStop = () => {
const synth = window.speechSynthesis;

synth.cancel();

setIsPaused(true);
};

return (
<div style={{display: 'flex'}}>
{
isPaused ?
<DisplayItem Green onClick={handlePlay}>
<AiFillPlayCircle style={{fontSize: 'larger'}}/>
&nbsp; {isPaused ? "Listen" : "Resume"}
</DisplayItem>
:
<DisplayItem Green onClick={handlePause}>
<AiFillPauseCircle style={{fontSize: 'larger'}}/>
&nbsp; Pause
</DisplayItem>

}
&nbsp;&nbsp;
<DisplayItem Red onClick={handleStop}>
<AiFillStop style={{fontSize: 'larger'}}/>
&nbsp; Stop
</DisplayItem>
</div>
);
};

export default TextToSpeech;
187 changes: 186 additions & 1 deletion src/Components/OpenAI/SelectionOptions.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,196 @@
import React from 'react'
import { arrayItems } from "../../utils/AIOptions";
// import { arrayItems } from "../../utils/AIOptions.jsx";

function OptionSelection({ selectOption, setInput }) {
const handleClick = (item) => {
selectOption(item.option)
setInput(item.description)
}
const arrayItems = [
{
name: "Q&A",
id: "q&a",
description: "Answer questions based on existing knowledge",
option: {
model: "text-davinci-003",
temperature: 0,
max_tokens: 100,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Grammer Correction",
id: "grammerCorrection",
description: "Corrects sentences into standard English.",
option: {
model: "text-davinci-003",
temperature: 0,
max_tokens: 100,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Summarize for a 2nd grader",
id: "summary",
description: "Translates difficult text into simpler concepts.",
option: {
model: "text-davinci-003",
temperature: 0.7,
max_tokens: 64,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
// {
// name: "English to Other languages",
// id: "translate",
// description: "Translates English text into French, Spanish and Japanese.",
// option: {
// model: "text-davinci-003",
// temperature: 0.3,
// max_tokens: 100,
// top_p: 1.0,
// frequency_penalty: 0.0,
// presence_penalty: 0.0,
// },
// },
// {
// name: "Movie to Emoji",
// id: "movieToEmoji",
// description: "Convert movie titles into emoji.",
// option: {
// model: "text-davinci-003",
// temperature: 0,
// max_tokens: 100,
// top_p: 1,
// frequency_penalty: 0.0,
// presence_penalty: 0.0,
// },
// },
{
name: "Calculate Time Complexity",
id: "calculateTimeComplexity",
description: "Find the time complexity of a function.",
option: {
model: "text-davinci-003",
temperature: 0,
max_tokens: 64,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Explain code",
id: "explainCode",
description: "Explain a complicated piece of code.",
option: {
model: "code-davinci-002",
temperature: 0,
max_tokens: 64,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "SQL request",
id: "SQLRequest",
description: "Create simple SQL queries.",
option: {
model: "text-davinci-003",
temperature: 0.3,
max_tokens: 60,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Ad from product description",
id: "adFromProductDescription",
description: "Turn a product description into ad copy.",
option: {
model: "text-davinci-003",
temperature: 0.5,
max_tokens: 100,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Third-person converter",
id: "Third-personConverter",
description: "Converts first-person POV to the third-person. This is modified from a community prompt to use fewer examples.",
option: {
model: "text-davinci-003",
temperature: 0,
max_tokens: 60,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Notes to summary",
id: "NotesToSummary",
description: "Turn meeting notes into a summary.",
option: {
model: "text-davinci-003",
temperature: 0,
max_tokens: 64,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "Chat",
id: "chat",
description: "Open ended conversation with an AI assistant.",
option: {
model: "text-davinci-003",
temperature: 0.9,
max_tokens: 150,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.6,
},
},
{
name: "Restaurant review creator",
id: "restaurantReviewCreator",
description: "Turn a few words into a restaurant review.",
option: {
model: "text-davinci-003",
temperature: 0.5,
max_tokens: 64,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
{
name: "JavaScript to Python",
id: "jstopy",
description: "Convert simple JavaScript expressions into Python.",
option: {
model: "code-davinci-002",
temperature: 0,
max_tokens: 64,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
},
},
];

return (
<>
<h1 className="heading">AI Solutions</h1>
Expand Down
16 changes: 9 additions & 7 deletions src/Components/Payment/PaypalButton.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import PaypalExpressBtn from 'react-paypal-express-checkout';
// import PaypalExpressBtn from 'react-paypal-express-checkout';

export default class PaypalButton extends React.Component {
render() {
Expand Down Expand Up @@ -55,12 +55,14 @@ export default class PaypalButton extends React.Component {
}

return (
<PaypalExpressBtn
style={style}
env={env} client={client}
currency={currency} total={total}
onError={onError} onSuccess={onSuccess}
onCancel={onCancel} />
<>
</>
// <PaypalExpressBtn
// style={style}
// env={env} client={client}
// currency={currency} total={total}
// onError={onError} onSuccess={onSuccess}
// onCancel={onCancel} />
);
}
}
29 changes: 29 additions & 0 deletions src/Components/SImpleForm/simpleForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { Component } from 'react';
import Container from 'react-bootstrap/Container';
import Form from 'react-bootstrap/Form';

class SimpleForm extends Component {
render() {
return (
<Container>
<Form>
<Form.Group controlId="form.Name">
<Form.Label>Name</Form.Label>
<Form.Control type="text" placeholder="Enter name" />
</Form.Group>
<Form.Group controlId="form.Email">
<Form.Label>Email address</Form.Label>
<Form.Control type="email" placeholder="[email protected]" />
</Form.Group>
<Form.Group controlId="form.Textarea">
<Form.Label>Comment</Form.Label>
<Form.Control as="textarea" rows={3} />
</Form.Group>
</Form>
</Container>
);
}

}

export default SimpleForm
Loading

0 comments on commit 66a7eb6

Please sign in to comment.