Skip to content

refactor: new API & universal load functions #1743

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 72 commits into from
Jun 5, 2025
Merged

Conversation

nsarrazin
Copy link
Collaborator

@nsarrazin nsarrazin commented Mar 4, 2025

This WIP PR addresses #1699 by expanding the API and moving all the server-side load functions to universal load functions that call the API endpoints instead.

This is important for shipping apps that must be bundled in SPA mode.

  • src/routes/+layout.server.ts
  • src/routes/assistant/[assistantId]/+page.server.ts
  • src/routes/assistants/+page.server.ts
  • src/routes/conversation/[id]/+page.server.ts
  • src/routes/login/callback/+page.server.ts (feat(api): migrate login and logout to API routes #1703)
  • src/routes/models/[...model]/+page.server.ts
  • src/routes/settings/+layout.server.ts
  • src/routes/tools/+page.server.ts
  • src/routes/tools/[toolId]/+layout.server.ts

@nsarrazin nsarrazin added enhancement New feature or request front This issue is related to the front-end of the app. back This issue is related to the Svelte backend or the DB dependencies Pull requests that update a dependency file labels Mar 4, 2025
@nsarrazin nsarrazin added this to the chat-ui in tauri milestone Mar 4, 2025
@nsarrazin nsarrazin marked this pull request as ready for review May 28, 2025 09:47
@nsarrazin
Copy link
Collaborator Author

should be working even if API is not fully ported, merging for now will check nothing broke

@nsarrazin nsarrazin merged commit 7961ae7 into main Jun 5, 2025
5 of 6 checks passed
@nsarrazin nsarrazin deleted the feat/api_elysia_setup branch June 5, 2025 11:44
@nsarrazin nsarrazin restored the feat/api_elysia_setup branch June 5, 2025 12:18
nsarrazin added a commit that referenced this pull request Jun 5, 2025
maksym-work pushed a commit to siilats/chat-ui that referenced this pull request Jul 2, 2025
* feat(API): refactor API with Elysia

* feat: initial elysia setup

* feat: replace conv/[id] load function with universal

* fix: delete v1 catchall

* wip

* fix: response type

* fix: add cors

* feat: more routes in tools & assistants

* refacto: use normal svelte fetch in `/assistant/[assistantId]`

* refacto: use normal svelte fetch in `conversation/[id]`

* feat: use universal load function for `tools/[toolId]`

* wip: removing more server load function stuff

* feat: more routes to universal load functions

* feat: more routes to universal

* refactor: move tools loading to API endpoint

* refactor(api): implement tools search API endpoint and move load function

* fix: types on tool search

* refactor: update assistant route and remove redundant page load function

* refactor(api): move assistants page load function to api call

* refactor(settings): remove waterfall loading

* refactor: main load function

* fix: types

* feat: improve fetchJSON to handle empty responses

* fix: issues with page loading & assistant avatars

* refactor(api): remove unused Eden fetch utility

* refactor(routes): improve conversation page loading and error handling

* feat(api): migrate login and logout to API routes (huggingface#1703)

* feat(auth): migrate login and logout to API routes

- Replaced form-based login/logout with fetch-based API routes
- Updated hooks and components to use new `/api/login` and `/api/logout` endpoints

* fix: invalidate on logout

* refactor: move `/api/login` routes back to `/login` and `/api/logout` to `/logout`

remove breaing change to connected apps

* refactor(api): update import aliases and configuration for API routes

* refactor: update conversation handling to use generic tree structure

- Changed `addChildren` and `addSibling` functions to utilize a generic `Tree` type for better flexibility.
- Updated `buildSubtree` to return a tree node structure.
- Modified conversation response types to use `Serialize<Conversation>` for improved serialization.
- Adjusted related tests to align with the new tree structure and types.

* fix: specify message type in ChatWindow component

- Updated the `messages` prop in the ChatWindow component to explicitly cast `messagesPath` as `Message[]` for improved type safety and clarity.

* feat: make login simpler with GET's

* fix: debug logs

* fix: isAdmin flag

* refactor: remove debug route

* fix: use config manager in api routes

* chores: use latest elysia

* wip

* feat: working with different origin

* refactor: update API routes to throw errors for unimplemented features

* fix: use hook for public config

so we dont use context outside of component lifecycles

* refactor: use api client for user reports in settings load function

* fix: deps

* feat: get rid of last fetchJSON call in load function

* cors setup

* feat: use api client side

* feat: use api for assistant loading

* feat: use api client for assistant search

* fix: lint

* feat: use api client for tool

* feat: rename client hook and use for deleting all convs

* fix: let non-authed user set their model

* feat: bump minor for elysia API
maksym-work pushed a commit to siilats/chat-ui that referenced this pull request Jul 2, 2025
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
* feat(API): refactor API with Elysia

* feat: initial elysia setup

* feat: replace conv/[id] load function with universal

* fix: delete v1 catchall

* wip

* fix: response type

* fix: add cors

* feat: more routes in tools & assistants

* refacto: use normal svelte fetch in `/assistant/[assistantId]`

* refacto: use normal svelte fetch in `conversation/[id]`

* feat: use universal load function for `tools/[toolId]`

* wip: removing more server load function stuff

* feat: more routes to universal load functions

* feat: more routes to universal

* refactor: move tools loading to API endpoint

* refactor(api): implement tools search API endpoint and move load function

* fix: types on tool search

* refactor: update assistant route and remove redundant page load function

* refactor(api): move assistants page load function to api call

* refactor(settings): remove waterfall loading

* refactor: main load function

* fix: types

* feat: improve fetchJSON to handle empty responses

* fix: issues with page loading & assistant avatars

* refactor(api): remove unused Eden fetch utility

* refactor(routes): improve conversation page loading and error handling

* feat(api): migrate login and logout to API routes (huggingface#1703)

* feat(auth): migrate login and logout to API routes

- Replaced form-based login/logout with fetch-based API routes
- Updated hooks and components to use new `/api/login` and `/api/logout` endpoints

* fix: invalidate on logout

* refactor: move `/api/login` routes back to `/login` and `/api/logout` to `/logout`

remove breaing change to connected apps

* refactor(api): update import aliases and configuration for API routes

* refactor: update conversation handling to use generic tree structure

- Changed `addChildren` and `addSibling` functions to utilize a generic `Tree` type for better flexibility.
- Updated `buildSubtree` to return a tree node structure.
- Modified conversation response types to use `Serialize<Conversation>` for improved serialization.
- Adjusted related tests to align with the new tree structure and types.

* fix: specify message type in ChatWindow component

- Updated the `messages` prop in the ChatWindow component to explicitly cast `messagesPath` as `Message[]` for improved type safety and clarity.

* feat: make login simpler with GET's

* fix: debug logs

* fix: isAdmin flag

* refactor: remove debug route

* fix: use config manager in api routes

* chores: use latest elysia

* wip

* feat: working with different origin

* refactor: update API routes to throw errors for unimplemented features

* fix: use hook for public config

so we dont use context outside of component lifecycles

* refactor: use api client for user reports in settings load function

* fix: deps

* feat: get rid of last fetchJSON call in load function

* cors setup

* feat: use api client side

* feat: use api for assistant loading

* feat: use api client for assistant search

* fix: lint

* feat: use api client for tool

* feat: rename client hook and use for deleting all convs

* fix: let non-authed user set their model

* feat: bump minor for elysia API
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
* feat(API): refactor API with Elysia

* feat: initial elysia setup

* feat: replace conv/[id] load function with universal

* fix: delete v1 catchall

* wip

* fix: response type

* fix: add cors

* feat: more routes in tools & assistants

* refacto: use normal svelte fetch in `/assistant/[assistantId]`

* refacto: use normal svelte fetch in `conversation/[id]`

* feat: use universal load function for `tools/[toolId]`

* wip: removing more server load function stuff

* feat: more routes to universal load functions

* feat: more routes to universal

* refactor: move tools loading to API endpoint

* refactor(api): implement tools search API endpoint and move load function

* fix: types on tool search

* refactor: update assistant route and remove redundant page load function

* refactor(api): move assistants page load function to api call

* refactor(settings): remove waterfall loading

* refactor: main load function

* fix: types

* feat: improve fetchJSON to handle empty responses

* fix: issues with page loading & assistant avatars

* refactor(api): remove unused Eden fetch utility

* refactor(routes): improve conversation page loading and error handling

* feat(api): migrate login and logout to API routes (huggingface#1703)

* feat(auth): migrate login and logout to API routes

- Replaced form-based login/logout with fetch-based API routes
- Updated hooks and components to use new `/api/login` and `/api/logout` endpoints

* fix: invalidate on logout

* refactor: move `/api/login` routes back to `/login` and `/api/logout` to `/logout`

remove breaing change to connected apps

* refactor(api): update import aliases and configuration for API routes

* refactor: update conversation handling to use generic tree structure

- Changed `addChildren` and `addSibling` functions to utilize a generic `Tree` type for better flexibility.
- Updated `buildSubtree` to return a tree node structure.
- Modified conversation response types to use `Serialize<Conversation>` for improved serialization.
- Adjusted related tests to align with the new tree structure and types.

* fix: specify message type in ChatWindow component

- Updated the `messages` prop in the ChatWindow component to explicitly cast `messagesPath` as `Message[]` for improved type safety and clarity.

* feat: make login simpler with GET's

* fix: debug logs

* fix: isAdmin flag

* refactor: remove debug route

* fix: use config manager in api routes

* chores: use latest elysia

* wip

* feat: working with different origin

* refactor: update API routes to throw errors for unimplemented features

* fix: use hook for public config

so we dont use context outside of component lifecycles

* refactor: use api client for user reports in settings load function

* fix: deps

* feat: get rid of last fetchJSON call in load function

* cors setup

* feat: use api client side

* feat: use api for assistant loading

* feat: use api client for assistant search

* fix: lint

* feat: use api client for tool

* feat: rename client hook and use for deleting all convs

* fix: let non-authed user set their model

* feat: bump minor for elysia API
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back This issue is related to the Svelte backend or the DB dependencies Pull requests that update a dependency file enhancement New feature or request front This issue is related to the front-end of the app.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant