Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chatgpt extension #12081

Merged
merged 7 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extensions/chatgpt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [Feature] - 2024-04-30

- Feature: add `Summarize` command to summarize website and YouTube video
- Refactor: model dropdown save model switch `localstorage` to `cache`

## [Feature] - 2024-04-09

- Feature: Support custom model name in `Models` (Enable in preferences)
Expand Down
141 changes: 69 additions & 72 deletions extensions/chatgpt/package-lock.json

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

33 changes: 29 additions & 4 deletions extensions/chatgpt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@
"subtitle": "ChatGPT",
"description": "Collection of your custom and default model",
"mode": "view"
},
{
"name": "summarize",
"title": "Summarize Website",
"subtitle": "ChatGPT",
"description": "Summarize Website and YouTube video",
"mode": "view",
"preferences": [
{
"name": "promptTemplate",
"description": "Template support {{content}} tag, and it will replace with the content",
"type": "file",
"title": "Prompt template for the website",
"required": false
},
{
"name": "promptTemplate2",
"description": "Template support {{content}} tag, and it will replace with the video transcript",
"type": "file",
"title": "Prompt template for the YouTube",
"required": false
}
]
}
],
"keywords": [
Expand Down Expand Up @@ -246,14 +269,16 @@
}
],
"dependencies": {
"@raycast/api": "^1.48.8",
"@raycast/utils": "^1.5.2",
"@raycast/api": "^1.72.1",
"@raycast/utils": "^1.14.1",
"@types/uuid": "^9.0.0",
"cross-fetch": "^4.0.0",
"csv-parse": "^5.5.3",
"openai": "^4.24.3",
"openai": "^4.40.0",
"proxy-agent": "^6.3.1",
"say": "^0.16.0",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"youtube-transcript": "^1.2.1"
},
"devDependencies": {
"@raycast/eslint-config": "^1.0.5",
Expand Down
15 changes: 12 additions & 3 deletions extensions/chatgpt/src/ask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ import { ChatView } from "./views/chat";
import { ModelDropdown } from "./views/model/dropdown";
import { QuestionForm } from "./views/question/form";

export default function Ask(props: { conversation?: Conversation }) {
export default function Ask(props: { conversation?: Conversation; initialQuestion?: string }) {
const conversations = useConversations();
const models = useModel();
const savedChats = useSavedChat();
const isAutoSaveConversation = useAutoSaveConversation();
const chats = useChat<Chat>(props.conversation ? props.conversation.chats : []);
const question = useQuestion({ initialQuestion: "", disableAutoLoad: props.conversation ? true : false });
const question = useQuestion({ initialQuestion: "", disableAutoLoad: !!props.conversation });

useEffect(() => {
// only work on `Summarize -> Ask` flow
if (props.initialQuestion) {
chats.ask(props.initialQuestion, props.conversation!.model);
}
}, []);

const [conversation, setConversation] = useState<Conversation>(
props.conversation ?? {
Expand Down Expand Up @@ -50,7 +57,9 @@ export default function Ask(props: { conversation?: Conversation }) {
const { push, pop } = useNavigation();

useEffect(() => {
if (!isAutoFullInput) {
if (props.initialQuestion || !isAutoFullInput) {
// `initialQuestion` only set from Summarize.tsx page
// `isAutoFullInput` is set from preferences
setLoading(false);
return;
}
Expand Down
Loading