chainlit 1.1.400rc1__py3-none-any.whl → 1.1.402__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chainlit might be problematic. Click here for more details.
- chainlit/copilot/dist/index.js +174 -174
- chainlit/data/__init__.py +8 -10
- chainlit/discord/app.py +8 -14
- chainlit/frontend/dist/assets/{DailyMotion-7d9d8967.js → DailyMotion-f314e070.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-056539a4.js → Facebook-8ccafb69.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-6ba8c523.js → FilePlayer-278edbf8.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-76b34822.js → Kaltura-ae0d33ee.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-920b0351.js → Mixcloud-8cf7a152.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-233baad2.js → Mux-7a9417e1.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-465edb0c.js → Preview-7932fd5a.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-854c68fa.js → SoundCloud-a6b17460.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-b752eb88.js → Streamable-bdaaac70.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-e3a9589f.js → Twitch-5c0aa780.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-ba4a57b2.js → Vidyard-8927f435.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-ab2483d7.js → Vimeo-715c5361.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-8e4a1a95.js → Wistia-8b2b2dba.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-82cbd48b.js → YouTube-77d859f9.js} +1 -1
- chainlit/frontend/dist/assets/{index-5a477218.js → index-f35e8b65.js} +106 -106
- chainlit/frontend/dist/assets/{react-plotly-503b28d5.js → react-plotly-9938b97b.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/langchain/callbacks.py +37 -8
- chainlit/server.py +1 -1
- chainlit/slack/app.py +19 -21
- chainlit/step.py +29 -8
- chainlit/teams/app.py +8 -12
- chainlit/translations/zh-CN.json +229 -0
- chainlit/user.py +3 -1
- {chainlit-1.1.400rc1.dist-info → chainlit-1.1.402.dist-info}/METADATA +1 -1
- {chainlit-1.1.400rc1.dist-info → chainlit-1.1.402.dist-info}/RECORD +31 -30
- {chainlit-1.1.400rc1.dist-info → chainlit-1.1.402.dist-info}/WHEEL +0 -0
- {chainlit-1.1.400rc1.dist-info → chainlit-1.1.402.dist-info}/entry_points.txt +0 -0
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<script>
|
|
22
22
|
const global = globalThis;
|
|
23
23
|
</script>
|
|
24
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
+
<script type="module" crossorigin src="/assets/index-f35e8b65.js"></script>
|
|
25
25
|
<link rel="stylesheet" href="/assets/index-aaf974a9.css">
|
|
26
26
|
</head>
|
|
27
27
|
<body>
|
chainlit/langchain/callbacks.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import time
|
|
3
|
-
from typing import Any, Dict, List, Optional, TypedDict, Union
|
|
3
|
+
from typing import Any, Dict, List, Optional, Tuple, TypedDict, Union,Sequence
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
|
-
from chainlit.context import context_var
|
|
7
|
-
from chainlit.message import Message
|
|
8
|
-
from chainlit.step import Step
|
|
9
6
|
from langchain.callbacks.tracers.base import BaseTracer
|
|
10
7
|
from langchain.callbacks.tracers.schemas import Run
|
|
11
8
|
from langchain.schema import BaseMessage
|
|
@@ -15,6 +12,10 @@ from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
|
|
|
15
12
|
from literalai.helper import utc_now
|
|
16
13
|
from literalai.step import TrueStepType
|
|
17
14
|
|
|
15
|
+
from chainlit.context import context_var
|
|
16
|
+
from chainlit.message import Message
|
|
17
|
+
from chainlit.step import Step
|
|
18
|
+
|
|
18
19
|
DEFAULT_ANSWER_PREFIX_TOKENS = ["Final", "Answer", ":"]
|
|
19
20
|
|
|
20
21
|
|
|
@@ -229,7 +230,24 @@ class GenerationHelper:
|
|
|
229
230
|
return provider, model, tools, settings
|
|
230
231
|
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
def process_content(content: Any) -> Tuple[Dict, Optional[str]]:
|
|
234
|
+
if content is None:
|
|
235
|
+
return {}, None
|
|
236
|
+
if isinstance(content, dict):
|
|
237
|
+
return content, "json"
|
|
238
|
+
elif isinstance(content, str):
|
|
239
|
+
return {"content": content}, "text"
|
|
240
|
+
else:
|
|
241
|
+
return {"content": str(content)}, "text"
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
DEFAULT_TO_IGNORE = [
|
|
245
|
+
"RunnableSequence",
|
|
246
|
+
"RunnableParallel",
|
|
247
|
+
"RunnableAssign",
|
|
248
|
+
"RunnableLambda",
|
|
249
|
+
"<lambda>",
|
|
250
|
+
]
|
|
233
251
|
DEFAULT_TO_KEEP = ["retriever", "llm", "agent", "chain", "tool"]
|
|
234
252
|
|
|
235
253
|
|
|
@@ -465,7 +483,11 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
465
483
|
parent_id=parent_id,
|
|
466
484
|
)
|
|
467
485
|
step.start = utc_now()
|
|
468
|
-
step.input = run.inputs
|
|
486
|
+
step.input, language = process_content(run.inputs)
|
|
487
|
+
if language is not None:
|
|
488
|
+
if step.metadata is None:
|
|
489
|
+
step.metadata = {}
|
|
490
|
+
step.metadata["language"] = language
|
|
469
491
|
|
|
470
492
|
self.steps[str(run.id)] = step
|
|
471
493
|
|
|
@@ -489,6 +511,9 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
489
511
|
generations = (run.outputs or {}).get("generations", [])
|
|
490
512
|
generation = generations[0][0]
|
|
491
513
|
variables = self.generation_inputs.get(str(run.parent_run_id), {})
|
|
514
|
+
variables = {
|
|
515
|
+
k: process_content(v) for k, v in variables.items() if v is not None
|
|
516
|
+
}
|
|
492
517
|
if message := generation.get("message"):
|
|
493
518
|
chat_start = self.chat_generations[str(run.id)]
|
|
494
519
|
duration = time.time() - chat_start["start"]
|
|
@@ -519,7 +544,11 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
519
544
|
"prompt_id"
|
|
520
545
|
]
|
|
521
546
|
if custom_variables := m.additional_kwargs.get("variables"):
|
|
522
|
-
current_step.generation.variables =
|
|
547
|
+
current_step.generation.variables = {
|
|
548
|
+
k: process_content(v)
|
|
549
|
+
for k, v in custom_variables.items()
|
|
550
|
+
if v is not None
|
|
551
|
+
}
|
|
523
552
|
break
|
|
524
553
|
|
|
525
554
|
current_step.language = "json"
|
|
@@ -563,7 +592,7 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
563
592
|
output = outputs.get(output_keys[0], outputs)
|
|
564
593
|
|
|
565
594
|
if current_step:
|
|
566
|
-
current_step.output = output
|
|
595
|
+
current_step.output = output[0] if isinstance(output, Sequence) else output
|
|
567
596
|
current_step.end = utc_now()
|
|
568
597
|
self._run_sync(current_step.update())
|
|
569
598
|
|
chainlit/server.py
CHANGED
|
@@ -266,7 +266,7 @@ def get_html_template():
|
|
|
266
266
|
)
|
|
267
267
|
url = config.ui.github or default_url
|
|
268
268
|
meta_image_url = config.ui.custom_meta_image_url or default_meta_image_url
|
|
269
|
-
favicon_path =
|
|
269
|
+
favicon_path = "/favicon"
|
|
270
270
|
|
|
271
271
|
tags = f"""<title>{config.ui.name}</title>
|
|
272
272
|
<link rel="icon" href="{favicon_path}" />
|
chainlit/slack/app.py
CHANGED
|
@@ -29,18 +29,16 @@ class SlackEmitter(BaseChainlitEmitter):
|
|
|
29
29
|
app: AsyncApp,
|
|
30
30
|
channel_id: str,
|
|
31
31
|
say,
|
|
32
|
-
enabled=False,
|
|
33
32
|
thread_ts: Optional[str] = None,
|
|
34
33
|
):
|
|
35
34
|
super().__init__(session)
|
|
36
35
|
self.app = app
|
|
37
36
|
self.channel_id = channel_id
|
|
38
37
|
self.say = say
|
|
39
|
-
self.enabled = enabled
|
|
40
38
|
self.thread_ts = thread_ts
|
|
41
39
|
|
|
42
40
|
async def send_element(self, element_dict: ElementDict):
|
|
43
|
-
if
|
|
41
|
+
if element_dict.get("display") != "inline":
|
|
44
42
|
return
|
|
45
43
|
|
|
46
44
|
persisted_file = self.session.files.get(element_dict.get("chainlitKey") or "")
|
|
@@ -65,18 +63,11 @@ class SlackEmitter(BaseChainlitEmitter):
|
|
|
65
63
|
)
|
|
66
64
|
|
|
67
65
|
async def send_step(self, step_dict: StepDict):
|
|
68
|
-
if not self.enabled:
|
|
69
|
-
return
|
|
70
|
-
|
|
71
66
|
step_type = step_dict.get("type")
|
|
72
|
-
|
|
73
|
-
"user_message",
|
|
74
|
-
"assistant_message",
|
|
75
|
-
]
|
|
76
|
-
is_chain_of_thought = bool(step_dict.get("parentId"))
|
|
67
|
+
is_assistant_message = step_type == "assistant_message"
|
|
77
68
|
is_empty_output = not step_dict.get("output")
|
|
78
69
|
|
|
79
|
-
if
|
|
70
|
+
if is_empty_output or not is_assistant_message:
|
|
80
71
|
return
|
|
81
72
|
|
|
82
73
|
enable_feedback = get_data_layer()
|
|
@@ -121,7 +112,9 @@ class SlackEmitter(BaseChainlitEmitter):
|
|
|
121
112
|
)
|
|
122
113
|
|
|
123
114
|
async def update_step(self, step_dict: StepDict):
|
|
124
|
-
|
|
115
|
+
is_assistant_message = step_dict["type"] == "assistant_message"
|
|
116
|
+
|
|
117
|
+
if not is_assistant_message:
|
|
125
118
|
return
|
|
126
119
|
|
|
127
120
|
await self.send_step(step_dict)
|
|
@@ -282,6 +275,9 @@ async def process_slack_message(
|
|
|
282
275
|
session, slack_files, slack_app.client.token
|
|
283
276
|
)
|
|
284
277
|
|
|
278
|
+
if on_chat_start := config.code.on_chat_start:
|
|
279
|
+
await on_chat_start()
|
|
280
|
+
|
|
285
281
|
msg = Message(
|
|
286
282
|
content=clean_content(text),
|
|
287
283
|
elements=file_elements,
|
|
@@ -291,11 +287,6 @@ async def process_slack_message(
|
|
|
291
287
|
|
|
292
288
|
await msg.send()
|
|
293
289
|
|
|
294
|
-
ctx.emitter.enabled = True
|
|
295
|
-
|
|
296
|
-
if on_chat_start := config.code.on_chat_start:
|
|
297
|
-
await on_chat_start()
|
|
298
|
-
|
|
299
290
|
if on_message := config.code.on_message:
|
|
300
291
|
await on_message(msg)
|
|
301
292
|
|
|
@@ -335,15 +326,22 @@ async def handle_app_mentions(event, say):
|
|
|
335
326
|
|
|
336
327
|
@slack_app.event("message")
|
|
337
328
|
async def handle_message(message, say):
|
|
338
|
-
user = await get_user(message["user"])
|
|
339
329
|
thread_id = str(
|
|
340
330
|
uuid.uuid5(
|
|
341
331
|
uuid.NAMESPACE_DNS,
|
|
342
332
|
message["channel"] + datetime.today().strftime("%Y-%m-%d"),
|
|
343
333
|
)
|
|
344
334
|
)
|
|
345
|
-
|
|
346
|
-
|
|
335
|
+
thread_ts = message.get("thread_ts", message["ts"])
|
|
336
|
+
thread_id = str(uuid.uuid5(uuid.NAMESPACE_DNS, thread_ts))
|
|
337
|
+
|
|
338
|
+
await process_slack_message(
|
|
339
|
+
event=message,
|
|
340
|
+
say=say,
|
|
341
|
+
thread_id=thread_id,
|
|
342
|
+
bind_thread_to_user=True,
|
|
343
|
+
thread_ts=thread_ts,
|
|
344
|
+
)
|
|
347
345
|
|
|
348
346
|
|
|
349
347
|
@slack_app.block_action("thumbdown")
|
chainlit/step.py
CHANGED
|
@@ -3,6 +3,7 @@ import inspect
|
|
|
3
3
|
import json
|
|
4
4
|
import time
|
|
5
5
|
import uuid
|
|
6
|
+
from copy import deepcopy
|
|
6
7
|
from functools import wraps
|
|
7
8
|
from typing import Callable, Dict, List, Optional, TypedDict, Union
|
|
8
9
|
|
|
@@ -29,6 +30,18 @@ def check_add_step_in_cot(step: "Step"):
|
|
|
29
30
|
return True
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
def stub_step(step: "Step"):
|
|
34
|
+
return {
|
|
35
|
+
"type": step.type,
|
|
36
|
+
"name": step.name,
|
|
37
|
+
"id": step.id,
|
|
38
|
+
"parentId": step.parent_id,
|
|
39
|
+
"threadId": step.thread_id,
|
|
40
|
+
"input": "",
|
|
41
|
+
"output": "",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
32
45
|
class StepDict(TypedDict, total=False):
|
|
33
46
|
name: str
|
|
34
47
|
type: StepType
|
|
@@ -52,6 +65,13 @@ class StepDict(TypedDict, total=False):
|
|
|
52
65
|
feedback: Optional[FeedbackDict]
|
|
53
66
|
|
|
54
67
|
|
|
68
|
+
def flatten_args_kwargs(func, *args, **kwargs):
|
|
69
|
+
signature = inspect.signature(func)
|
|
70
|
+
bound_arguments = signature.bind(*args, **kwargs)
|
|
71
|
+
bound_arguments.apply_defaults()
|
|
72
|
+
return {k: deepcopy(v) for k, v in bound_arguments.arguments.items()}
|
|
73
|
+
|
|
74
|
+
|
|
55
75
|
def step(
|
|
56
76
|
original_function: Optional[Callable] = None,
|
|
57
77
|
*,
|
|
@@ -86,7 +106,7 @@ def step(
|
|
|
86
106
|
show_input=show_input,
|
|
87
107
|
) as step:
|
|
88
108
|
try:
|
|
89
|
-
step.input =
|
|
109
|
+
step.input = flatten_args_kwargs(func, args, kwargs)
|
|
90
110
|
except:
|
|
91
111
|
pass
|
|
92
112
|
result = await func(*args, **kwargs)
|
|
@@ -113,7 +133,7 @@ def step(
|
|
|
113
133
|
show_input=show_input,
|
|
114
134
|
) as step:
|
|
115
135
|
try:
|
|
116
|
-
step.input =
|
|
136
|
+
step.input = flatten_args_kwargs(func, args, kwargs)
|
|
117
137
|
except:
|
|
118
138
|
pass
|
|
119
139
|
result = func(*args, **kwargs)
|
|
@@ -302,9 +322,9 @@ class Step:
|
|
|
302
322
|
await asyncio.gather(*tasks)
|
|
303
323
|
|
|
304
324
|
if not check_add_step_in_cot(self):
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
325
|
+
await context.emitter.update_step(stub_step(self))
|
|
326
|
+
else:
|
|
327
|
+
await context.emitter.update_step(step_dict)
|
|
308
328
|
|
|
309
329
|
return True
|
|
310
330
|
|
|
@@ -356,9 +376,9 @@ class Step:
|
|
|
356
376
|
await asyncio.gather(*tasks)
|
|
357
377
|
|
|
358
378
|
if not check_add_step_in_cot(self):
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
379
|
+
await context.emitter.send_step(stub_step(self))
|
|
380
|
+
else:
|
|
381
|
+
await context.emitter.send_step(step_dict)
|
|
362
382
|
|
|
363
383
|
return self
|
|
364
384
|
|
|
@@ -381,6 +401,7 @@ class Step:
|
|
|
381
401
|
assert self.id
|
|
382
402
|
|
|
383
403
|
if not check_add_step_in_cot(self):
|
|
404
|
+
await context.emitter.send_step(stub_step(self))
|
|
384
405
|
return
|
|
385
406
|
|
|
386
407
|
if not self.streaming:
|
chainlit/teams/app.py
CHANGED
|
@@ -42,13 +42,12 @@ from chainlit.user_session import user_session
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class TeamsEmitter(BaseChainlitEmitter):
|
|
45
|
-
def __init__(self, session: HTTPSession, turn_context: TurnContext
|
|
45
|
+
def __init__(self, session: HTTPSession, turn_context: TurnContext):
|
|
46
46
|
super().__init__(session)
|
|
47
47
|
self.turn_context = turn_context
|
|
48
|
-
self.enabled = enabled
|
|
49
48
|
|
|
50
49
|
async def send_element(self, element_dict: ElementDict):
|
|
51
|
-
if
|
|
50
|
+
if element_dict.get("display") != "inline":
|
|
52
51
|
return
|
|
53
52
|
|
|
54
53
|
persisted_file = self.session.files.get(element_dict.get("chainlitKey") or "")
|
|
@@ -82,7 +81,7 @@ class TeamsEmitter(BaseChainlitEmitter):
|
|
|
82
81
|
await self.turn_context.send_activity(Activity(attachments=[attachment]))
|
|
83
82
|
|
|
84
83
|
async def send_step(self, step_dict: StepDict):
|
|
85
|
-
if not
|
|
84
|
+
if not step_dict["type"] == "assistant_message":
|
|
86
85
|
return
|
|
87
86
|
|
|
88
87
|
step_type = step_dict.get("type")
|
|
@@ -90,10 +89,9 @@ class TeamsEmitter(BaseChainlitEmitter):
|
|
|
90
89
|
"user_message",
|
|
91
90
|
"assistant_message",
|
|
92
91
|
]
|
|
93
|
-
is_chain_of_thought = bool(step_dict.get("parentId"))
|
|
94
92
|
is_empty_output = not step_dict.get("output")
|
|
95
93
|
|
|
96
|
-
if
|
|
94
|
+
if is_empty_output or not is_message:
|
|
97
95
|
return
|
|
98
96
|
else:
|
|
99
97
|
reply = MessageFactory.text(step_dict["output"])
|
|
@@ -122,7 +120,7 @@ class TeamsEmitter(BaseChainlitEmitter):
|
|
|
122
120
|
await self.turn_context.send_activity(reply)
|
|
123
121
|
|
|
124
122
|
async def update_step(self, step_dict: StepDict):
|
|
125
|
-
if not
|
|
123
|
+
if not step_dict["type"] == "assistant_message":
|
|
126
124
|
return
|
|
127
125
|
|
|
128
126
|
await self.send_step(step_dict)
|
|
@@ -256,6 +254,9 @@ async def process_teams_message(
|
|
|
256
254
|
|
|
257
255
|
file_elements = await download_teams_files(session, teams_files)
|
|
258
256
|
|
|
257
|
+
if on_chat_start := config.code.on_chat_start:
|
|
258
|
+
await on_chat_start()
|
|
259
|
+
|
|
259
260
|
msg = Message(
|
|
260
261
|
content=text,
|
|
261
262
|
elements=file_elements,
|
|
@@ -265,11 +266,6 @@ async def process_teams_message(
|
|
|
265
266
|
|
|
266
267
|
await msg.send()
|
|
267
268
|
|
|
268
|
-
ctx.emitter.enabled = True
|
|
269
|
-
|
|
270
|
-
if on_chat_start := config.code.on_chat_start:
|
|
271
|
-
await on_chat_start()
|
|
272
|
-
|
|
273
269
|
if on_message := config.code.on_message:
|
|
274
270
|
await on_message(msg)
|
|
275
271
|
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": {
|
|
3
|
+
"atoms": {
|
|
4
|
+
"buttons": {
|
|
5
|
+
"userButton": {
|
|
6
|
+
"menu": {
|
|
7
|
+
"settings": "设置",
|
|
8
|
+
"settingsKey": "S",
|
|
9
|
+
"APIKeys": "API 密钥",
|
|
10
|
+
"logout": "登出"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"molecules": {
|
|
16
|
+
"newChatButton": {
|
|
17
|
+
"newChat": "新建对话"
|
|
18
|
+
},
|
|
19
|
+
"tasklist": {
|
|
20
|
+
"TaskList": {
|
|
21
|
+
"title": "\ud83d\uddd2\ufe0f 任务列表",
|
|
22
|
+
"loading": "加载中...",
|
|
23
|
+
"error": "发生错误"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"attachments": {
|
|
27
|
+
"cancelUpload": "取消上传",
|
|
28
|
+
"removeAttachment": "移除附件"
|
|
29
|
+
},
|
|
30
|
+
"newChatDialog": {
|
|
31
|
+
"createNewChat": "创建新对话?",
|
|
32
|
+
"clearChat": "这将清除当前消息并开始新的对话。",
|
|
33
|
+
"cancel": "取消",
|
|
34
|
+
"confirm": "确认"
|
|
35
|
+
},
|
|
36
|
+
"settingsModal": {
|
|
37
|
+
"settings": "设置",
|
|
38
|
+
"expandMessages": "展开消息",
|
|
39
|
+
"hideChainOfThought": "隐藏思考链",
|
|
40
|
+
"darkMode": "暗色模式"
|
|
41
|
+
},
|
|
42
|
+
"detailsButton": {
|
|
43
|
+
"using": "使用",
|
|
44
|
+
"used": "已用"
|
|
45
|
+
},
|
|
46
|
+
"auth": {
|
|
47
|
+
"authLogin": {
|
|
48
|
+
"title": "登录以访问应用。",
|
|
49
|
+
"form": {
|
|
50
|
+
"email": "电子邮箱地址",
|
|
51
|
+
"password": "密码",
|
|
52
|
+
"noAccount": "没有账户?",
|
|
53
|
+
"alreadyHaveAccount": "已有账户?",
|
|
54
|
+
"signup": "注册",
|
|
55
|
+
"signin": "登录",
|
|
56
|
+
"or": "或者",
|
|
57
|
+
"continue": "继续",
|
|
58
|
+
"forgotPassword": "忘记密码?",
|
|
59
|
+
"passwordMustContain": "您的密码必须包含:",
|
|
60
|
+
"emailRequired": "电子邮箱是必填项",
|
|
61
|
+
"passwordRequired": "密码是必填项"
|
|
62
|
+
},
|
|
63
|
+
"error": {
|
|
64
|
+
"default": "无法登录。",
|
|
65
|
+
"signin": "尝试使用不同的账户登录。",
|
|
66
|
+
"oauthsignin": "尝试使用不同的账户登录。",
|
|
67
|
+
"redirect_uri_mismatch": "重定向URI与OAuth应用配置不匹配。",
|
|
68
|
+
"oauthcallbackerror": "尝试使用不同的账户登录。",
|
|
69
|
+
"oauthcreateaccount": "尝试使用不同的账户登录。",
|
|
70
|
+
"emailcreateaccount": "尝试使用不同的账户登录。",
|
|
71
|
+
"callback": "尝试使用不同的账户登录。",
|
|
72
|
+
"oauthaccountnotlinked": "为了验证您的身份,请使用最初使用的同一账户登录。",
|
|
73
|
+
"emailsignin": "无法发送邮件。",
|
|
74
|
+
"emailverify": "请验证您的电子邮件,已发送一封新邮件。",
|
|
75
|
+
"credentialssignin": "登录失败。请检查您提供的详细信息是否正确。",
|
|
76
|
+
"sessionrequired": "请登录以访问此页面。"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"authVerifyEmail": {
|
|
80
|
+
"almostThere": "您快成功了!我们已向 ",
|
|
81
|
+
"verifyEmailLink": "请单击该邮件中的链接以完成注册。",
|
|
82
|
+
"didNotReceive": "没找到邮件?",
|
|
83
|
+
"resendEmail": "重新发送邮件",
|
|
84
|
+
"goBack": "返回",
|
|
85
|
+
"emailSent": "邮件已成功发送。",
|
|
86
|
+
"verifyEmail": "验证您的电子邮件地址"
|
|
87
|
+
},
|
|
88
|
+
"providerButton": {
|
|
89
|
+
"continue": "使用{{provider}}继续",
|
|
90
|
+
"signup": "使用{{provider}}注册"
|
|
91
|
+
},
|
|
92
|
+
"authResetPassword": {
|
|
93
|
+
"newPasswordRequired": "新密码是必填项",
|
|
94
|
+
"passwordsMustMatch": "密码必须一致",
|
|
95
|
+
"confirmPasswordRequired": "确认密码是必填项",
|
|
96
|
+
"newPassword": "新密码",
|
|
97
|
+
"confirmPassword": "确认密码",
|
|
98
|
+
"resetPassword": "重置密码"
|
|
99
|
+
},
|
|
100
|
+
"authForgotPassword": {
|
|
101
|
+
"email": "电子邮箱地址",
|
|
102
|
+
"emailRequired": "电子邮箱是必填项",
|
|
103
|
+
"emailSent": "请检查电子邮箱{{email}}以获取重置密码的指示。",
|
|
104
|
+
"enterEmail": "请输入您的电子邮箱地址,我们将发送重置密码的指示。",
|
|
105
|
+
"resendEmail": "重新发送邮件",
|
|
106
|
+
"continue": "继续",
|
|
107
|
+
"goBack": "返回"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"organisms": {
|
|
112
|
+
"chat": {
|
|
113
|
+
"history": {
|
|
114
|
+
"index": {
|
|
115
|
+
"showHistory": "显示历史",
|
|
116
|
+
"lastInputs": "最后输入",
|
|
117
|
+
"noInputs": "如此空旷...",
|
|
118
|
+
"loading": "加载中..."
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"inputBox": {
|
|
122
|
+
"input": {
|
|
123
|
+
"placeholder": "在这里输入您的消息..."
|
|
124
|
+
},
|
|
125
|
+
"speechButton": {
|
|
126
|
+
"start": "开始录音",
|
|
127
|
+
"stop": "停止录音"
|
|
128
|
+
},
|
|
129
|
+
"SubmitButton": {
|
|
130
|
+
"sendMessage": "发送消息",
|
|
131
|
+
"stopTask": "停止任务"
|
|
132
|
+
},
|
|
133
|
+
"UploadButton": {
|
|
134
|
+
"attachFiles": "附加文件"
|
|
135
|
+
},
|
|
136
|
+
"waterMark": {
|
|
137
|
+
"text": "使用"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"Messages": {
|
|
141
|
+
"index": {
|
|
142
|
+
"running": "运行中",
|
|
143
|
+
"executedSuccessfully": "执行成功",
|
|
144
|
+
"failed": "失败",
|
|
145
|
+
"feedbackUpdated": "反馈更新",
|
|
146
|
+
"updating": "正在更新"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"dropScreen": {
|
|
150
|
+
"dropYourFilesHere": "在这里拖放您的文件"
|
|
151
|
+
},
|
|
152
|
+
"index": {
|
|
153
|
+
"failedToUpload": "上传失败",
|
|
154
|
+
"cancelledUploadOf": "取消上传",
|
|
155
|
+
"couldNotReachServer": "无法连接到服务器",
|
|
156
|
+
"continuingChat": "继续之前的对话"
|
|
157
|
+
},
|
|
158
|
+
"settings": {
|
|
159
|
+
"settingsPanel": "设置面板",
|
|
160
|
+
"reset": "重置",
|
|
161
|
+
"cancel": "取消",
|
|
162
|
+
"confirm": "确认"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"threadHistory": {
|
|
166
|
+
"sidebar": {
|
|
167
|
+
"filters": {
|
|
168
|
+
"FeedbackSelect": {
|
|
169
|
+
"feedbackAll": "反馈:全部",
|
|
170
|
+
"feedbackPositive": "反馈:正面",
|
|
171
|
+
"feedbackNegative": "反馈:负面"
|
|
172
|
+
},
|
|
173
|
+
"SearchBar": {
|
|
174
|
+
"search": "搜索"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"DeleteThreadButton": {
|
|
178
|
+
"confirmMessage": "这将删除线程及其消息和元素。",
|
|
179
|
+
"cancel": "取消",
|
|
180
|
+
"confirm": "确认",
|
|
181
|
+
"deletingChat": "删除对话",
|
|
182
|
+
"chatDeleted": "对话已删除"
|
|
183
|
+
},
|
|
184
|
+
"index": {
|
|
185
|
+
"pastChats": "过往对话"
|
|
186
|
+
},
|
|
187
|
+
"ThreadList": {
|
|
188
|
+
"empty": "空的...",
|
|
189
|
+
"today": "今天",
|
|
190
|
+
"yesterday": "昨天",
|
|
191
|
+
"previous7days": "前7天",
|
|
192
|
+
"previous30days": "前30天"
|
|
193
|
+
},
|
|
194
|
+
"TriggerButton": {
|
|
195
|
+
"closeSidebar": "关闭侧边栏",
|
|
196
|
+
"openSidebar": "打开侧边栏"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"Thread": {
|
|
200
|
+
"backToChat": "返回对话",
|
|
201
|
+
"chatCreatedOn": "此对话创建于"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"header": {
|
|
205
|
+
"chat": "对话",
|
|
206
|
+
"readme": "说明"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"hooks": {
|
|
211
|
+
"useLLMProviders": {
|
|
212
|
+
"failedToFetchProviders": "获取提供者失败:"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"pages": {
|
|
216
|
+
"Design": {},
|
|
217
|
+
"Env": {
|
|
218
|
+
"savedSuccessfully": "保存成功",
|
|
219
|
+
"requiredApiKeys": "必需的API密钥",
|
|
220
|
+
"requiredApiKeysInfo": "要使用此应用,需要以下API密钥。这些密钥存储在您的设备本地存储中。"
|
|
221
|
+
},
|
|
222
|
+
"Page": {
|
|
223
|
+
"notPartOfProject": "您不是此项目的一部分。"
|
|
224
|
+
},
|
|
225
|
+
"ResumeButton": {
|
|
226
|
+
"resumeChat": "恢复对话"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
chainlit/user.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Dict, Literal, TypedDict
|
|
1
|
+
from typing import Dict, Literal, Optional, TypedDict
|
|
2
2
|
|
|
3
3
|
from dataclasses_json import DataClassJsonMixin
|
|
4
4
|
from pydantic.dataclasses import Field, dataclass
|
|
@@ -19,6 +19,7 @@ Provider = Literal[
|
|
|
19
19
|
class UserDict(TypedDict):
|
|
20
20
|
id: str
|
|
21
21
|
identifier: str
|
|
22
|
+
display_name: Optional[str]
|
|
22
23
|
metadata: Dict
|
|
23
24
|
|
|
24
25
|
|
|
@@ -26,6 +27,7 @@ class UserDict(TypedDict):
|
|
|
26
27
|
@dataclass
|
|
27
28
|
class User(DataClassJsonMixin):
|
|
28
29
|
identifier: str
|
|
30
|
+
display_name: Optional[str] = None
|
|
29
31
|
metadata: Dict = Field(default_factory=dict)
|
|
30
32
|
|
|
31
33
|
|