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 start Ollama button and it functionality #158

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions src/panels/setupGranitePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { IModelServer } from '../modelServer';
import { MockServer } from '../ollama/mockServer';
import { OllamaServer } from '../ollama/ollamaServer';
import { Telemetry } from '../telemetry';
import { terminalCommandRunner } from '../terminal/terminalCommandRunner';
import { getNonce } from "../utils/getNonce";
import { getUri } from "../utils/getUri";

Expand Down Expand Up @@ -237,6 +238,14 @@ export class SetupGranitePage {
},
});
break;
case "startOllama":
await terminalCommandRunner.runInTerminal(
'ollama start',
{
name: "Start Ollama",
show: true,
}
);
case "installOllama":
await this.server.installServer(data.mode);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/terminalCommandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TerminalCommandRunner implements Disposable {
public async runInTerminal(command: string, options: ITerminalOptions): Promise<Terminal> {

let terminal: Terminal | undefined;
const name = "Granite Models Setup";
const name = options.name;
if (window.terminals.length) {
terminal = window.terminals.find(t => name === t.name);
}
Expand Down
45 changes: 32 additions & 13 deletions webviews/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ function App() {
data: {
tabModelId: UImodeTabModel,
chatModelId: chatModel,
embeddingsModelId: embeddingsModel,
},
embeddingsModelId: embeddingsModel
}
});
}

function handleStartOllama(): void {
vscode.postMessage({
command: "startOllama"
});
}

Expand Down Expand Up @@ -229,9 +235,9 @@ function App() {

uiMode === "advanced"
? (checkKeepExistingConfig =
chatModel === null && tabModel === null && embeddingsModel === null)
chatModel === null && tabModel === null && embeddingsModel === null)
: (checkKeepExistingConfig =
chatModel === null && embeddingsModel === null);
chatModel === null && embeddingsModel === null);

setIsKeepExistingConfigSelected(checkKeepExistingConfig);
setUiMode(uiMode);
Expand Down Expand Up @@ -291,12 +297,12 @@ function App() {
{installationModes.some(
(mode) => mode.supportsRefresh === true
) && (
<p>
<span>
This page will refresh once Ollama is installed.
</span>
</p>
)}
<p>
<span>
This page will refresh once Ollama is installed.
</span>
</p>
)}
{installationModes.map((mode) => (
<button
key={mode.id}
Expand All @@ -309,6 +315,19 @@ function App() {
))}
</div>
)}

{
// show start ollama button when server stopped
serverStatus === ServerStatus.stopped && (
<button
className="install-button"
onClick={() => handleStartOllama()}
>
Start Ollama
</button>
)
}

</div>
</div>

Expand Down Expand Up @@ -387,7 +406,7 @@ function App() {
</label>
</div>
</div>
{}
{ }
<button
className="install-button"
onClick={handleSetupGraniteClick}
Expand All @@ -404,8 +423,8 @@ function App() {

<div className="info-message">
<p>
* To reopen this wizard, open the command palette and run:
<p style={{ margin: 2, paddingLeft: 10 }}><strong>Paver: Setup Granite as code assistant</strong></p>
* To reopen this wizard, open the command palette and run:
<p style={{ margin: 2, paddingLeft: 10 }}><strong>Paver: Setup Granite as code assistant</strong></p>
</p>
{uiMode === "simple" ? (
<p>
Expand Down