Skip to content

Commit

Permalink
Update ai-humanizer extension (#15383)
Browse files Browse the repository at this point in the history
* Update ai-humanizer extension

- docs: release new version
- Merge branch \'contributions/merge-1731663833996344000\'
- Pull contributions
- chore: added api key
- Rephrasyai patch (#4)
- chore: fixed linting
- fix: changed API
- Merge branch \'contributions/merge-1715997763328086000\'
- Pull contributions
- feat: added screenshot via raycast\'s window capture
- fix: linting
- initial commit
- Initial commit

* chore: updated lock file

* fix: any -> unknown
  • Loading branch information
frolvanya authored Nov 15, 2024
1 parent 8a1cf5c commit 957afe5
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 59 deletions.
4 changes: 4 additions & 0 deletions extensions/ai-humanizer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# AI Humanizer Changelog

## [Fixes] - 2024-11-15

- Changed API to [Rephrasy](https://rephrasy.ai)

## [Fixes] - 2024-05-17

- Fixed API
Expand Down
3 changes: 3 additions & 0 deletions extensions/ai-humanizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

This Raycast extension allows you to easily humanize text using an AI-powered service. Simply paste your original text, click the "Humanize" button, and the humanized result will be displayed. You can then copy the humanized text to the clipboard with a single shortcut.

## API Keys
To get API Keys for this extension please head over to [Rephrasy](https://rephrasy.ai) and create an account.

## Features

- **Humanization**: Utilize an external API to humanize the provided text.
Expand Down
42 changes: 29 additions & 13 deletions extensions/ai-humanizer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 42 additions & 33 deletions extensions/ai-humanizer/package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
{
"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "ai-humanizer",
"title": "Humanize AI Text",
"description": "Humanize AI Text",
"icon": "command-icon.png",
"author": "frolik",
"license": "MIT",
"commands": [
{
"name": "index",
"title": "AI Humanizer",
"description": "Humanize AI Text",
"mode": "view"
}
],
"dependencies": {
"@raycast/api": "^1.66.1",
"axios": "^1.6.7"
},
"devDependencies": {
"@raycast/eslint-config": "^1.0.6",
"@types/node": "20.8.10",
"@types/react": "18.2.27",
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
"scripts": {
"build": "ray build -e dist",
"dev": "ray develop",
"fix-lint": "ray lint --fix",
"lint": "ray lint",
"publish": "npx @raycast/api@latest publish"
"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "ai-humanizer",
"title": "Humanize AI Text",
"description": "Humanize AI Text",
"icon": "command-icon.png",
"author": "frolik",
"license": "MIT",
"commands": [
{
"name": "index",
"title": "AI Humanizer",
"description": "Humanize AI Text",
"mode": "view"
}
],
"dependencies": {
"@raycast/api": "^1.85.1",
"axios": "^1.6.7"
},
"devDependencies": {
"@raycast/eslint-config": "^1.0.6",
"@types/node": "20.8.10",
"@types/react": "18.2.27",
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
"preferences": [
{
"name": "apiKey",
"type": "password",
"title": "API Key",
"description": "Enter your Rephrasy.ai API key",
"required": true
}
],
"scripts": {
"build": "ray build -e dist",
"dev": "ray develop",
"fix-lint": "ray lint --fix",
"lint": "ray lint",
"publish": "npx @raycast/api@latest publish"
}
}
60 changes: 47 additions & 13 deletions extensions/ai-humanizer/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,66 @@
import { Form, ActionPanel, Action, showToast, Icon } from "@raycast/api";
import { Form, ActionPanel, Action, showToast, Icon, getPreferenceValues, Toast } from "@raycast/api";
import { useState } from "react";

import axios from "axios";

interface Values {
originalText: string;
humanizedText: string;
model: string;
}

interface Preferences {
apiKey: string;
}

export default function Command() {
const [humanizedText, setHumanizedText] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false);

async function humanize(text: string): Promise<string | undefined> {
const preferences = getPreferenceValues<Preferences>();
const apiKey = preferences.apiKey;

async function humanize(text: string, model: string): Promise<string | undefined> {
try {
const url = "https://aitohumanconverter.com/v2/process.php";
const data = `text=${text}`;
const url = "https://v1-humanizer.rephrasy.ai/api";
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
};
const data = {
text: text,
model: model,
};

const response = await axios.post(url, data);
const response = await axios.post(url, data, { headers });

showToast({ title: "Text Humanized", message: "Text successfully humanized!" });

return response.data.data;
} catch (error) {
showToast({ title: "Error", message: "Failed to humanize text" });
console.log("API Response:", response.data);

return response.data.output;
} catch (error: unknown) {
console.error("Error in humanize function:", error);
showToast({
style: Toast.Style.Failure,
title: "Error",
message: "Failed to humanize text",
});
}
}

const handleSubmit = async (values: Values) => {
if (!apiKey) {
showToast({
style: Toast.Style.Failure,
title: "API Key Missing",
message: "Please set your API key in the extension preferences.",
});
return;
}

setLoading(true);
setHumanizedText((await humanize(values.originalText)) || "");
const result = await humanize(values.originalText, values.model);
console.log("Humanized Text Result:", result);
setHumanizedText(result || "");
setLoading(false);
};

Expand All @@ -39,15 +70,18 @@ export default function Command() {
actions={
<ActionPanel>
<Action.SubmitForm title="Humanize" icon={Icon.Wand} onSubmit={handleSubmit} />
{humanizedText.length > 0 && <Action.CopyToClipboard content={humanizedText} />}
</ActionPanel>
}
>
<Form.TextArea autoFocus={true} id="originalText" title="Original Text" />
<Form.Dropdown id="model" title="Model" defaultValue="undetectable">
<Form.Dropdown.Item value="undetectable" title="Undetectable" />
<Form.Dropdown.Item value="SEO Model" title="SEO" />
</Form.Dropdown>
{humanizedText && (
<>
<Form.Separator />
<Form.TextArea id="humanizedText" onChange={() => {}} title="Humanized Text" value={humanizedText} />
<Form.TextArea id="humanizedText" title="Humanized Text" value={humanizedText} />
</>
)}
</Form>
Expand Down

0 comments on commit 957afe5

Please sign in to comment.