Skip to content

Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.

Python

basic form

rgskd45687928c1b
diff --git a/ui/src/lib/api.js b/ui/src/lib/api.js
index 1d09e9f..2f11cc6 100644
--- a/ui/src/lib/api.js
+++ b/ui/src/lib/api.js
@@ -1,9 +1,9 @@
import {
- messages,
- projectList,
- modelList,
agentState,
internet,
+ messages,
+ modelList,
+ projectList,
} from "./store";
export const API_BASE_URL = "http://127.0.0.1:1337";
@@ -128,3 +128,21 @@ export async function checkInternetStatus() {
internet.set(false);
}
}
+
+export async function getSettings() {
+ const response = await fetch(`${API_BASE_URL}/api/get-settings`);
+ const data = await response.json();
+ return data.settings;
+}
+
+export async function setSettings(newSettings) {
+ const response = await fetch(`${API_BASE_URL}/api/set-settings`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(newSettings),
+ });
+ const data = await response.json();
+ return data;
+}
diff --git a/ui/src/lib/components/Sidebar.svelte b/ui/src/lib/components/Sidebar.svelte
index 91824dd..a73b984 100644
--- a/ui/src/lib/components/Sidebar.svelte
+++ b/ui/src/lib/components/Sidebar.svelte
@@ -2,9 +2,11 @@
class="flex flex-col w-20 h-dvh fixed top-0 left-0 z-10 bg-slate-950 p-4 space-y-4 items-center shadow-2xl shadow-indigo-700"
>
<div class="p-5 rounded nav-button relative">
+ <a href="/">
<button class="text-gray-400 hover:text-white flex justify-center w-full">
<i class="fas fa-home fa-lg"></i>
</button>
+ </a>
<span class="tooltip">Home</span>
</div>
<div class="p-5 rounded nav-button relative">
@@ -13,7 +15,7 @@
<i class="fas fa-cog fa-lg"></i>
</button>
</a>
- <span class="tooltip">Settings</span>
+ <span class="tooltip">Settings</span>
</div>
<div class="p-5 rounded nav-button relative">
<button class="text-gray-400 hover:text-white flex justify-center w-full">
diff --git a/ui/src/routes/settings/+page.svelte b/ui/src/routes/settings/+page.svelte
index edcddc3..35f9eaf 100644
--- a/ui/src/routes/settings/+page.svelte
+++ b/ui/src/routes/settings/+page.svelte
@@ -1,5 +1,6 @@
<script>
- import ConfigurationSettings from "../../lib/components/ConfigurationSettings.svelte";
+ import Settings from "./Settings/Settings.svelte";
+
</script>
-<div><ConfigurationSettings/></div>
\ No newline at end of file
+<div><Settings data/></div>
\ No newline at end of file
diff --git a/ui/src/routes/settings/Settings/Button.svelte b/ui/src/routes/settings/Settings/Button.svelte
new file mode 100644
index 0000000..44f227e
--- /dev/null
+++ b/ui/src/routes/settings/Settings/Button.svelte
@@ -0,0 +1,16 @@
+<script lang="ts">
+ export let isActive: boolean = undefined;
+ export let onClick: () => void = undefined;
+ export let activeText: string = undefined;
+ export let text: string;
+ export let type: "button" | "submit" | "reset" = undefined;
+</script>
+
+<button
+ class={`px-4 py-2 rounded w-full mt-2 ${isActive ? "bg-slate-800" : "bg-indigo-700"}`}
+ on:click={onClick}
+ disabled={isActive}
+ {type}
+>
+ {@html isActive ? activeText : text}
+</button>
diff --git a/ui/src/routes/settings/Settings/Input.svelte b/ui/src/routes/settings/Settings/Input.svelte
new file mode 100644
index 0000000..8339da4
--- /dev/null
+++ b/ui/src/routes/settings/Settings/Input.svelte
@@ -0,0 +1,56 @@
+<script>
+ export let type = 'text';
+ export let value = type === 'text' ? '' : null;
+ export let error = '';
+ export let label = '';
+ export let placeholder = '';
+
+ function handleInput({ target: t }) {
+ if (type === 'number') {
+ value = t.value === '' ? null : t.valueAsNumber;
+ } else {
+ value = t.value;
+ }
+ }
+ </script>
+
+
+ <label class="block">
+ {#if label}
+ <span class="block">{label}</span>
+ {/if}
+ <input
+ class="block input"
+ class:error
+ {type}
+ {placeholder}
+ {value}
+ on:input={handleInput}
+ on:input
+ on:blur
+ />
+ {#if error}
+ <span class="block error-text">{error}</span>
+ {/if}
+ </label>
+
+ <style>
+ .input {
+ border-radius: 4px;
+ padding: 6px 10px;
+ margin: 0;
+ color:black;
+ }
+
+ .block {
+ display: block;
+ }
+
+ .error {
+ border-color: #f55;
+ }
+
+ .error-text {
+ color: #f55;
+ }
+ </style>
\ No newline at end of file
diff --git a/ui/src/routes/settings/Settings/Settings.svelte b/ui/src/routes/settings/Settings/Settings.svelte
new file mode 100644
index 0000000..bb01ddf
--- /dev/null
+++ b/ui/src/routes/settings/Settings/Settings.svelte
@@ -0,0 +1,31 @@
+<script type="ts">
+ import { onMount } from "svelte";
+ import { getSettings, setSettings } from "../../../lib/api";
+ import Button from "./Button.svelte";
+ import Input from "./Input.svelte";
+ let result;
+ onMount(async () => {
+ result = await getSettings();
+ console.log(result);
+ });
+
+ async function handleSubmit() {
+ const postResult = await setSettings(result);
+ console.log(postResult);
+ }
+</script>
+
+<form on:submit|preventDefault={handleSubmit}>
+ <p>API_KEYS</p>
+ {#if result}
+ <div class="pl-4">
+ <Input
+ label="CLAUDE"
+ type="text"
+ bind:value={result["API_KEYS"]["CLAUDE"]}
+ />
+ </div>
+ {/if}
+
+ <Button type="submit" text="Submit"></Button>
+</form>