Spaces:
Running
Running
some fixes
Browse files- src/lib/components/chat/Assistant.svelte +2 -2
- src/lib/components/flow/actions/{ResetPanel.svelte → PanelFlowActions.svelte} +31 -9
- src/lib/components/model/SettingsModel.svelte +2 -1
- src/lib/helpers/{getNodesAssociatedWith.ts → get-nodes-associated-with.ts} +0 -0
- src/lib/helpers/map-nodes-export.ts +13 -0
- src/routes/+page.svelte +3 -3
src/lib/components/chat/Assistant.svelte
CHANGED
|
@@ -184,10 +184,10 @@
|
|
| 184 |
<span class="inline-flex items-center gap-1 rounded-full bg-muted py-0.5 pr-2 pl-1">
|
| 185 |
<img
|
| 186 |
src={`https://huggingface.co/api/avatars/${inferenceProvider}`}
|
| 187 |
-
alt={
|
| 188 |
class="size-4 rounded-full"
|
| 189 |
/>
|
| 190 |
-
{
|
| 191 |
</span>
|
| 192 |
provider
|
| 193 |
</span>
|
|
|
|
| 184 |
<span class="inline-flex items-center gap-1 rounded-full bg-muted py-0.5 pr-2 pl-1">
|
| 185 |
<img
|
| 186 |
src={`https://huggingface.co/api/avatars/${inferenceProvider}`}
|
| 187 |
+
alt={provider}
|
| 188 |
class="size-4 rounded-full"
|
| 189 |
/>
|
| 190 |
+
{provider}
|
| 191 |
</span>
|
| 192 |
provider
|
| 193 |
</span>
|
src/lib/components/flow/actions/{ResetPanel.svelte → PanelFlowActions.svelte}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import { RefreshCcw } from '@lucide/svelte';
|
| 3 |
import { Panel, useSvelteFlow } from '@xyflow/svelte';
|
| 4 |
|
| 5 |
import { Button } from '$lib/components/ui/button';
|
| 6 |
import { breakpointsState } from '$lib/state/breakpoints.svelte';
|
| 7 |
|
| 8 |
const { getNodes } = useSvelteFlow();
|
| 9 |
-
let
|
| 10 |
|
| 11 |
function handleReset() {
|
| 12 |
const ok = confirm('Are you sure you want to reset the flow?');
|
|
@@ -14,13 +14,24 @@
|
|
| 14 |
location.reload();
|
| 15 |
}
|
| 16 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</script>
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
<Button
|
| 25 |
variant="outline"
|
| 26 |
size={breakpointsState.isMobile ? 'icon-sm' : 'default'}
|
|
@@ -32,5 +43,16 @@
|
|
| 32 |
Clear flow
|
| 33 |
{/if}
|
| 34 |
</Button>
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import { Download, RefreshCcw } from '@lucide/svelte';
|
| 3 |
import { Panel, useSvelteFlow } from '@xyflow/svelte';
|
| 4 |
|
| 5 |
import { Button } from '$lib/components/ui/button';
|
| 6 |
import { breakpointsState } from '$lib/state/breakpoints.svelte';
|
| 7 |
|
| 8 |
const { getNodes } = useSvelteFlow();
|
| 9 |
+
let showPanelFlowActions = $derived(getNodes().length > 1);
|
| 10 |
|
| 11 |
function handleReset() {
|
| 12 |
const ok = confirm('Are you sure you want to reset the flow?');
|
|
|
|
| 14 |
location.reload();
|
| 15 |
}
|
| 16 |
}
|
| 17 |
+
|
| 18 |
+
function handleExport() {
|
| 19 |
+
const ok = confirm('Are you sure you want to export the flow?');
|
| 20 |
+
if (ok) {
|
| 21 |
+
const flow = getNodes();
|
| 22 |
+
const flowJson = JSON.stringify(flow, null, 2);
|
| 23 |
+
const flowBlob = new Blob([flowJson], { type: 'application/json' });
|
| 24 |
+
const flowUrl = URL.createObjectURL(flowBlob);
|
| 25 |
+
window.open(flowUrl, '_blank');
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
</script>
|
| 29 |
|
| 30 |
+
{#if showPanelFlowActions}
|
| 31 |
+
<Panel
|
| 32 |
+
position={breakpointsState.isMobile ? 'bottom-left' : 'top-left'}
|
| 33 |
+
class="flex items-center justify-end gap-2 p-1 lg:p-2"
|
| 34 |
+
>
|
| 35 |
<Button
|
| 36 |
variant="outline"
|
| 37 |
size={breakpointsState.isMobile ? 'icon-sm' : 'default'}
|
|
|
|
| 43 |
Clear flow
|
| 44 |
{/if}
|
| 45 |
</Button>
|
| 46 |
+
<!-- <Button
|
| 47 |
+
variant="outline"
|
| 48 |
+
size={breakpointsState.isMobile ? 'icon-sm' : 'default'}
|
| 49 |
+
class=""
|
| 50 |
+
onclick={handleExport}
|
| 51 |
+
>
|
| 52 |
+
<Download />
|
| 53 |
+
{#if !breakpointsState.isMobile}
|
| 54 |
+
Export flow
|
| 55 |
+
{/if}
|
| 56 |
+
</Button> -->
|
| 57 |
+
</Panel>
|
| 58 |
+
{/if}
|
src/lib/components/model/SettingsModel.svelte
CHANGED
|
@@ -211,8 +211,9 @@
|
|
| 211 |
{/if}
|
| 212 |
</p>
|
| 213 |
{:else}
|
|
|
|
| 214 |
<img
|
| 215 |
-
src={`https://huggingface.co/api/avatars/${
|
| 216 |
alt={provider}
|
| 217 |
class="size-4 rounded"
|
| 218 |
/>
|
|
|
|
| 211 |
{/if}
|
| 212 |
</p>
|
| 213 |
{:else}
|
| 214 |
+
{@const providerName = getProviderName(provider)}
|
| 215 |
<img
|
| 216 |
+
src={`https://huggingface.co/api/avatars/${providerName}`}
|
| 217 |
alt={provider}
|
| 218 |
class="size-4 rounded"
|
| 219 |
/>
|
src/lib/helpers/{getNodesAssociatedWith.ts → get-nodes-associated-with.ts}
RENAMED
|
File without changes
|
src/lib/helpers/map-nodes-export.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Node } from '@xyflow/svelte';
|
| 2 |
+
|
| 3 |
+
export function mapNodesExport(nodes: Node[]): Record<string, unknown>[] {
|
| 4 |
+
return nodes.map((node) => {
|
| 5 |
+
// const
|
| 6 |
+
return {
|
| 7 |
+
id: node.id,
|
| 8 |
+
type: node.type,
|
| 9 |
+
position: node.position,
|
| 10 |
+
data: node.data
|
| 11 |
+
};
|
| 12 |
+
});
|
| 13 |
+
}
|
src/routes/+page.svelte
CHANGED
|
@@ -22,9 +22,9 @@
|
|
| 22 |
import PanelCanvasActions from '$lib/components/flow/actions/PanelCanvasActions.svelte';
|
| 23 |
import { viewState } from '$lib/state/view.svelte';
|
| 24 |
import ContextMenuComponent from '$lib/components/flow/actions/ContextMenu.svelte';
|
| 25 |
-
import { getNodesAssociatedWith } from '$lib/helpers/
|
| 26 |
import { breakpointsState } from '$lib/state/breakpoints.svelte';
|
| 27 |
-
import
|
| 28 |
|
| 29 |
const nodeTypes = {
|
| 30 |
user: User,
|
|
@@ -136,7 +136,7 @@
|
|
| 136 |
patternColor={mode.current === 'dark' ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.04)'}
|
| 137 |
class="bg-background!"
|
| 138 |
/>
|
| 139 |
-
<
|
| 140 |
<PanelRightActions />
|
| 141 |
<PanelCanvasActions />
|
| 142 |
</SvelteFlow>
|
|
|
|
| 22 |
import PanelCanvasActions from '$lib/components/flow/actions/PanelCanvasActions.svelte';
|
| 23 |
import { viewState } from '$lib/state/view.svelte';
|
| 24 |
import ContextMenuComponent from '$lib/components/flow/actions/ContextMenu.svelte';
|
| 25 |
+
import { getNodesAssociatedWith } from '$lib/helpers/get-nodes-associated-with';
|
| 26 |
import { breakpointsState } from '$lib/state/breakpoints.svelte';
|
| 27 |
+
import PanelFlowActions from '$lib/components/flow/actions/PanelFlowActions.svelte';
|
| 28 |
|
| 29 |
const nodeTypes = {
|
| 30 |
user: User,
|
|
|
|
| 136 |
patternColor={mode.current === 'dark' ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.04)'}
|
| 137 |
class="bg-background!"
|
| 138 |
/>
|
| 139 |
+
<PanelFlowActions />
|
| 140 |
<PanelRightActions />
|
| 141 |
<PanelCanvasActions />
|
| 142 |
</SvelteFlow>
|