Skip to content

Commit

Permalink
Merge branch 'Chainlit:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hayescode authored Mar 25, 2024
2 parents 354ddc2 + 407adef commit 21b2d31
Show file tree
Hide file tree
Showing 176 changed files with 5,963 additions and 7,021 deletions.
14 changes: 0 additions & 14 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ I've copy/pasted the whole document there, without the previous two headings.
- [Install python dependencies](#install-python-dependencies)
- [Start the Chainlit server from source](#start-the-chainlit-server-from-source)
- [Start the UI from source](#start-the-ui-from-source)
- [Develop locally on `libs/react-components`](#develop-locally-on-libsreact-components)
- [Run the tests](#run-the-tests)
- [Run one test](#run-one-test)

Expand Down Expand Up @@ -117,19 +116,6 @@ pnpm run dev --port 5174

If you visit `http://127.0.0.1:5174/`, it should connect to your local server. If the local server is not running, it should say that it can't connect to the server.

## Develop locally on `libs/react-components`

Reusable UI components are living in the separate npm package `libs/react-components`. The main Chainlit UI build and import that package automatically.

You can enable hot module replacement for development.

```sh
cd libs/react-components
pnpm run build:watch
```

This will watch for file changes in `libs/react-components` and automatically rebuild the library as you develop.

## Run the tests

Run `pnpm test`
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ jobs:
tests:
uses: ./.github/workflows/tests.yaml
secrets: inherit
tests-components:
uses: ./.github/workflows/tests-components.yaml
secrets: inherit
ci:
runs-on: ubuntu-latest
name: Run CI
needs: [mypy, tests, tests-components]
needs: [mypy, tests]
steps:
- name: 'Done'
run: echo "Done"
33 changes: 0 additions & 33 deletions .github/workflows/tests-components.yaml

This file was deleted.

1 change: 1 addition & 0 deletions backend/chainlit/langchain/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def _on_run_update(self, run: Run) -> None:

current_step.language = "json"
current_step.output = json.dumps(message_completion)
completion = message_completion.get("content", "")
else:
completion_start = self.completion_generations[str(run.id)]
completion = generation.get("text", "")
Expand Down
14 changes: 12 additions & 2 deletions backend/chainlit/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ def init_markdown(root: str):
logger.info(f"Created default chainlit markdown file at {chainlit_md_file}")


def get_markdown_str(root: str):
def get_markdown_str(root: str, language: str):
"""Get the chainlit.md file as a string."""
chainlit_md_path = os.path.join(root, "chainlit.md")
translated_chainlit_md_path = os.path.join(root, f"chainlit_{language}.md")
default_chainlit_md_path = os.path.join(root, "chainlit.md")

if os.path.exists(translated_chainlit_md_path):
chainlit_md_path = translated_chainlit_md_path
else:
chainlit_md_path = default_chainlit_md_path
logger.warning(
f"Translated markdown file for {language} not found. Defaulting to chainlit.md."
)

if os.path.exists(chainlit_md_path):
with open(chainlit_md_path, "r", encoding="utf-8") as f:
chainlit_md = f.read()
Expand Down
5 changes: 4 additions & 1 deletion backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ async def project_settings(
# Load translation based on the provided language
translation = config.load_translation(language)

# Load the markdown file based on the provided language
markdown = get_markdown_str(config.root, language)

profiles = []
if config.code.set_chat_profiles:
chat_profiles = await config.code.set_chat_profiles(current_user)
Expand All @@ -523,7 +526,7 @@ async def project_settings(
"userEnv": config.project.user_env,
"dataPersistence": get_data_layer() is not None,
"threadResumable": bool(config.code.on_chat_resume),
"markdown": get_markdown_str(config.root),
"markdown": markdown,
"chatProfiles": profiles,
"translation": translation,
}
Expand Down
2 changes: 2 additions & 0 deletions backend/chainlit/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"confirm": "Best\u00e4tigen"
},
"settingsModal": {
"settings": "Einstellungen",
"expandMessages": "Nachrichten ausklappen",
"hideChainOfThought": "Zwischenschritte verbergen",
"darkMode": "Dunkelmodus"
Expand All @@ -43,6 +44,7 @@
"chat": {
"history": {
"index": {
"showHistory": "Zeige Chatverlauf",
"lastInputs": "Letzte Eingaben",
"noInputs": "Leer...",
"loading": "L\u00e4dt..."
Expand Down
2 changes: 2 additions & 0 deletions backend/chainlit/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"confirm": "Confirm"
},
"settingsModal": {
"settings": "Settings",
"expandMessages": "Expand Messages",
"hideChainOfThought": "Hide Chain of Thought",
"darkMode": "Dark Mode"
Expand All @@ -43,6 +44,7 @@
"chat": {
"history": {
"index": {
"showHistory": "Show history",
"lastInputs": "Last Inputs",
"noInputs": "Such empty...",
"loading": "Loading..."
Expand Down
2 changes: 2 additions & 0 deletions backend/chainlit/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"confirm": "Confirmar"
},
"settingsModal": {
"settings": "Configurações",
"expandMessages": "Expandir Mensagens",
"hideChainOfThought": "Esconder Sequência de Pensamento",
"darkMode": "Modo Escuro"
Expand All @@ -43,6 +44,7 @@
"chat": {
"history": {
"index": {
"showHistory": "Mostrar histórico",
"lastInputs": "Últimas Entradas",
"noInputs": "Vazio...",
"loading": "Carregando..."
Expand Down
15 changes: 15 additions & 0 deletions cypress/e2e/readme/chainlit_pt-BR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Bem-vindo ao Chainlit! 🚀🤖

Olá, desenvolvedor! 👋 Estamos empolgados em tê-lo a bordo. O Chainlit é uma ferramenta poderosa projetada para ajudá-lo a prototipar, depurar e compartilhar aplicativos construídos em cima de LLMs.

## Links úteis 🔗

- **Documentação:** Comece com a nossa abrangente Documentação do Chainlit 📚
- **Comunidade no Discord:** Junte-se ao nosso amigável Discord do Chainlit para fazer perguntas, compartilhar seus projetos e se conectar com outros desenvolvedores! 💬

Mal podemos esperar para ver o que você cria com o Chainlit! Boa codificação! 💻😊

## Tela de boas-vindas

Para modificar a tela de boas-vindas, edite o arquivo chainlit.md
na raiz do seu projeto. Se você não quiser uma tela de boas-vindas, basta deixar este arquivo vazio.
1 change: 1 addition & 0 deletions cypress/e2e/readme/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import chainlit as cl
34 changes: 34 additions & 0 deletions cypress/e2e/readme/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { runTestServer } from '../../support/testUtils';

describe('readme_language', () => {
before(() => {
runTestServer();
});

it('should show default markdown on open', () => {
cy.visit('/readme');
cy.contains('Welcome to Chainlit!');
});

it('should show Portguese markdown on pt-BR language', () => {
cy.visit('/readme', {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, 'language', {
value: 'pt-BR'
});
}
});
cy.contains('Bem-vindo ao Chainlit!');
});

it('should fallback to default markdown on Klingon language', () => {
cy.visit('/readme', {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, 'language', {
value: 'Klingon'
});
}
});
cy.contains('Welcome to Chainlit!');
});
});
35 changes: 32 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,71 @@
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint ./src --ext .ts,.tsx && tsc --noemit",
"format": "prettier src/**/*.{ts,tsx} --write --loglevel error"
"format": "prettier src/**/*.{ts,tsx} --write --loglevel error",
"test": "vitest run",
"prepublish": "pnpm run build && pnpm test"
},
"dependencies": {
"@chainlit/react-client": "workspace:^",
"@chainlit/react-components": "workspace:^",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.9",
"@mui/lab": "^5.0.0-alpha.122",
"@mui/material": "^5.14.10",
"draft-js": "^0.11.7",
"formik": "^2.4.3",
"highlight.js": "^11.9.0",
"i18next": "^23.7.16",
"lodash": "^4.17.21",
"mui-chips-input": "2.0.0",
"plotly.js": "^2.27.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-file-icon": "^1.3.0",
"react-hotkeys-hook": "^4.4.1",
"react-i18next": "^14.0.0",
"react-markdown": "^9.0.1",
"react-password-checklist": "^1.5.0",
"react-plotly.js": "^2.6.0",
"react-resizable": "^3.0.5",
"react-router-dom": "^6.15.0",
"react-speech-recognition": "^3.10.0",
"recoil": "^0.7.7",
"regenerator-runtime": "^0.14.0",
"rehype-katex": "^7.0.0",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"sonner": "^1.2.3",
"swr": "^2.2.2",
"usehooks-ts": "^2.9.1",
"uuid": "^9.0.0",
"yup": "^1.2.0"
},
"devDependencies": {
"@swc/core": "^1.3.86",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@types/draft-js": "^0.11.10",
"@types/lodash": "^4.14.199",
"@types/node": "^20.5.7",
"@types/react": "^18.2.0",
"@types/react-file-icon": "^1.0.2",
"@types/react-plotly.js": "^2.6.3",
"@types/react-resizable": "^3.0.4",
"@types/react-speech-recognition": "^3.9.2",
"@types/uuid": "^9.0.3",
"@vitejs/plugin-react": "^4.0.4",
"@vitejs/plugin-react-swc": "^3.3.2",
"immutable": "^4.3.4",
"jsdom": "^22.1.0",
"tslib": "^2.6.2",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.2.0"
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.34.4"
}
}
Loading

0 comments on commit 21b2d31

Please sign in to comment.