Skip to content

Commit

Permalink
select graph (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu authored Jan 2, 2025
1 parent ac79dcc commit 2a072a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/lib/components/chat/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import type { i18n as i18nType } from 'i18next';
import { WEBUI_BASE_URL } from '$lib/constants';
import { iterativeAnalysis, graphChat } from './Agents/iterative_analysis';
import * as graphDataSet from './Agents/iterative_analysis';
import {
chatId,
Expand Down Expand Up @@ -1850,7 +1850,8 @@
);
// Add chat data to the graph
const graphData = JSON.parse(JSON.stringify(iterativeAnalysis));
const graphData = graphDataSet[history.graphId ?? "iterativeAnalysis"];
// console.log(history.graphId);
// const graphData = JSON.parse(JSON.stringify(graphChat));
let lastNodeId: string | null = null;
Expand Down Expand Up @@ -1931,7 +1932,9 @@
return { role, content };
});
graphai.injectValue("chatHistory", messages);
graphai.injectValue("llmEngine", llmEngine);
if (graphai.nodes["llmEngine"]) {
graphai.injectValue("llmEngine", llmEngine);
}
// graphai.injectValue("llmEngine", "anthropicAgent");
graphai.onLogCallback = ({ nodeId, agentId, state, inputs, result, errorMessage }) => {
if (result) {
Expand Down Expand Up @@ -2848,12 +2851,15 @@
}
}}
on:submit={async (e) => {
if (e.detail) {
if (e.detail) {
const { prompt, graphId } = e.detail;
history.graphId = graphId;
console.log(prompt, graphId);
await tick();
submitPrompt(
($settings?.richTextInput ?? true)
? e.detail.replaceAll('\n\n', '\n')
: e.detail
? prompt.replaceAll('\n\n', '\n')
: prompt
);
}
}}
Expand Down
18 changes: 16 additions & 2 deletions src/lib/components/chat/Placeholder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import EyeSlash from '$lib/components/icons/EyeSlash.svelte';
import MessageInput from './MessageInput.svelte';
import * as graphDataSet from './Agents/iterative_analysis';
const i18n = getContext('i18n');
export let transparentBackground = false;
Expand All @@ -36,6 +38,9 @@
export let selectedToolIds = [];
export let webSearchEnabled = false;
export let selectedGraph = "graphChat";
const graphNames = Object.keys(graphDataSet);
let models = [];
const selectSuggestionPrompt = async (p) => {
Expand Down Expand Up @@ -142,7 +147,6 @@
{/if}
</div>
</div>

<div class="flex mt-1 mb-2">
<div in:fade={{ duration: 100, delay: 50 }}>
{#if models[selectedModelIdx]?.info?.meta?.description ?? null}
Expand Down Expand Up @@ -204,12 +208,22 @@
dispatch('upload', e.detail);
}}
on:submit={(e) => {
dispatch('submit', e.detail);
dispatch('submit', {prompt: e.detail, graphId: selectedGraph});
}}
/>
</div>
</div>
</div>
<select
class=" dark:bg-gray-900 w-fit pr-8 rounded py-2 px-2 text-xs bg-transparent outline-none text-right"
bind:value={selectedGraph}
placeholder="Select a graphtheme"
>
{#each graphNames as item}
<option value="{item}">{item}</option>
{/each}
</select>

<div class="mx-auto max-w-2xl font-primary" in:fade={{ duration: 200, delay: 200 }}>
<div class="mx-5">
<Suggestions
Expand Down

0 comments on commit 2a072a7

Please sign in to comment.