chainlit 1.1.202__py3-none-any.whl → 1.1.300rc0__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/__init__.py +19 -3
- chainlit/config.py +21 -18
- chainlit/copilot/dist/index.js +429 -396
- chainlit/data/__init__.py +16 -5
- chainlit/data/sql_alchemy.py +44 -25
- chainlit/discord/app.py +4 -2
- chainlit/element.py +4 -12
- chainlit/frontend/dist/assets/{DailyMotion-53376209.js → DailyMotion-e54bf0dc.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-aee41f5b.js → Facebook-a767c817.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-b2cdb30f.js → FilePlayer-5d19f3d1.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-51db0377.js → Kaltura-93bef413.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-cb900886.js → Mixcloud-d5d27c2a.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-79ac59e6.js → Mux-ad063035.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-cfe7584c.js → Preview-a9a0e47e.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-a985707c.js → SoundCloud-1698c4da.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-3d89aab5.js → Streamable-e5832da9.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-bf016588.js → Twitch-cd321ef4.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-1891ecd7.js → Vidyard-8646c638.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-0645662c.js → Vimeo-0e590e3a.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-3b449fe2.js → Wistia-76f0c9b0.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-5ea2381e.js → YouTube-a94756f4.js} +1 -1
- chainlit/frontend/dist/assets/index-51fef15f.js +727 -0
- chainlit/frontend/dist/assets/index-53c62926.css +1 -0
- chainlit/frontend/dist/assets/{react-plotly-2ff19c9f.js → react-plotly-d9ffbf69.js} +1 -1
- chainlit/frontend/dist/index.html +2 -2
- chainlit/langchain/callbacks.py +4 -2
- chainlit/llama_index/callbacks.py +2 -2
- chainlit/message.py +17 -17
- chainlit/server.py +38 -38
- chainlit/slack/app.py +0 -1
- chainlit/socket.py +1 -3
- chainlit/step.py +24 -25
- chainlit/translations/en-US.json +1 -3
- chainlit/types.py +10 -0
- chainlit/utils.py +4 -3
- {chainlit-1.1.202.dist-info → chainlit-1.1.300rc0.dist-info}/METADATA +6 -7
- chainlit-1.1.300rc0.dist-info/RECORD +77 -0
- chainlit/frontend/dist/assets/index-a0c5a67e.js +0 -698
- chainlit/frontend/dist/assets/index-d088547c.css +0 -1
- chainlit/playground/__init__.py +0 -2
- chainlit/playground/config.py +0 -36
- chainlit/playground/provider.py +0 -108
- chainlit/playground/providers/__init__.py +0 -11
- chainlit/playground/providers/anthropic.py +0 -118
- chainlit/playground/providers/huggingface.py +0 -75
- chainlit/playground/providers/langchain.py +0 -89
- chainlit/playground/providers/openai.py +0 -386
- chainlit/playground/providers/vertexai.py +0 -171
- chainlit-1.1.202.dist-info/RECORD +0 -86
- {chainlit-1.1.202.dist-info → chainlit-1.1.300rc0.dist-info}/WHEEL +0 -0
- {chainlit-1.1.202.dist-info → chainlit-1.1.300rc0.dist-info}/entry_points.txt +0 -0
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
<script>
|
|
23
23
|
const global = globalThis;
|
|
24
24
|
</script>
|
|
25
|
-
<script type="module" crossorigin src="/assets/index-
|
|
26
|
-
<link rel="stylesheet" href="/assets/index-
|
|
25
|
+
<script type="module" crossorigin src="/assets/index-51fef15f.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="/assets/index-53c62926.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="root"></div>
|
chainlit/langchain/callbacks.py
CHANGED
|
@@ -456,7 +456,7 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
456
456
|
elif run.run_type == "llm":
|
|
457
457
|
step_type = "llm"
|
|
458
458
|
elif run.run_type == "retriever":
|
|
459
|
-
step_type = "
|
|
459
|
+
step_type = "tool"
|
|
460
460
|
elif run.run_type == "tool":
|
|
461
461
|
step_type = "tool"
|
|
462
462
|
elif run.run_type == "embedding":
|
|
@@ -533,7 +533,9 @@ class LangchainTracer(BaseTracer, GenerationHelper, FinalStreamHelper):
|
|
|
533
533
|
break
|
|
534
534
|
|
|
535
535
|
current_step.language = "json"
|
|
536
|
-
current_step.output = json.dumps(
|
|
536
|
+
current_step.output = json.dumps(
|
|
537
|
+
message_completion, indent=4, ensure_ascii=False
|
|
538
|
+
)
|
|
537
539
|
else:
|
|
538
540
|
completion_start = self.completion_generations[str(run.id)]
|
|
539
541
|
completion = generation.get("text", "")
|
|
@@ -73,9 +73,9 @@ class LlamaIndexCallbackHandler(TokenCountingHandler):
|
|
|
73
73
|
|
|
74
74
|
step_type: StepType = "undefined"
|
|
75
75
|
if event_type == CBEventType.RETRIEVE:
|
|
76
|
-
step_type = "
|
|
76
|
+
step_type = "tool"
|
|
77
77
|
elif event_type == CBEventType.QUERY:
|
|
78
|
-
step_type = "
|
|
78
|
+
step_type = "tool"
|
|
79
79
|
elif event_type == CBEventType.LLM:
|
|
80
80
|
step_type = "llm"
|
|
81
81
|
else:
|
chainlit/message.py
CHANGED
|
@@ -173,21 +173,21 @@ class MessageBase(ABC):
|
|
|
173
173
|
Sends a token to the UI. This is useful for streaming messages.
|
|
174
174
|
Once all tokens have been streamed, call .send() to end the stream and persist the message if persistence is enabled.
|
|
175
175
|
"""
|
|
176
|
-
|
|
177
|
-
if not self.streaming:
|
|
178
|
-
self.streaming = True
|
|
179
|
-
step_dict = self.to_dict()
|
|
180
|
-
await context.emitter.stream_start(step_dict)
|
|
181
|
-
|
|
182
176
|
if is_sequence:
|
|
183
177
|
self.content = token
|
|
184
178
|
else:
|
|
185
179
|
self.content += token
|
|
186
180
|
|
|
187
181
|
assert self.id
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
|
|
183
|
+
if not self.streaming:
|
|
184
|
+
self.streaming = True
|
|
185
|
+
step_dict = self.to_dict()
|
|
186
|
+
await context.emitter.stream_start(step_dict)
|
|
187
|
+
else:
|
|
188
|
+
await context.emitter.send_token(
|
|
189
|
+
id=self.id, token=token, is_sequence=is_sequence
|
|
190
|
+
)
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
class Message(MessageBase):
|
|
@@ -196,7 +196,7 @@ class Message(MessageBase):
|
|
|
196
196
|
|
|
197
197
|
Args:
|
|
198
198
|
content (Union[str, Dict]): The content of the message.
|
|
199
|
-
author (str, optional): The author of the message, this will be used in the UI. Defaults to the
|
|
199
|
+
author (str, optional): The author of the message, this will be used in the UI. Defaults to the assistant name (see config).
|
|
200
200
|
language (str, optional): Language of the code is the content is code. See https://react-code-blocks-rajinwonderland.vercel.app/?path=/story/codeblock--supported-languages for a list of supported languages.
|
|
201
201
|
actions (List[Action], optional): A list of actions to send with the message.
|
|
202
202
|
elements (List[ElementBased], optional): A list of elements to send with the message.
|
|
@@ -303,7 +303,7 @@ class ErrorMessage(MessageBase):
|
|
|
303
303
|
|
|
304
304
|
Args:
|
|
305
305
|
content (str): Text displayed above the upload button.
|
|
306
|
-
author (str, optional): The author of the message, this will be used in the UI. Defaults to the
|
|
306
|
+
author (str, optional): The author of the message, this will be used in the UI. Defaults to the assistant name (see config).
|
|
307
307
|
parent_id (str, optional): If provided, the message will be nested inside the parent in the UI.
|
|
308
308
|
indent (int, optional): If positive, the message will be nested in the UI.
|
|
309
309
|
"""
|
|
@@ -316,7 +316,7 @@ class ErrorMessage(MessageBase):
|
|
|
316
316
|
):
|
|
317
317
|
self.content = content
|
|
318
318
|
self.author = author
|
|
319
|
-
self.type = "
|
|
319
|
+
self.type = "assistant_message"
|
|
320
320
|
self.is_error = True
|
|
321
321
|
self.fail_on_persist_error = fail_on_persist_error
|
|
322
322
|
|
|
@@ -346,7 +346,7 @@ class AskUserMessage(AskMessageBase):
|
|
|
346
346
|
|
|
347
347
|
Args:
|
|
348
348
|
content (str): The content of the prompt.
|
|
349
|
-
author (str, optional): The author of the message, this will be used in the UI. Defaults to the
|
|
349
|
+
author (str, optional): The author of the message, this will be used in the UI. Defaults to the assistant name (see config).
|
|
350
350
|
disable_feedback (bool, optional): Hide the feedback buttons for this specific message
|
|
351
351
|
timeout (int, optional): The number of seconds to wait for an answer before raising a TimeoutError.
|
|
352
352
|
raise_on_timeout (bool, optional): Whether to raise a socketio TimeoutError if the user does not answer in time.
|
|
@@ -357,7 +357,7 @@ class AskUserMessage(AskMessageBase):
|
|
|
357
357
|
content: str,
|
|
358
358
|
author: str = config.ui.name,
|
|
359
359
|
type: MessageStepType = "assistant_message",
|
|
360
|
-
disable_feedback: bool =
|
|
360
|
+
disable_feedback: bool = True,
|
|
361
361
|
timeout: int = 60,
|
|
362
362
|
raise_on_timeout: bool = False,
|
|
363
363
|
):
|
|
@@ -411,7 +411,7 @@ class AskFileMessage(AskMessageBase):
|
|
|
411
411
|
accept (Union[List[str], Dict[str, List[str]]]): List of mime type to accept like ["text/csv", "application/pdf"] or a dict like {"text/plain": [".txt", ".py"]}.
|
|
412
412
|
max_size_mb (int, optional): Maximum size per file in MB. Maximum value is 100.
|
|
413
413
|
max_files (int, optional): Maximum number of files to upload. Maximum value is 10.
|
|
414
|
-
author (str, optional): The author of the message, this will be used in the UI. Defaults to the
|
|
414
|
+
author (str, optional): The author of the message, this will be used in the UI. Defaults to the assistant name (see config).
|
|
415
415
|
disable_feedback (bool, optional): Hide the feedback buttons for this specific message
|
|
416
416
|
timeout (int, optional): The number of seconds to wait for an answer before raising a TimeoutError.
|
|
417
417
|
raise_on_timeout (bool, optional): Whether to raise a socketio TimeoutError if the user does not answer in time.
|
|
@@ -425,7 +425,7 @@ class AskFileMessage(AskMessageBase):
|
|
|
425
425
|
max_files=1,
|
|
426
426
|
author=config.ui.name,
|
|
427
427
|
type: MessageStepType = "assistant_message",
|
|
428
|
-
disable_feedback: bool =
|
|
428
|
+
disable_feedback: bool = True,
|
|
429
429
|
timeout=90,
|
|
430
430
|
raise_on_timeout=False,
|
|
431
431
|
):
|
|
@@ -501,7 +501,7 @@ class AskActionMessage(AskMessageBase):
|
|
|
501
501
|
content: str,
|
|
502
502
|
actions: List[Action],
|
|
503
503
|
author=config.ui.name,
|
|
504
|
-
disable_feedback=
|
|
504
|
+
disable_feedback=True,
|
|
505
505
|
timeout=90,
|
|
506
506
|
raise_on_timeout=False,
|
|
507
507
|
):
|
chainlit/server.py
CHANGED
|
@@ -33,7 +33,6 @@ from chainlit.data import get_data_layer
|
|
|
33
33
|
from chainlit.data.acl import is_thread_author
|
|
34
34
|
from chainlit.logger import logger
|
|
35
35
|
from chainlit.markdown import get_markdown_str
|
|
36
|
-
from chainlit.playground.config import get_llm_providers
|
|
37
36
|
from chainlit.telemetry import trace_event
|
|
38
37
|
from chainlit.types import (
|
|
39
38
|
DeleteFeedbackRequest,
|
|
@@ -153,9 +152,9 @@ def get_build_dir(local_target: str, packaged_target: str):
|
|
|
153
152
|
packaged_build_dir = os.path.join(BACKEND_ROOT, packaged_target, "dist")
|
|
154
153
|
|
|
155
154
|
if config.ui.custom_build and os.path.exists(
|
|
156
|
-
os.path.join(APP_ROOT, config.ui.custom_build
|
|
155
|
+
os.path.join(APP_ROOT, config.ui.custom_build)
|
|
157
156
|
):
|
|
158
|
-
return os.path.join(APP_ROOT, config.ui.custom_build
|
|
157
|
+
return os.path.join(APP_ROOT, config.ui.custom_build)
|
|
159
158
|
elif os.path.exists(local_build_dir):
|
|
160
159
|
return local_build_dir
|
|
161
160
|
elif os.path.exists(packaged_build_dir):
|
|
@@ -234,7 +233,9 @@ def get_html_template():
|
|
|
234
233
|
CSS_PLACEHOLDER = "<!-- CSS INJECTION PLACEHOLDER -->"
|
|
235
234
|
|
|
236
235
|
default_url = "https://github.com/Chainlit/chainlit"
|
|
237
|
-
default_meta_image_url =
|
|
236
|
+
default_meta_image_url = (
|
|
237
|
+
"https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"
|
|
238
|
+
)
|
|
238
239
|
url = config.ui.github or default_url
|
|
239
240
|
meta_image_url = config.ui.custom_meta_image_url or default_meta_image_url
|
|
240
241
|
|
|
@@ -496,40 +497,6 @@ async def oauth_callback(
|
|
|
496
497
|
return response
|
|
497
498
|
|
|
498
499
|
|
|
499
|
-
@app.post("/generation")
|
|
500
|
-
async def generation(
|
|
501
|
-
request: GenerationRequest,
|
|
502
|
-
current_user: Annotated[Union[User, PersistedUser], Depends(get_current_user)],
|
|
503
|
-
):
|
|
504
|
-
"""Handle a completion request from the prompt playground."""
|
|
505
|
-
|
|
506
|
-
providers = get_llm_providers()
|
|
507
|
-
|
|
508
|
-
try:
|
|
509
|
-
provider = [p for p in providers if p.id == request.generation.provider][0]
|
|
510
|
-
except IndexError:
|
|
511
|
-
raise HTTPException(
|
|
512
|
-
status_code=404,
|
|
513
|
-
detail=f"LLM provider '{request.generation.provider}' not found",
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
trace_event("pp_create_completion")
|
|
517
|
-
response = await provider.create_completion(request)
|
|
518
|
-
|
|
519
|
-
return response
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
@app.get("/project/llm-providers")
|
|
523
|
-
async def get_providers(
|
|
524
|
-
current_user: Annotated[Union[User, PersistedUser], Depends(get_current_user)]
|
|
525
|
-
):
|
|
526
|
-
"""List the providers."""
|
|
527
|
-
trace_event("pp_get_llm_providers")
|
|
528
|
-
providers = get_llm_providers()
|
|
529
|
-
providers = [p.to_dict() for p in providers]
|
|
530
|
-
return JSONResponse(content={"providers": providers})
|
|
531
|
-
|
|
532
|
-
|
|
533
500
|
@app.get("/project/translations")
|
|
534
501
|
async def project_translations(
|
|
535
502
|
language: str = Query(default="en-US", description="Language code"),
|
|
@@ -562,9 +529,21 @@ async def project_settings(
|
|
|
562
529
|
if chat_profiles:
|
|
563
530
|
profiles = [p.to_dict() for p in chat_profiles]
|
|
564
531
|
|
|
532
|
+
starters = []
|
|
533
|
+
if config.code.set_starters:
|
|
534
|
+
starters = await config.code.set_starters(current_user)
|
|
535
|
+
if starters:
|
|
536
|
+
starters = [s.to_dict() for s in starters]
|
|
537
|
+
|
|
565
538
|
if config.code.on_audio_chunk:
|
|
566
539
|
config.features.audio.enabled = True
|
|
567
540
|
|
|
541
|
+
debug_url = None
|
|
542
|
+
data_layer = get_data_layer()
|
|
543
|
+
|
|
544
|
+
if data_layer and config.run.debug:
|
|
545
|
+
debug_url = await data_layer.build_debug_url()
|
|
546
|
+
|
|
568
547
|
return JSONResponse(
|
|
569
548
|
content={
|
|
570
549
|
"ui": config.ui.to_dict(),
|
|
@@ -574,6 +553,8 @@ async def project_settings(
|
|
|
574
553
|
"threadResumable": bool(config.code.on_chat_resume),
|
|
575
554
|
"markdown": markdown,
|
|
576
555
|
"chatProfiles": profiles,
|
|
556
|
+
"starters": starters,
|
|
557
|
+
"debugUrl": debug_url,
|
|
577
558
|
}
|
|
578
559
|
)
|
|
579
560
|
|
|
@@ -812,6 +793,25 @@ async def get_logo(theme: Optional[Theme] = Query(Theme.light)):
|
|
|
812
793
|
return FileResponse(logo_path, media_type=media_type)
|
|
813
794
|
|
|
814
795
|
|
|
796
|
+
@app.get("/avatars/{avatar_id}")
|
|
797
|
+
async def get_avatar(avatar_id: str):
|
|
798
|
+
if avatar_id == "default":
|
|
799
|
+
avatar_id = config.ui.name
|
|
800
|
+
|
|
801
|
+
avatar_id = avatar_id.strip().lower().replace(" ", "_")
|
|
802
|
+
|
|
803
|
+
avatar_path = os.path.join(APP_ROOT, "public", "avatars", f"{avatar_id}.*")
|
|
804
|
+
|
|
805
|
+
files = glob.glob(avatar_path)
|
|
806
|
+
|
|
807
|
+
if files:
|
|
808
|
+
avatar_path = files[0]
|
|
809
|
+
media_type, _ = mimetypes.guess_type(avatar_path)
|
|
810
|
+
return FileResponse(avatar_path, media_type=media_type)
|
|
811
|
+
else:
|
|
812
|
+
return await get_favicon()
|
|
813
|
+
|
|
814
|
+
|
|
815
815
|
@app.head("/")
|
|
816
816
|
def status_check():
|
|
817
817
|
return {"message": "Site is operational"}
|
chainlit/slack/app.py
CHANGED
chainlit/socket.py
CHANGED
|
@@ -233,9 +233,7 @@ async def stop(sid):
|
|
|
233
233
|
trace_event("stop_task")
|
|
234
234
|
|
|
235
235
|
init_ws_context(session)
|
|
236
|
-
await Message(
|
|
237
|
-
author="System", content="Task manually stopped.", disable_feedback=True
|
|
238
|
-
).send()
|
|
236
|
+
await Message(content="Task manually stopped.", disable_feedback=True).send()
|
|
239
237
|
|
|
240
238
|
if session.current_task:
|
|
241
239
|
session.current_task.cancel()
|
chainlit/step.py
CHANGED
|
@@ -50,7 +50,6 @@ def step(
|
|
|
50
50
|
id: Optional[str] = None,
|
|
51
51
|
tags: Optional[List[str]] = None,
|
|
52
52
|
disable_feedback: bool = True,
|
|
53
|
-
root: bool = False,
|
|
54
53
|
language: Optional[str] = None,
|
|
55
54
|
show_input: Union[bool, str] = False,
|
|
56
55
|
):
|
|
@@ -72,7 +71,6 @@ def step(
|
|
|
72
71
|
name=name,
|
|
73
72
|
id=id,
|
|
74
73
|
disable_feedback=disable_feedback,
|
|
75
|
-
root=root,
|
|
76
74
|
tags=tags,
|
|
77
75
|
language=language,
|
|
78
76
|
show_input=show_input,
|
|
@@ -85,8 +83,9 @@ def step(
|
|
|
85
83
|
try:
|
|
86
84
|
if result and not step.output:
|
|
87
85
|
step.output = result
|
|
88
|
-
except:
|
|
89
|
-
|
|
86
|
+
except Exception as e:
|
|
87
|
+
step.is_error = True
|
|
88
|
+
step.output = str(e)
|
|
90
89
|
return result
|
|
91
90
|
|
|
92
91
|
return async_wrapper
|
|
@@ -99,7 +98,6 @@ def step(
|
|
|
99
98
|
name=name,
|
|
100
99
|
id=id,
|
|
101
100
|
disable_feedback=disable_feedback,
|
|
102
|
-
root=root,
|
|
103
101
|
tags=tags,
|
|
104
102
|
language=language,
|
|
105
103
|
show_input=show_input,
|
|
@@ -113,7 +111,8 @@ def step(
|
|
|
113
111
|
if result and not step.output:
|
|
114
112
|
step.output = result
|
|
115
113
|
except:
|
|
116
|
-
|
|
114
|
+
step.is_error = True
|
|
115
|
+
step.output = str(e)
|
|
117
116
|
return result
|
|
118
117
|
|
|
119
118
|
return sync_wrapper
|
|
@@ -136,7 +135,6 @@ class Step:
|
|
|
136
135
|
streaming: bool
|
|
137
136
|
persisted: bool
|
|
138
137
|
|
|
139
|
-
root: bool
|
|
140
138
|
show_input: Union[bool, str]
|
|
141
139
|
|
|
142
140
|
is_error: Optional[bool]
|
|
@@ -161,7 +159,6 @@ class Step:
|
|
|
161
159
|
metadata: Optional[Dict] = None,
|
|
162
160
|
tags: Optional[List[str]] = None,
|
|
163
161
|
disable_feedback: bool = True,
|
|
164
|
-
root: bool = False,
|
|
165
162
|
language: Optional[str] = None,
|
|
166
163
|
show_input: Union[bool, str] = False,
|
|
167
164
|
):
|
|
@@ -179,7 +176,6 @@ class Step:
|
|
|
179
176
|
self.is_error = False
|
|
180
177
|
self.show_input = show_input
|
|
181
178
|
self.parent_id = parent_id
|
|
182
|
-
self.root = root
|
|
183
179
|
|
|
184
180
|
self.language = language
|
|
185
181
|
self.generation = None
|
|
@@ -299,11 +295,8 @@ class Step:
|
|
|
299
295
|
tasks = [el.send(for_id=self.id) for el in self.elements]
|
|
300
296
|
await asyncio.gather(*tasks)
|
|
301
297
|
|
|
302
|
-
if config.ui.hide_cot and (self.parent_id or not self.
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
if not config.features.prompt_playground and "generation" in step_dict:
|
|
306
|
-
step_dict.pop("generation", None)
|
|
298
|
+
if config.ui.hide_cot and (self.parent_id or "message" not in self.type):
|
|
299
|
+
return True
|
|
307
300
|
|
|
308
301
|
await context.emitter.update_step(step_dict)
|
|
309
302
|
|
|
@@ -356,12 +349,9 @@ class Step:
|
|
|
356
349
|
tasks = [el.send(for_id=self.id) for el in self.elements]
|
|
357
350
|
await asyncio.gather(*tasks)
|
|
358
351
|
|
|
359
|
-
if config.ui.hide_cot and (self.parent_id or not self.
|
|
352
|
+
if config.ui.hide_cot and (self.parent_id or "message" not in self.type):
|
|
360
353
|
return self
|
|
361
354
|
|
|
362
|
-
if not config.features.prompt_playground and "generation" in step_dict:
|
|
363
|
-
step_dict.pop("generation", None)
|
|
364
|
-
|
|
365
355
|
await context.emitter.send_step(step_dict)
|
|
366
356
|
|
|
367
357
|
return self
|
|
@@ -378,17 +368,17 @@ class Step:
|
|
|
378
368
|
|
|
379
369
|
assert self.id
|
|
380
370
|
|
|
381
|
-
if config.ui.hide_cot and (self.parent_id or not self.
|
|
371
|
+
if config.ui.hide_cot and (self.parent_id or "message" not in self.type):
|
|
382
372
|
return
|
|
383
373
|
|
|
384
374
|
if not self.streaming:
|
|
385
375
|
self.streaming = True
|
|
386
376
|
step_dict = self.to_dict()
|
|
387
377
|
await context.emitter.stream_start(step_dict)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
378
|
+
else:
|
|
379
|
+
await context.emitter.send_token(
|
|
380
|
+
id=self.id, token=token, is_sequence=is_sequence
|
|
381
|
+
)
|
|
392
382
|
|
|
393
383
|
# Handle parameter less decorator
|
|
394
384
|
def __call__(self, func):
|
|
@@ -408,7 +398,7 @@ class Step:
|
|
|
408
398
|
previous_steps = local_steps.get() or []
|
|
409
399
|
parent_step = previous_steps[-1] if previous_steps else None
|
|
410
400
|
|
|
411
|
-
if not self.parent_id
|
|
401
|
+
if not self.parent_id:
|
|
412
402
|
if parent_step:
|
|
413
403
|
self.parent_id = parent_step.id
|
|
414
404
|
elif context.session.root_message:
|
|
@@ -421,6 +411,10 @@ class Step:
|
|
|
421
411
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
422
412
|
self.end = utc_now()
|
|
423
413
|
|
|
414
|
+
if exc_type:
|
|
415
|
+
self.output = str(exc_val)
|
|
416
|
+
self.is_error = True
|
|
417
|
+
|
|
424
418
|
if self in context.active_steps:
|
|
425
419
|
context.active_steps.remove(self)
|
|
426
420
|
|
|
@@ -437,7 +431,7 @@ class Step:
|
|
|
437
431
|
previous_steps = local_steps.get() or []
|
|
438
432
|
parent_step = previous_steps[-1] if previous_steps else None
|
|
439
433
|
|
|
440
|
-
if not self.parent_id
|
|
434
|
+
if not self.parent_id:
|
|
441
435
|
if parent_step:
|
|
442
436
|
self.parent_id = parent_step.id
|
|
443
437
|
elif context.session.root_message:
|
|
@@ -450,6 +444,11 @@ class Step:
|
|
|
450
444
|
|
|
451
445
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
452
446
|
self.end = utc_now()
|
|
447
|
+
|
|
448
|
+
if exc_type:
|
|
449
|
+
self.output = str(exc_val)
|
|
450
|
+
self.is_error = True
|
|
451
|
+
|
|
453
452
|
if self in context.active_steps:
|
|
454
453
|
context.active_steps.remove(self)
|
|
455
454
|
|
chainlit/translations/en-US.json
CHANGED
chainlit/types.py
CHANGED
|
@@ -226,6 +226,15 @@ class Theme(str, Enum):
|
|
|
226
226
|
dark = "dark"
|
|
227
227
|
|
|
228
228
|
|
|
229
|
+
@dataclass
|
|
230
|
+
class Starter(DataClassJsonMixin):
|
|
231
|
+
"""Specification for a starter that can be chosen by the user at the thread start."""
|
|
232
|
+
|
|
233
|
+
label: str
|
|
234
|
+
message: str
|
|
235
|
+
icon: Optional[str] = None
|
|
236
|
+
|
|
237
|
+
|
|
229
238
|
@dataclass
|
|
230
239
|
class ChatProfile(DataClassJsonMixin):
|
|
231
240
|
"""Specification for a chat profile that can be chosen by the user at the thread start."""
|
|
@@ -234,6 +243,7 @@ class ChatProfile(DataClassJsonMixin):
|
|
|
234
243
|
markdown_description: str
|
|
235
244
|
icon: Optional[str] = None
|
|
236
245
|
default: bool = False
|
|
246
|
+
starters: Optional[List[Starter]] = None
|
|
237
247
|
|
|
238
248
|
|
|
239
249
|
FeedbackStrategy = Literal["BINARY"]
|
chainlit/utils.py
CHANGED
|
@@ -44,9 +44,10 @@ def wrap_user_function(user_function: Callable, with_task=False) -> Callable:
|
|
|
44
44
|
pass
|
|
45
45
|
except Exception as e:
|
|
46
46
|
logger.exception(e)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if with_task:
|
|
48
|
+
await ErrorMessage(
|
|
49
|
+
content=str(e) or e.__class__.__name__, author="Error"
|
|
50
|
+
).send()
|
|
50
51
|
finally:
|
|
51
52
|
if with_task:
|
|
52
53
|
await context.emitter.task_end()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chainlit
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.300rc0
|
|
4
4
|
Summary: Build Conversational AI.
|
|
5
5
|
Home-page: https://github.com/Chainlit/chainlit
|
|
6
6
|
License: Apache-2.0 license
|
|
@@ -22,7 +22,7 @@ Requires-Dist: fastapi-socketio (>=0.0.10,<0.0.11)
|
|
|
22
22
|
Requires-Dist: filetype (>=1.2.0,<2.0.0)
|
|
23
23
|
Requires-Dist: httpx (>=0.23.0)
|
|
24
24
|
Requires-Dist: lazify (>=0.4.0,<0.5.0)
|
|
25
|
-
Requires-Dist: literalai (==0.0.
|
|
25
|
+
Requires-Dist: literalai (==0.0.602)
|
|
26
26
|
Requires-Dist: nest-asyncio (>=1.5.6,<2.0.0)
|
|
27
27
|
Requires-Dist: packaging (>=23.1,<24.0)
|
|
28
28
|
Requires-Dist: pydantic (>=1,<3)
|
|
@@ -46,9 +46,6 @@ Description-Content-Type: text/markdown
|
|
|
46
46
|
|
|
47
47
|
**Build production-ready Conversational AI applications in minutes, not weeks ⚡️**
|
|
48
48
|
|
|
49
|
-
> [!NOTE]
|
|
50
|
-
> You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/)! Also available on the Discord `@Chainlit Help`. Proudly built with Chainlit!
|
|
51
|
-
|
|
52
49
|
Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.
|
|
53
50
|
|
|
54
51
|
- ✅ ChatGPT-like application
|
|
@@ -57,9 +54,11 @@ Chainlit is an open-source async Python framework which allows developers to bui
|
|
|
57
54
|
- ✅ Custom frontend (build your own agentic experience)
|
|
58
55
|
- ✅ API Endpoint
|
|
59
56
|
|
|
60
|
-
Full documentation is available [here](https://docs.chainlit.io).
|
|
57
|
+
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!
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
> [!NOTE]
|
|
60
|
+
> Contact us [here](https://forms.gle/BX3UNBLmTF75KgZVA) for **Enterprise Support**.
|
|
61
|
+
> 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.
|
|
63
62
|
|
|
64
63
|
https://github.com/Chainlit/chainlit/assets/13104895/8882af90-fdfa-4b24-8200-1ee96c6c7490
|
|
65
64
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
chainlit/__init__.py,sha256=NQENgJ2GQB4h2IzRtNoO3EdPnk-dI3WEYymenFpmsA8,10995
|
|
2
|
+
chainlit/__main__.py,sha256=7Vg3w3T3qDuz4KDu5lQhLH6lQ3cYdume7gHH7Z1V97U,87
|
|
3
|
+
chainlit/action.py,sha256=k-GsblVHI4DnDWFyF-RZgq3KfdfAFICFh2OBeU4w8N8,1410
|
|
4
|
+
chainlit/auth.py,sha256=lLHePwmwKzX0LiWqpTAtKTdSecrDLqCMSY9Yw4c-TD8,2681
|
|
5
|
+
chainlit/cache.py,sha256=Bv3dT4eHhE6Fq3c6Do0ZTpiyoXgXYewdxTgpYghEd9g,1361
|
|
6
|
+
chainlit/chat_settings.py,sha256=2ByenmwS8O6jQjDVJjhhbLrBPGA5aY2F7R3VvQQxXPk,877
|
|
7
|
+
chainlit/cli/__init__.py,sha256=JEB3Z3VWpzPgcfdSOQ6Z-L7dHdl7A1y47KUZP8H08GQ,4951
|
|
8
|
+
chainlit/cli/utils.py,sha256=mE2d9oOk-B2b9ZvDV1zENoDWxjfMriGP7bVwEFduZP4,717
|
|
9
|
+
chainlit/config.py,sha256=b9Zaab386X6S0k5F9e-epL-AohRvIQZ9RzicyCPAk3s,16581
|
|
10
|
+
chainlit/context.py,sha256=kBnJiKKNhft1nrXFLQnAW6M-_mzMpYqDEFAG5-lrHyo,2813
|
|
11
|
+
chainlit/copilot/dist/assets/logo_dark-2a3cf740.svg,sha256=Kjz3QMh-oh-ag4YatjU0YCPqGF7F8nHh8VUQoJIs01E,8887
|
|
12
|
+
chainlit/copilot/dist/assets/logo_light-b078e7bc.svg,sha256=sHjnvEq1rfqh3bcexJNYUY7WEDdTQZq3aKZYpi4w4ck,8889
|
|
13
|
+
chainlit/copilot/dist/index.js,sha256=Xu_6ZFSc1Pj06-f8l0S66VACGMWdQCLTZyIiw1jVQFo,6749304
|
|
14
|
+
chainlit/data/__init__.py,sha256=E0NmYlxi0v4V17zKI2btAMKHWyK8kXamVMEQF0m7TPU,16984
|
|
15
|
+
chainlit/data/acl.py,sha256=5EwZuKVcZediw77L661MohGce3JzGIaYmw6NutmMTw0,578
|
|
16
|
+
chainlit/data/sql_alchemy.py,sha256=lY_5fg7LY0zcBZfsfxHYIhC5taM1MCatH9-CLgpg-Vk,26821
|
|
17
|
+
chainlit/data/storage_clients.py,sha256=D9KY1XKDjZh2uuh01ECxeoEtjw-JlrCR-WCuOuePVQI,3007
|
|
18
|
+
chainlit/discord/__init__.py,sha256=kZ_AAMaCToqO-1FdeQ8_IHS2pqNT0QJ-yyd8bCMaHHs,198
|
|
19
|
+
chainlit/discord/app.py,sha256=KvBS-bL89tKzzz2-lqCQVaI2hb4qYTyhl_TzCdhMfHQ,10540
|
|
20
|
+
chainlit/element.py,sha256=qhXq9b6NtvKePHNpyft9QzYS-O2h7zlhsRDCjOmsAhg,10549
|
|
21
|
+
chainlit/emitter.py,sha256=54MPYoYHkOCKJvT30Vvg9mWYzWunGN9I3cFaqIoQ8oU,13037
|
|
22
|
+
chainlit/frontend/dist/assets/DailyMotion-e54bf0dc.js,sha256=24Xl96SqTSvpoC1L5tkqfw-a685rGVMY2VYJY1ne1-w,2961
|
|
23
|
+
chainlit/frontend/dist/assets/Facebook-a767c817.js,sha256=C5yLZLECrqjwxO4FUn2WR2HB_QnM6giru0nOkwRX8M8,3216
|
|
24
|
+
chainlit/frontend/dist/assets/FilePlayer-5d19f3d1.js,sha256=SfpQT7Ukmcufcj0Fob1neCdH9LIo532sbcoWGibAkPk,9041
|
|
25
|
+
chainlit/frontend/dist/assets/Kaltura-93bef413.js,sha256=yiX6xfZL_1VJINw2Qz2-JU8gDavSeY_HqialOkBbyB0,2790
|
|
26
|
+
chainlit/frontend/dist/assets/Mixcloud-d5d27c2a.js,sha256=Jo8sSYAGGp8tqZ4FVvR1Cwg80IygEgMvQXnERgS0m9c,2638
|
|
27
|
+
chainlit/frontend/dist/assets/Mux-ad063035.js,sha256=eaUjBR3dX2FtoTS50IW2ThBThfQ3jJMoAyU-AGBdP5E,5360
|
|
28
|
+
chainlit/frontend/dist/assets/Preview-a9a0e47e.js,sha256=bnp9f1WzhjkOifiKEUvPDty798I5hx2KTRlr2eH5B6M,3011
|
|
29
|
+
chainlit/frontend/dist/assets/SoundCloud-1698c4da.js,sha256=Vq_LSG7FvnhfSQVf4rvDC8yqvD788m9YuVKuVMzDteA,2923
|
|
30
|
+
chainlit/frontend/dist/assets/Streamable-e5832da9.js,sha256=U8iKcleacnxzOiSgI1PUpUDczLoX9S1LlJXMHhKJxxY,2935
|
|
31
|
+
chainlit/frontend/dist/assets/Twitch-cd321ef4.js,sha256=AVTGn9uXl3LhVgjZcGpabx7qJonv73uL0VQKxa4XGv4,3083
|
|
32
|
+
chainlit/frontend/dist/assets/Vidyard-8646c638.js,sha256=xhNjHVX_nTvYUae5v-Cp0-wPXIEA58LCJB8T7inA7CM,2857
|
|
33
|
+
chainlit/frontend/dist/assets/Vimeo-0e590e3a.js,sha256=eIlhe6MvWSMPZw2lk3609AO8bCxcSPDtsqobdvr28Kw,3627
|
|
34
|
+
chainlit/frontend/dist/assets/Wistia-76f0c9b0.js,sha256=BlCGykDsVA9AoyWY78coEoMaE-ckrgiaWBjYllGgKX4,3514
|
|
35
|
+
chainlit/frontend/dist/assets/YouTube-a94756f4.js,sha256=yw8J-DKrk4XkbUKIfqPWYVW6PklBjknEzAjdoVQbX5U,4448
|
|
36
|
+
chainlit/frontend/dist/assets/index-51fef15f.js,sha256=wEpCSTpE3OQDf03qrMXy8sEJLJyuiXZHABTw4FCM4YY,2751506
|
|
37
|
+
chainlit/frontend/dist/assets/index-53c62926.css,sha256=U8YpJoRn8y4ZXI1mRdKl9fIDXCS9Fs9N7gaugq9P9jc,2640
|
|
38
|
+
chainlit/frontend/dist/assets/logo_dark-2a3cf740.svg,sha256=Kjz3QMh-oh-ag4YatjU0YCPqGF7F8nHh8VUQoJIs01E,8887
|
|
39
|
+
chainlit/frontend/dist/assets/logo_light-b078e7bc.svg,sha256=sHjnvEq1rfqh3bcexJNYUY7WEDdTQZq3aKZYpi4w4ck,8889
|
|
40
|
+
chainlit/frontend/dist/assets/react-plotly-d9ffbf69.js,sha256=uAPeLExciHnNG9NeJ4dLDgaifieMV_ZCzl5VhdYF8Lw,3739251
|
|
41
|
+
chainlit/frontend/dist/favicon.svg,sha256=0Cy8x28obT5eWW3nxZRhsEvu6_zMqrqbg0y6hT3D0Q0,6455
|
|
42
|
+
chainlit/frontend/dist/index.html,sha256=63ECKq4CjbL_YMB4exOG5H_P9G8ynOTUmJzSJYg0hlI,1005
|
|
43
|
+
chainlit/haystack/__init__.py,sha256=uZ77YiPy-qleSTi3dQCDO9HE6S6F6GpJWmh7jO4cxXA,217
|
|
44
|
+
chainlit/haystack/callbacks.py,sha256=tItLc6OmskPeDEJH2Qjtg7KgAgIy1TuYQYHTZm9cr3U,5209
|
|
45
|
+
chainlit/hello.py,sha256=LwENQWo5s5r8nNDn4iKSV77vX60Ky5r_qGjQhyi7qlY,416
|
|
46
|
+
chainlit/input_widget.py,sha256=KmOn1nPTBvnld3iIBHR0Vih0KsCxVnTbo2t_xBNANzo,4949
|
|
47
|
+
chainlit/langchain/__init__.py,sha256=zErMw0_3ufSGeF9ye7X0ZX3wDat4mTOx97T40ePDO2g,217
|
|
48
|
+
chainlit/langchain/callbacks.py,sha256=MHl_m6FYZmCzn0e2KOlZpd6ld0rSP1LzuCKs4Eh_N_8,20517
|
|
49
|
+
chainlit/langflow/__init__.py,sha256=wxhxdsl1yxdsRyNTgZticxFF_8VFtJJ4OdIy3tnEIyM,817
|
|
50
|
+
chainlit/llama_index/__init__.py,sha256=weRoIWCaRBGvA1LczCEfsqhWsltQSVlhtRnTovtdo8w,227
|
|
51
|
+
chainlit/llama_index/callbacks.py,sha256=THFmwotSF_ibqFuaQgxGvEjgKmmzoGJKNlVI75SI2ig,7267
|
|
52
|
+
chainlit/logger.py,sha256=wTwRSZsLfXwWy6U4351IgWAm4KCMThgxm9EZpjGUEr4,373
|
|
53
|
+
chainlit/markdown.py,sha256=VUpqW7MqgjiPIQYHU4funwqC4GmHZBu_TGZTjTI4B0k,2025
|
|
54
|
+
chainlit/message.py,sha256=dheL_MiBcdc4wB9yJBRnOBZavcNRYVgjhWllSj3c1c4,18012
|
|
55
|
+
chainlit/oauth_providers.py,sha256=WiKUFpNp0RRN5Vq6LHCR9V-9td_1YEn2yD8iGu8atvY,17459
|
|
56
|
+
chainlit/openai/__init__.py,sha256=DJP_ptclLUM5Zylr4RO1Vk0lCufo3yDqXyH5J9izYS8,1814
|
|
57
|
+
chainlit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
|
+
chainlit/secret.py,sha256=cQvIFGTQ7r2heC8EOGdgifSZZYqslh-qQxhUhKhD8vU,295
|
|
59
|
+
chainlit/server.py,sha256=dpgTSFJJ33Judgn2MIfg0F1dTz6gFCvp3iazhQ9d8mQ,24595
|
|
60
|
+
chainlit/session.py,sha256=SOX2zFct3apiSNcIzCDWgDRsUFgUG_6hewqWU8gfIZE,9694
|
|
61
|
+
chainlit/slack/__init__.py,sha256=Q41ztJHeVmpoXVgVqAcwGOufQp_bjf7dDT7eEXDdhPI,207
|
|
62
|
+
chainlit/slack/app.py,sha256=hGqd6m3BI47dLUyhF2-Q544r3Uib72Iz4GaBiwxchno,11619
|
|
63
|
+
chainlit/socket.py,sha256=mJiKs7QTsahYZAdvTaJBCLO90wtLolN61iSviIRdErY,11664
|
|
64
|
+
chainlit/step.py,sha256=UKLPLq4UsB-vJfgIuLelno2KbmUKHXfvi0k8KB_Eplc,13882
|
|
65
|
+
chainlit/sync.py,sha256=G1n-7-3WgXsN8y1bJkEyws_YwmHZIyDZoZUwhprigag,1235
|
|
66
|
+
chainlit/telemetry.py,sha256=Rk4dnZv0OnGOgV4kD-VHdhgl4i7i3ypqhSE_R-LZceM,3060
|
|
67
|
+
chainlit/translations/en-US.json,sha256=Co2qy0iVqddjH_C4fH8s_pzHkLdwKWW-F5eYQPXWX50,7740
|
|
68
|
+
chainlit/translations.py,sha256=WG_r7HzxBYns-zk9tVvoGdoofv71okTZx8k1RlcoTIg,2034
|
|
69
|
+
chainlit/types.py,sha256=nnPI5yKJ7WRLg-bZ0Cx33w8VKsEX_bMOG74B_vB5k5I,5633
|
|
70
|
+
chainlit/user.py,sha256=Cw4uGz0ffivWFszv8W__EHwkvTHQ3Lj9hqpRCPxFujo,619
|
|
71
|
+
chainlit/user_session.py,sha256=G1amgs1_h2tVn4mtAXZmunm9nlBHQ_rCYvJQh3nsVwQ,1645
|
|
72
|
+
chainlit/utils.py,sha256=jdDcwOCUqpFRvWd_NWLaEUHB3vRIAU8rb013aWoqXOE,2642
|
|
73
|
+
chainlit/version.py,sha256=iosXhlXclBwBqlADFKEilxAC2wWKbtuBKi87AmPi7s8,196
|
|
74
|
+
chainlit-1.1.300rc0.dist-info/METADATA,sha256=80sz6Tmyx6Iw3B45nlgTiIKWH6buYuOBCKnQeXG697Q,5854
|
|
75
|
+
chainlit-1.1.300rc0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
76
|
+
chainlit-1.1.300rc0.dist-info/entry_points.txt,sha256=FrkqdjrFl8juSnvBndniyX7XuKojmUwO4ghRh-CFMQc,45
|
|
77
|
+
chainlit-1.1.300rc0.dist-info/RECORD,,
|