Skip to content

Commit

Permalink
♻️ refactor: Remove "timeout" configuration option from Config compon…
Browse files Browse the repository at this point in the history
…ent and constants

The "timeout" configuration option was no longer being used in the
genAiCommit utility function, so it was removed from the Config component
and the config constants. This refactor improves code cleanliness and
removes unnecessary configuration.
  • Loading branch information
canisminor1990 committed Jul 10, 2023
1 parent d890d71 commit 377b344
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
20 changes: 0 additions & 20 deletions src/commands/Config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const Config = memo(() => {
const githubTokenConfig: string | any = configStore.get(CONFIG_NAME.GITHUB_TOKEN);
const promptConfig: string | any = configStore.get(CONFIG_NAME.PROMPT);
const maxLengthConfig: number | any = configStore.get(CONFIG_NAME.MAX_LENGTH);
const timeoutConfig: number | any = configStore.get(CONFIG_NAME.TIMEOUT);
const localeConfig: number | any = configStore.get(CONFIG_NAME.LOCALE);
const diffChunkSize: number | any = configStore.get(CONFIG_NAME.DIFF_CHUNK_SIZE);

Expand Down Expand Up @@ -92,12 +91,6 @@ const Config = memo(() => {
),
value: CONFIG_NAME.API_BASE_URL,
},
{
label: (
<ConfigTitle badge={timeoutConfig + 'ms'} color={theme.colorText} title="OpenAI timeout" />
),
value: CONFIG_NAME.TIMEOUT,
},
{
label: (
<ConfigTitle
Expand Down Expand Up @@ -215,19 +208,6 @@ const Config = memo(() => {
key: CONFIG_NAME.API_BASE_URL,
title: '🤯 OpenAI API Proxy Config',
},
{
children: (
<TextInput
defaultValue={String(timeoutConfig)}
onSubmit={(v) => {
updateConfig(CONFIG_NAME.TIMEOUT, Number(v));
}}
placeholder="The timeout for network requests to the OpenAI API in milliseconds, default 10000..."
/>
),
key: CONFIG_NAME.TIMEOUT,
title: '🤯 OpenAI Timeout Config',
},
{
children: (
<TextInput
Expand Down
5 changes: 0 additions & 5 deletions src/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const CONFIG_NAME = {
MAX_LENGTH: 'maxLength',
OPENAI_TOKEN: 'openaiToken',
PROMPT: 'prompt',
TIMEOUT: 'timeout',
};

const schema = {
Expand Down Expand Up @@ -41,10 +40,6 @@ const schema = {
default: 100,
type: 'number',
},
[CONFIG_NAME.TIMEOUT]: {
default: 10_000,
type: 'number',
},
[CONFIG_NAME.DIFF_CHUNK_SIZE]: {
default: 1000,
type: 'number',
Expand Down
11 changes: 5 additions & 6 deletions src/utils/genAiCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import gitmojis from '../constants/gitmojis';
import template from './template';

const diffChunkSize: number | any = storeConfig.get(CONFIG_NAME.DIFF_CHUNK_SIZE) || 1000;
const timeout: number | any = storeConfig.get(CONFIG_NAME.TIMEOUT) || 10_000;
// const timeout: number | any = storeConfig.get(CONFIG_NAME.TIMEOUT) || 10_000;
const basePath: string | any = storeConfig.get(CONFIG_NAME.API_BASE_URL);
const openAIApiKey: string | any = storeConfig.get(CONFIG_NAME.OPENAI_TOKEN);
const addEmoji = (message: string) => {
Expand All @@ -36,23 +36,22 @@ export default async () => {
maxRetries: 10,
openAIApiKey,
temperature: 0.5,
timeout,
},
{
basePath,
},
);

console.time(' ✅ Split diff info');
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: diffChunkSize });
const diffDocument = await textSplitter.createDocuments([diff]);
console.timeEnd(' ✅ Split diff info');
console.time(' ✅ Generate diff summary');
const chain = loadSummarizationChain(chat, { type: 'map_reduce' });
const diffSummary = await chain.call({
input_documents: diffDocument,
timeout,
});

if (!diffSummary['text']) throw new Error('🤯 Diff summary failed');

console.timeEnd(' ✅ Generate diff summary');
const res = await chat.call([
new SystemMessage(template),
new HumanMessage(
Expand Down

0 comments on commit 377b344

Please sign in to comment.