Skip to content

Commit

Permalink
Allow empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Mahar committed Aug 29, 2024
1 parent 822e351 commit 4e138a9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/components/AIModelInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ export const defaultOpenAiModelInfos: AIModelInfo[] = [
costPer1kInput: 0.01,
costPer1kOutput: 0.03,
},
{
id: 'gpt-4o',
name: 'GPT-4 Omni 128K',
maxTokens: 128000,
costPer1kInput: 0.005,
costPer1kOutput: 0.015,
},
{
id: 'gpt-4o-mini',
name: 'GPT-4 Omni Mini 128K',
maxTokens: 128000,
costPer1kInput: 0.00015,
costPer1kOutput: 0.0006,
},
];
4 changes: 2 additions & 2 deletions src/components/AITextProcessor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const AITextProcessor = ({ ...props }: AITextProcessorProps) => {

const processChunk = (chunkIndex: number) => {
const chunk = chunks[chunkIndex];
if (chunk) {
if (typeof chunk === 'string') {
setCurrentChunkIndex(chunkIndex);
processingRef.current = true;
setRenderTime(Date.now());
Expand Down Expand Up @@ -581,7 +581,7 @@ export const AITextProcessor = ({ ...props }: AITextProcessorProps) => {
const canSave = !!presetName.trim() && (hasMeaningfulChanges || hasSuperfluousChanges);
const canReset = !!selectedPreset && canSave;
const configured = !!openAiModel && !!userPrompt;
const canExecute = configured && !!input;
const canExecute = configured;
const hasInput = (input ?? '').length > 0;

return (
Expand Down
7 changes: 6 additions & 1 deletion src/components/TextUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ export class TextUtils {
chunkWordCount = 0;
}
}
if (chunkBuffer.length > 0) {

if (
chunkBuffer.length > 0 ||
// Allow empty inputs
input.trim() === ''
) {
chunks.push(chunkBuffer);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/useLocalSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const LocalSettingsDefaults = {
[LocalSettingsKeys.presets]: defaultPresetsMap,
[LocalSettingsKeys.selectedPresetName]: '',
[LocalSettingsKeys.customOpenAiModelInfos]: [] as AIModelInfo[],
[LocalSettingsKeys.defaultOpenAiModel]: 'gpt-3.5-turbo',
[LocalSettingsKeys.defaultOpenAiModel]: 'gpt-4o',
[LocalSettingsKeys.presetName]: '',
[LocalSettingsKeys.presetDescription]: '',
[LocalSettingsKeys.openAiModel]: defaultAiModelOption,
Expand Down

0 comments on commit 4e138a9

Please sign in to comment.