Skip to content
Open
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
16 changes: 16 additions & 0 deletions components/components/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ function SettingsDialog({ settings, setSettings, openDialog, setOpenDialog }: Pr
<RadioGroupItem value="gemini" id="gemini-llm"/>
</Label>
</RadioGroup>
<div>
<Label >
Model Name (optional)
</Label>
<Input
id="model-name"
placeholder="Model Name"
value={settings?.modelName || ""}
onChange={(e) =>
setSettings({
...settings,
modelName: e.target.value,
})
}
/>
</div>
</div>
{
settings.llm === 'openai' ? (
Expand Down
1 change: 1 addition & 0 deletions components/contexts/SettingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const initialValue = {
init: false,
llm: 'openai',
geminiApiKey: '',
modelName: '',
},
initCreate: false,
setSettings: () => {},
Expand Down
1 change: 1 addition & 0 deletions components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Settings {
init: boolean;
llm: string;
geminiApiKey: string;
modelName: string | null;
}

export enum AppState {
Expand Down
2 changes: 2 additions & 0 deletions service/events/generateCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IGenerateCodeParams {
llm: string;
geminiApiKey: string;
slug?: string;
modelName: string;
}

const encoder = new TextEncoder();
Expand Down Expand Up @@ -118,6 +119,7 @@ export async function streamGenerateCode(
openAiBaseURL: params.openAiBaseURL,
llm: params.llm, // 'Gemini'
geminiApiKey: params.geminiApiKey,
modelName: params.modelName,
},
);
} catch (e) {
Expand Down
12 changes: 11 additions & 1 deletion service/events/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ async function useGeminiResponse([messages, callback, params]: Parameters<
modelType = "gemini-pro-vision"
}

if (params.modelName) {
modelType = params.modelName
}

const model = genAI.getGenerativeModel({ model: modelType});

const result = await model.generateContentStream({
Expand Down Expand Up @@ -133,6 +137,7 @@ export async function streamingOpenAIResponses(
openAiBaseURL: any;
llm: string;
geminiApiKey: any;
modelName: any;
}
) {

Expand All @@ -153,8 +158,13 @@ export async function streamingOpenAIResponses(
'https://api.openai.com/v1',
});

let modelName = 'gpt-4-vision';
if (params.modelName) {
modelName = params.modelName;
}

const stream = await openai.chat.completions.create({
model: 'gpt-4-vision-preview',
model: modelName,
temperature: 0,
max_tokens: 4096,
messages,
Expand Down