-
Notifications
You must be signed in to change notification settings - Fork 2
Introduce per thread url structure slg 71 #130
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c50b39f
Bump flowbite-svelte for VirtualLists
aryadhruv 54dae3d
Refactor chat to use virtual list
aryadhruv 42a849e
Formatting d'oh
aryadhruv 2c951c1
Update Chat.svelte
aryadhruv 83b0699
Merge branch 'main' into load-current-thread-from-backend-slg-45
aryadhruv 8213e2a
Merge branch 'main' into load-current-thread-from-backend-slg-45
aryadhruv b563386
Refactor thread message conversion logic
aryadhruv 5438c9c
Set final_answer_started when loading messages
aryadhruv 3f99991
Revert flowbit package update
aryadhruv 9a4afc4
Rollback changes -Virtual list
aryadhruv 2cc7cbd
Load only list 100 messages
aryadhruv f7a1cb9
Update Chat.svelte
aryadhruv 31f2897
Prevent's avalanche of message onMount
aryadhruv 49fc83c
Formatting d'oh!
aryadhruv 839b8a2
Fix Clipboard Button size
aryadhruv 538a1fb
Update AIMessageActions.svelte
aryadhruv 79652d4
Added datatype ThreadValues
aryadhruv 5e9aedb
Update AIMessageActions.svelte
aryadhruv fc3bbf7
Moved chat page to /chat/[threadID]/+page.svelte
aryadhruv d366db9
Consume thread to load chats
aryadhruv f450a8c
Use ChatError
aryadhruv f19f797
Merge branch 'main' into introduce-per-thread-url-structure2-slg-71
aryadhruv 64708d5
Add comment on lazily made threads
aryadhruv 31cc936
Update client.ts
aryadhruv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| <script lang="ts"> | ||
| import { error } from '@sveltejs/kit'; | ||
| import { page } from '$app/state'; | ||
| import { onMount } from 'svelte'; | ||
| import type { Thread } from '@langchain/langgraph-sdk'; | ||
| import Chat from '$lib/components/Chat.svelte'; | ||
| import ChatLoader from '$lib/components/ChatLoader.svelte'; | ||
| import LoginModal from '$lib/components/LoginModal.svelte'; | ||
| import { getOrCreateAssistant, createClient } from '$lib/langgraph/client'; | ||
| import * as m from '$lib/paraglide/messages.js'; | ||
| import type { Client } from '@langchain/langgraph-sdk'; | ||
| import type { ThreadValues } from '$lib/langgraph/types'; | ||
| import ChatError from '$lib/components/ChatError.svelte'; | ||
|
|
||
| let show_login_dialog = $state(false); | ||
|
|
||
| // Updates client whenever accessToken changes | ||
| let client = $derived(page.data.session ? createClient(page.data.session.accessToken) : null); | ||
| let assistantId = $state<string | null>(null); | ||
| let thread = $state<Thread<ThreadValues> | null>(null); | ||
| let threadId = $derived(page.params.threadID); | ||
| let initialization_error = $state<Error | null>(null); | ||
|
|
||
| async function initAssistantAndThread(client: Client, threadId: string) { | ||
| try { | ||
| assistantId = await getOrCreateAssistant(client, 'chat'); | ||
| const fetchedThread = await client.threads.get(threadId); | ||
| thread = fetchedThread as Thread<ThreadValues>; | ||
| } catch (err) { | ||
| if (err instanceof Error) initialization_error = err; | ||
| error(500, { | ||
| message: 'Error during generation' | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| $effect(() => { | ||
| if ((assistantId === null || thread === null) && client && threadId) { | ||
| initAssistantAndThread(client, threadId); | ||
| } | ||
| }); | ||
|
|
||
| onMount(async () => { | ||
| if (!page.data.session) show_login_dialog = true; | ||
| }); | ||
|
|
||
| const suggestions = [ | ||
| { | ||
| title: m.chat_suggestion_0_title(), | ||
| description: m.chat_suggestion_0_description(), | ||
| suggestedText: m.chat_suggestion_0_text() | ||
| }, | ||
| { | ||
| title: m.chat_suggestion_1_title(), | ||
| description: m.chat_suggestion_1_description(), | ||
| suggestedText: m.chat_suggestion_1_text() | ||
| }, | ||
| { | ||
| title: m.chat_suggestion_2_title(), | ||
| description: m.chat_suggestion_2_description(), | ||
| suggestedText: m.chat_suggestion_2_text() | ||
| }, | ||
| { | ||
| title: m.chat_suggestion_3_title(), | ||
| description: m.chat_suggestion_3_description(), | ||
| suggestedText: m.chat_suggestion_3_text() | ||
| } | ||
| ]; | ||
|
|
||
| let greeting = $derived.by(() => { | ||
| const userName = page.data.session?.user?.name; | ||
|
|
||
| if (userName) { | ||
| return m.chat_greeting_hello({ name: userName }); | ||
| } else { | ||
| return m.chat_greeting_anonymous(); | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| {#if initialization_error} | ||
| <ChatError error={initialization_error} /> | ||
| {:else if assistantId && thread && client} | ||
| <!-- We're all set up --> | ||
| <Chat | ||
| langGraphClient={client} | ||
| {assistantId} | ||
| {thread} | ||
| introTitle={greeting} | ||
| intro={m.chat_intro()} | ||
| {suggestions} | ||
| /> | ||
| {:else} | ||
| <ChatLoader /> | ||
| {/if} | ||
|
|
||
| <LoginModal bind:open={show_login_dialog} /> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would always be getting and never creating. Perhaps good to split this up.