Skip to content

Commit

Permalink
GUI: form fixes; chore: version updated
Browse files Browse the repository at this point in the history
  • Loading branch information
brainless committed Jul 5, 2024
1 parent e0dbd3f commit da32d10
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 32 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dwata",
"version": "0.1.2",
"description": "A general purpose, multi-model and multi-modal AI studio",
"version": "0.1.3",
"description": "AI assistants for everyone",
"type": "module",
"author": {
"name": "Sumit Datta",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ members = ["openai"]

[package]
name = "dwata"
version = "0.1.2"
description = "A general purpose, multi-model and multi-modal AI studio"
version = "0.1.3"
description = "AI assistants for everyone"
authors = ["Sumit Datta <sumitdatta@gmail.com>"]
license = "Apache-2.0 license"
repository = "https://github.com/brainless/dwata"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"productName": "dwata",
"version": "0.1.2",
"version": "0.1.3",
"identifier": "com.dwata.app",
"build": {
"beforeDevCommand": "pnpm dev",
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Home: Component = () => {
<p style={{ color: getColors().colors["editor.foreground"] }}>
To get started, please{" "}
<Button
href="/settings/ai-provider/add"
href="/settings/ai-integration/add"
size="sm"
label="add an AI provider"
/>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const SettingsIndex: Component = () => {
<div class="mb-2" />
<Button
label="Add an AI provider"
href="/settings/ai-provider/add"
href="/settings/ai-integration/add"
size="sm"
></Button>
<div class="mb-6" />
Expand Down Expand Up @@ -85,8 +85,8 @@ const SettingsRoutes: Component = () => {
component={DirectorySourceForm}
/>

<Route path="/ai-provider/add" component={AIIntegrationForm} />
<Route path="/ai-provider/edit/:id" component={AIIntegrationForm} />
<Route path="/ai-integration/add" component={AIIntegrationForm} />
<Route path="/ai-integration/edit/:id" component={AIIntegrationForm} />

<Route path="/" component={SettingsIndex} />
</>
Expand Down
1 change: 0 additions & 1 deletion src/widgets/chat/ReplyItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Chat } from "../../api_types/Chat";
import { marked } from "marked";
import { Role } from "../../api_types/Role";
import { useChat } from "../../stores/chat";
import { invoke } from "@tauri-apps/api/core";

interface IPropTypes extends Chat {
index: number;
Expand Down
51 changes: 31 additions & 20 deletions src/widgets/interactable/ConfiguredForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
For,
JSX,
createComputed,
createEffect,
createResource,
createSignal,
onMount,
Expand Down Expand Up @@ -57,37 +56,49 @@ const Form: Component<IPropTypes> = (props) => {
});
});

createEffect((previousData) => {
if (previousData !== props.initialData) {
onMount(() => {
refetchModuleConfiguration();
if (props.initialData !== undefined) {
setFormData((state) => ({ ...state, ...props.initialData }));

setDirty((state) => [
...state,
...Object.keys(props.initialData).filter((x) => !state.includes(x)),
...Object.keys(props.initialData!).filter((x) => !state.includes(x)),
]);
}
}, {});

onMount(() => {
refetchModuleConfiguration();
// setFormConfiguration(config() as Configuration);

if (props.existingItemId) {
refetchModuleData();
}
});

if (!!moduleData() && props.module in moduleData()!) {
for (const [key, value] of Object.entries(
moduleData()![props.module as keyof ModuleDataRead],
)) {
if (key in formData()) {
setFormData((state) => ({
...state,
[key as string]: value as IFormFieldValue,
}));
}
createComputed((isSet) => {
if (!props.existingItemId) {
return false;
}

if (
!isSet &&
moduleData.state === "ready" &&
moduleData() !== undefined &&
props.module in moduleData()!
) {
let _data: { [key: string]: IFormFieldValue } = {};
for (const [key, value] of Object.entries(
moduleData()![props.module as keyof ModuleDataRead],
)) {
if (key in formData()) {
_data[key] = value as IFormFieldValue;
}
}

setFormData((state) => ({
...state,
..._data,
}));
return true;
}
return false;
});

const handleChange = (name: string, value: IFormFieldValue) => {
Expand Down Expand Up @@ -147,7 +158,7 @@ const Form: Component<IPropTypes> = (props) => {

nextTaskStore[1].initiateTask({
name: response.nextTask,
arguments: response.arguments,
arguments: response.arguments || undefined,
});
if (!!props.postSaveNavigateTo) {
navigate(
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/settings/SettingsIntegrationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const SettingsAIIntegrationItem: Component<AIIntegration> = (props) => {
const navigate = useNavigate();

const handleClick = () => {
navigate(`/settings/ai-provider/edit/${props.id}`);
navigate(`/settings/ai-integration/edit/${props.id}`);
};

return (
Expand Down

0 comments on commit da32d10

Please sign in to comment.