Skip to content
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

Willy/ui2 #1615

Merged
merged 59 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
33bab32
chore: clean auth hooks
willydouhard Dec 18, 2024
925d419
wip
willydouhard Dec 18, 2024
7cf94da
wip header+sidebar
willydouhard Dec 21, 2024
22a454e
wip sidebar
willydouhard Dec 22, 2024
a6562d2
wip login
willydouhard Dec 22, 2024
7c184d9
wip composer
willydouhard Dec 23, 2024
d3ced1c
wip chat settings
willydouhard Dec 23, 2024
bbf1c00
wip tasklist
willydouhard Dec 23, 2024
b17d40f
wip readme + starters
willydouhard Dec 23, 2024
dbee012
wip copy button
willydouhard Dec 23, 2024
b4da382
wip footer
willydouhard Dec 24, 2024
18e8865
wip: messages
willydouhard Dec 26, 2024
ac4bf2d
wip sideview
willydouhard Dec 26, 2024
5f5dfe3
wip actions
willydouhard Dec 27, 2024
7f3f00a
wip thread resume
willydouhard Dec 27, 2024
3a02fdb
wip env
willydouhard Dec 28, 2024
27b47e8
wip element view
willydouhard Dec 28, 2024
29a5c94
chore: delete old mui files
willydouhard Dec 28, 2024
8697b2b
wip copilot
willydouhard Dec 29, 2024
53f767f
fix scroll
willydouhard Dec 29, 2024
7f2eb57
fix: enforce cookie auth
willydouhard Dec 29, 2024
1cad031
fix: copilot css
willydouhard Dec 29, 2024
3ed8b45
replace formik/yup with hookform/zod
willydouhard Dec 29, 2024
3fb3f6b
improve copilot scroll
willydouhard Dec 29, 2024
d2086b3
fix: lint
willydouhard Dec 29, 2024
20774a5
Merge branch 'main' of github.com:Chainlit/chainlit into willy/ui2
willydouhard Dec 29, 2024
c3c76af
fix: tests
willydouhard Dec 30, 2024
70816eb
fix: format/lint
willydouhard Dec 30, 2024
ff0251f
fix: import
willydouhard Dec 30, 2024
c60a26d
fix: ruff
willydouhard Dec 30, 2024
63bfcaa
fix: ruff
willydouhard Dec 30, 2024
d15df93
fix: ruff
willydouhard Dec 30, 2024
d3a11c4
fix: mypy
willydouhard Dec 30, 2024
9552dd1
fix: mypy
willydouhard Dec 30, 2024
0a8f383
feat: custom theme/font
willydouhard Dec 31, 2024
0b872a4
fix: ruff
willydouhard Dec 31, 2024
fdff686
fix: ruff
willydouhard Dec 31, 2024
346ff3b
fix: mypy
willydouhard Dec 31, 2024
db7b9d8
feat: copilot shadow root
willydouhard Dec 31, 2024
d3b3caa
feat: custom element
willydouhard Jan 1, 2025
6073a0c
fix: ruff
willydouhard Jan 1, 2025
56139d3
fix: mypy
willydouhard Jan 1, 2025
8d11d26
chore: bump python multipart
willydouhard Jan 1, 2025
14ce78c
chore: regenerate poetry.lock
willydouhard Jan 1, 2025
3925195
feat: expose shadcn components to CustomElement
willydouhard Jan 2, 2025
08df9d4
feat: fix chat if not thread resumable
willydouhard Jan 2, 2025
32849d2
fix: add error boundary to dynamic icon
willydouhard Jan 2, 2025
4bd978d
fix: enhance thread page
willydouhard Jan 2, 2025
318f157
fix: prevent enter when composing message
willydouhard Jan 2, 2025
0d1070d
feat: replace jsx parser with react runner
willydouhard Jan 3, 2025
dfb92ef
fix: icon component
willydouhard Jan 3, 2025
a1ac429
fix: thread page
willydouhard Jan 3, 2025
79d3a31
Update README.md
willydouhard Jan 3, 2025
f20f531
chore: update changelog
willydouhard Jan 3, 2025
739127f
fix: step content check
willydouhard Jan 3, 2025
3d85634
fix: check ROOT_PATH everytime html template is rendered
willydouhard Jan 3, 2025
e62092f
feat: add autofocus on login input
willydouhard Jan 3, 2025
f6a66b9
Hugues/data layer (#1621)
desaxce Jan 4, 2025
a9e9e88
fix: comment in feedback
desaxce Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["**/*.jsx"],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
Expand Down
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": [
"pages/(.*)$",
"@mui/(.*)$",
"@chainlit/(.*)$",
"components/(.*)$",
"assets/(.*)$",
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ All notable changes to Chainlit will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [2.0.0] - 2025-01-06

The Chainlit UI (including the copilot) has been completely re-written with Shadcn/Tailwind. This brings several advantages:
1. The codebase is simpler and more contribution friendly.
2. It enabled the new custom element feature.
3. The theme customisation is more powerful.

### Added
- Custom Elements (code your own elements)
- `Cmd+k` thread search
- Thread rename
- Official PostGres open source data layer
- New `@data_layer` decorator for configuring custom data layers declaratively

### Changed
- Authentication is now based on cookies. Cross Origins are disallowed unless added in `allow_origins` in the `config.toml` file
- No longer need to click on `resume` to resume a thread
- **[breaking]**: Theme customisation is now handled in `public/theme.json` instead of `config.toml`.
- **[breaking]**: Changed fields on the `Action` class:
- The `value` field has replaced with `payload` which accepts a Python dict
- The `description` field has been renamed `tooltip`
- The field `icon` has been added
- The `collapsed` field has been removed.
- **[breaking]**: Completely revamped audio implementation (#1401, #1410):
- Replaced `AudioChunk` with `InputAudioChunk` and `OutputAudioChunk`
- Changed default audio sampling rate from 44100 to 24000
- Removed several audio configuration options (`min_decibels`, `initial_silence_timeout`, `silence_timeout`, `chunk_duration`, `max_duration`)

### Fixed

- Autoscaling of Chainlit app behind a load balancer should now work. Don't forget to enable sticky sessions

## [2.1.dev0] - 2024-11-14

Pre-release: developer preview.
Expand Down
32 changes: 1 addition & 31 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@

Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.

- ✅ ChatGPT-like application
- ✅ Embedded Chatbot & Software Copilot
- ✅ Slack & Discord
- ✅ Custom frontend (build your own agentic experience)
- ✅ API Endpoint

Full documentation is available [here](https://docs.chainlit.io). You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/), an app built using Chainlit!

> [!NOTE]
> Check out [Literal AI](https://literalai.com), our product to monitor and evaluate LLM applications! It works with any Python or TypeScript applications and [seamlessly](https://docs.chainlit.io/data-persistence/overview) with Chainlit by adding a `LITERAL_API_KEY` in your project.
>
> Chainlit is developed and maintained by the Literal AI team, which is currently focused on expanding the capabilities of Literal AI. While we continue to support and maintain Chainlit, we are also committed to enabling the community to contribute, particularly in areas like integrations and data layers.
https://github.com/user-attachments/assets/b3738aba-55c0-42fa-ac00-6efd1ee0d148

<p align="center">
<img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" alt="Chainlit user interface" width="80%"></img>
</p>

## Installation

Expand Down Expand Up @@ -93,24 +81,6 @@ chainlit run demo.py -w

<img src="/images/quick-start.png" alt="Quick Start"></img>

## 🎉 Key Features and Integrations

Full documentation is available [here](https://docs.chainlit.io). Key features:

- [💬 Multi Modal chats](https://docs.chainlit.io/advanced-features/multi-modal)
- [💭 Chain of Thought visualization](https://docs.chainlit.io/concepts/step)
- [💾 Data persistence + human feedback](https://docs.chainlit.io/data-persistence/overview)
- [🐛 Debug Mode](https://docs.chainlit.io/data-persistence/enterprise#debug-mode)
- [👤 Authentication](https://docs.chainlit.io/authentication/overview)

Chainlit is compatible with all Python programs and libraries. That being said, it comes with integrations for:

- [LangChain](https://docs.chainlit.io/integrations/langchain)
- [Llama Index](https://docs.chainlit.io/integrations/llama-index)
- [Autogen](https://github.com/Chainlit/cookbook/tree/main/pyautogen)
- [OpenAI Assistant](https://github.com/Chainlit/cookbook/tree/main/openai-assistant)
- [Haystack](https://docs.chainlit.io/integrations/haystack)

## 📚 More Examples - Cookbook

You can find various examples of Chainlit apps [here](https://github.com/Chainlit/cookbook) that leverage tools and services such as OpenAI, Anthropiс, LangChain, LlamaIndex, ChromaDB, Pinecone and more.
Expand Down
104 changes: 47 additions & 57 deletions backend/chainlit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from chainlit.context import context
from chainlit.element import (
Audio,
Component,
CustomElement,
Dataframe,
File,
Image,
Expand Down Expand Up @@ -117,83 +117,73 @@ def acall(self):
)

__all__ = [
"__version__",
"Action",
"AskActionMessage",
"AskFileMessage",
"AskUserMessage",
"AsyncLangchainCallbackHandler",
"Audio",
"ChatGeneration",
"ChatProfile",
"Starter",
"user_session",
"chat_context",
"ChatSettings",
"CompletionGeneration",
"CopilotFunction",
"CustomElement",
"Dataframe",
"ErrorMessage",
"File",
"GenerationMessage",
"HaystackAgentCallbackHandler",
"Image",
"InputAudioChunk",
"LangchainCallbackHandler",
"LlamaIndexCallbackHandler",
"Message",
"OutputAudioChunk",
"Action",
"User",
"PersistedUser",
"Audio",
"Pdf",
"PersistedUser",
"Plotly",
"Image",
"Text",
"Component",
"Dataframe",
"Pyplot",
"File",
"Starter",
"Step",
"Task",
"TaskList",
"TaskStatus",
"Text",
"User",
"Video",
"ChatSettings",
"input_widget",
"Message",
"ErrorMessage",
"AskUserMessage",
"AskActionMessage",
"AskFileMessage",
"Step",
"step",
"ChatGeneration",
"CompletionGeneration",
"GenerationMessage",
"on_logout",
"on_window_message",
"send_window_message",
"on_chat_start",
"on_chat_end",
"on_chat_resume",
"on_stop",
"__version__",
"action_callback",
"author_rename",
"on_settings_update",
"password_auth_callback",
"header_auth_callback",
"sleep",
"run_sync",
"make_async",
"cache",
"chat_context",
"context",
"LangchainCallbackHandler",
"AsyncLangchainCallbackHandler",
"LlamaIndexCallbackHandler",
"HaystackAgentCallbackHandler",
"instrument_openai",
"instrument_mistralai",
"password_auth_callback",
"data_layer",
"header_auth_callback",
"input_widget",
"instrument_mistralai",
"instrument_openai",
"make_async",
"oauth_callback",
"on_audio_chunk",
"on_audio_end",
"on_audio_start",
"on_chat_end",
"on_chat_resume",
"on_chat_start",
"on_logout",
"on_message",
"on_chat_start",
"on_chat_resume",
"on_settings_update",
"on_stop",
"on_window_message",
"password_auth_callback",
"run_sync",
"send_window_message",
"set_chat_profiles",
"set_starters",
"on_chat_end",
"on_audio_start",
"on_audio_chunk",
"on_audio_end",
"author_rename",
"on_stop",
"action_callback",
"on_settings_update",
"data_layer",
"sleep",
"step",
"user_session",
]


Expand Down
16 changes: 8 additions & 8 deletions backend/chainlit/action.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
from typing import Optional
from typing import Dict, Optional

from dataclasses_json import DataClassJsonMixin
from pydantic import Field
Expand All @@ -13,18 +13,18 @@
class Action(DataClassJsonMixin):
# Name of the action, this should be used in the action_callback
name: str
# The value associated with the action. This is useful to differentiate between multiple actions with the same name.
value: str
# The label of the action. This is what the user will see. If not provided the name will be used.
# The parameters to call this action with.
payload: Dict
# The label of the action. This is what the user will see.
label: str = ""
# The description of the action. This is what the user will see when they hover the action.
description: str = ""
# The tooltip of the action button. This is what the user will see when they hover the action.
tooltip: str = ""
# The lucid icon name for this action.
icon: Optional[str] = None
# This should not be set manually, only used internally.
forId: Optional[str] = None
# The ID of the action
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
# Show the action in a drawer menu
collapsed: bool = False

def __post_init__(self) -> None:
trace_event(f"init {self.__class__.__name__}")
Expand Down
2 changes: 1 addition & 1 deletion backend/chainlit/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def get_configuration():
"requireLogin": require_login(),
"passwordAuth": config.code.password_auth_callback is not None,
"headerAuth": config.code.header_auth_callback is not None,
"cookieAuth": config.project.cookie_auth,
"oauthProviders": (
get_configured_oauth_providers() if is_oauth_enabled() else []
),
"default_theme": config.ui.default_theme,
}


Expand Down
1 change: 0 additions & 1 deletion backend/chainlit/auth/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def set_auth_cookie(response: Response, token: str):
secure=_cookie_secure,
samesite=_cookie_samesite,
max_age=_auth_cookie_lifetime,
path="/", # Why is path set here and not below?
)


Expand Down
2 changes: 1 addition & 1 deletion backend/chainlit/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def action_callback(name: str) -> Callable:
"""

def decorator(func: Callable[[Action], Any]):
config.code.action_callbacks[name] = wrap_user_function(func, with_task=True)
config.code.action_callbacks[name] = wrap_user_function(func, with_task=False)
return func

return decorator
Expand Down
Loading
Loading