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

added open ai base url to client settings #474

Merged
merged 1 commit into from
Mar 19, 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
25 changes: 22 additions & 3 deletions src/app/clientsettings/clientsettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
commandRtnHandler(prtn, this.errorMessage);
}

@boundMethod
inlineUpdateOpenAIBaseURL(newBaseURL: string): void {
const prtn = GlobalCommandRunner.setClientOpenAISettings({ baseurl: newBaseURL });
commandRtnHandler(prtn, this.errorMessage);
}

@boundMethod
setErrorMessage(msg: string): void {
mobx.action(() => {
Expand Down Expand Up @@ -232,7 +238,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
</div>
</div>
<div className="settings-field">
<div className="settings-label">OpenAI Token</div>
<div className="settings-label">AI Token</div>
<div className="settings-input">
<InlineSettingsTextEdit
placeholder=""
Expand All @@ -245,7 +251,20 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
</div>
</div>
<div className="settings-field">
<div className="settings-label">OpenAI Model</div>
<div className="settings-label">AI Base URL</div>
<div className="settings-input">
<InlineSettingsTextEdit
placeholder=""
text={isBlank(openAIOpts.baseurl) ? "openai default" : openAIOpts.baseurl}
value={openAIOpts.baseurl ?? ""}
onChange={this.inlineUpdateOpenAIBaseURL}
maxLength={10}
showIcon={true}
/>
</div>
</div>
<div className="settings-field">
<div className="settings-label">AI Model</div>
<div className="settings-input">
<InlineSettingsTextEdit
placeholder="gpt-3.5-turbo"
Expand All @@ -258,7 +277,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
</div>
</div>
<div className="settings-field">
<div className="settings-label">OpenAI MaxTokens</div>
<div className="settings-label">AI MaxTokens</div>
<div className="settings-input">
<InlineSettingsTextEdit
placeholder=""
Expand Down
10 changes: 9 additions & 1 deletion src/models/commandrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ class CommandRunner {
return GlobalModel.submitCommand("client", "set", null, kwargs, interactive);
}

setClientOpenAISettings(opts: { model?: string; apitoken?: string; maxtokens?: string }): Promise<CommandRtnType> {
setClientOpenAISettings(opts: {
model?: string;
apitoken?: string;
maxtokens?: string;
baseurl?: string;
}): Promise<CommandRtnType> {
let kwargs = {
nohist: "1",
};
Expand All @@ -386,6 +391,9 @@ class CommandRunner {
if (opts.maxtokens != null) {
kwargs["openaimaxtokens"] = opts.maxtokens;
}
if (opts.baseurl != null) {
kwargs["openaibaseurl"] = opts.baseurl;
}
return GlobalModel.submitCommand("client", "set", null, kwargs, false);
}

Expand Down
1 change: 1 addition & 0 deletions src/types/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ declare global {
apitoken?: string;
maxtokens?: number;
maxchoices?: number;
baseurl?: string;
};

type PlaybookType = {
Expand Down
Loading