chainlit 0.7.700__py3-none-any.whl → 1.0.0rc0__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 +32 -23
- chainlit/auth.py +9 -10
- chainlit/cli/__init__.py +1 -2
- chainlit/config.py +13 -12
- chainlit/context.py +7 -3
- chainlit/data/__init__.py +375 -9
- chainlit/data/acl.py +6 -5
- chainlit/element.py +86 -123
- chainlit/emitter.py +117 -50
- chainlit/frontend/dist/assets/{index-71698725.js → index-6aee009a.js} +118 -292
- chainlit/frontend/dist/assets/{react-plotly-2c0acdf0.js → react-plotly-2f07c02a.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/haystack/callbacks.py +45 -43
- chainlit/hello.py +1 -1
- chainlit/langchain/callbacks.py +132 -120
- chainlit/llama_index/callbacks.py +68 -48
- chainlit/message.py +179 -207
- chainlit/oauth_providers.py +39 -34
- chainlit/playground/provider.py +44 -30
- chainlit/playground/providers/anthropic.py +4 -4
- chainlit/playground/providers/huggingface.py +2 -2
- chainlit/playground/providers/langchain.py +8 -10
- chainlit/playground/providers/openai.py +19 -13
- chainlit/server.py +155 -99
- chainlit/session.py +109 -40
- chainlit/socket.py +47 -36
- chainlit/step.py +393 -0
- chainlit/types.py +78 -21
- chainlit/user.py +32 -0
- chainlit/user_session.py +1 -5
- {chainlit-0.7.700.dist-info → chainlit-1.0.0rc0.dist-info}/METADATA +12 -31
- chainlit-1.0.0rc0.dist-info/RECORD +60 -0
- chainlit/client/base.py +0 -169
- chainlit/client/cloud.py +0 -502
- chainlit/prompt.py +0 -40
- chainlit-0.7.700.dist-info/RECORD +0 -61
- {chainlit-0.7.700.dist-info → chainlit-1.0.0rc0.dist-info}/WHEEL +0 -0
- {chainlit-0.7.700.dist-info → chainlit-1.0.0rc0.dist-info}/entry_points.txt +0 -0
chainlit/client/cloud.py
DELETED
|
@@ -1,502 +0,0 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
3
|
-
|
|
4
|
-
import httpx
|
|
5
|
-
from chainlit.logger import logger
|
|
6
|
-
|
|
7
|
-
from .base import (
|
|
8
|
-
AppUser,
|
|
9
|
-
ChainlitGraphQLClient,
|
|
10
|
-
ConversationDict,
|
|
11
|
-
ConversationFilter,
|
|
12
|
-
ElementDict,
|
|
13
|
-
MessageDict,
|
|
14
|
-
PageInfo,
|
|
15
|
-
PaginatedResponse,
|
|
16
|
-
Pagination,
|
|
17
|
-
PersistedAppUser,
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ChainlitCloudClient(ChainlitGraphQLClient):
|
|
22
|
-
chainlit_server: str
|
|
23
|
-
|
|
24
|
-
def __init__(self, api_key: str, chainlit_server="https://cloud.chainlit.io"):
|
|
25
|
-
# Remove trailing slash
|
|
26
|
-
chainlit_server = chainlit_server.rstrip("/")
|
|
27
|
-
super().__init__(api_key=api_key, chainlit_server=chainlit_server)
|
|
28
|
-
self.chainlit_server = chainlit_server
|
|
29
|
-
|
|
30
|
-
async def create_app_user(self, app_user: AppUser) -> Optional[PersistedAppUser]:
|
|
31
|
-
mutation = """
|
|
32
|
-
mutation ($username: String!, $role: Role!, $tags: [String!], $provider: String, $image: String) {
|
|
33
|
-
createAppUser(username: $username, role: $role, tags: $tags, provider: $provider, image: $image) {
|
|
34
|
-
id,
|
|
35
|
-
username,
|
|
36
|
-
role,
|
|
37
|
-
tags,
|
|
38
|
-
provider,
|
|
39
|
-
image,
|
|
40
|
-
createdAt
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
"""
|
|
44
|
-
variables = app_user.to_dict()
|
|
45
|
-
res = await self.mutation(mutation, variables)
|
|
46
|
-
|
|
47
|
-
if self.check_for_errors(res):
|
|
48
|
-
logger.warning("Could not create app user.")
|
|
49
|
-
return None
|
|
50
|
-
|
|
51
|
-
return PersistedAppUser.from_dict(res["data"]["createAppUser"])
|
|
52
|
-
|
|
53
|
-
async def update_app_user(self, app_user: AppUser) -> Optional[PersistedAppUser]:
|
|
54
|
-
mutation = """
|
|
55
|
-
mutation ($username: String!, $role: Role!, $tags: [String!], $provider: String, $image: String) {
|
|
56
|
-
updateAppUser(username: $username, role: $role, tags: $tags, provider: $provider, image: $image) {
|
|
57
|
-
id,
|
|
58
|
-
username,
|
|
59
|
-
role,
|
|
60
|
-
tags,
|
|
61
|
-
provider,
|
|
62
|
-
image,
|
|
63
|
-
createdAt
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
"""
|
|
67
|
-
variables = app_user.to_dict()
|
|
68
|
-
res = await self.mutation(mutation, variables)
|
|
69
|
-
|
|
70
|
-
if self.check_for_errors(res):
|
|
71
|
-
logger.warning("Could not update app user.")
|
|
72
|
-
return None
|
|
73
|
-
|
|
74
|
-
return PersistedAppUser.from_dict(res["data"]["updateAppUser"])
|
|
75
|
-
|
|
76
|
-
async def get_app_user(self, username: str) -> Optional[PersistedAppUser]:
|
|
77
|
-
query = """
|
|
78
|
-
query ($username: String!) {
|
|
79
|
-
getAppUser(username: $username) {
|
|
80
|
-
id,
|
|
81
|
-
username,
|
|
82
|
-
role,
|
|
83
|
-
tags,
|
|
84
|
-
provider,
|
|
85
|
-
image,
|
|
86
|
-
createdAt
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
"""
|
|
90
|
-
variables = {"username": username}
|
|
91
|
-
res = await self.query(query, variables)
|
|
92
|
-
|
|
93
|
-
if self.check_for_errors(res):
|
|
94
|
-
logger.warning("Could not get app user.")
|
|
95
|
-
return None
|
|
96
|
-
|
|
97
|
-
return PersistedAppUser.from_dict(res["data"]["getAppUser"])
|
|
98
|
-
|
|
99
|
-
async def delete_app_user(self, username: str) -> bool:
|
|
100
|
-
mutation = """
|
|
101
|
-
mutation ($username: String!) {
|
|
102
|
-
deleteAppUser(username: $username) {
|
|
103
|
-
id,
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
"""
|
|
107
|
-
variables = {"username": username}
|
|
108
|
-
res = await self.mutation(mutation, variables)
|
|
109
|
-
|
|
110
|
-
if self.check_for_errors(res):
|
|
111
|
-
logger.warning("Could not delete app user.")
|
|
112
|
-
return False
|
|
113
|
-
|
|
114
|
-
return True
|
|
115
|
-
|
|
116
|
-
async def create_conversation(
|
|
117
|
-
self, app_user_id: Optional[str], tags: Optional[List[str]]
|
|
118
|
-
) -> Optional[str]:
|
|
119
|
-
mutation = """
|
|
120
|
-
mutation ($appUserId: String, $tags: [String!]) {
|
|
121
|
-
createConversation (appUserId: $appUserId, tags: $tags) {
|
|
122
|
-
id
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
"""
|
|
126
|
-
variables = {} # type: Dict[str, Any]
|
|
127
|
-
if app_user_id is not None:
|
|
128
|
-
variables["appUserId"] = app_user_id
|
|
129
|
-
|
|
130
|
-
if tags:
|
|
131
|
-
variables["tags"] = tags
|
|
132
|
-
|
|
133
|
-
res = await self.mutation(mutation, variables)
|
|
134
|
-
|
|
135
|
-
if self.check_for_errors(res):
|
|
136
|
-
logger.warning("Could not create conversation.")
|
|
137
|
-
return None
|
|
138
|
-
|
|
139
|
-
return res["data"]["createConversation"]["id"]
|
|
140
|
-
|
|
141
|
-
async def delete_conversation(self, conversation_id: str) -> bool:
|
|
142
|
-
mutation = """
|
|
143
|
-
mutation ($id: ID!) {
|
|
144
|
-
deleteConversation(id: $id) {
|
|
145
|
-
id
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
"""
|
|
149
|
-
variables = {"id": conversation_id}
|
|
150
|
-
res = await self.mutation(mutation, variables)
|
|
151
|
-
self.check_for_errors(res, raise_error=True)
|
|
152
|
-
|
|
153
|
-
return True
|
|
154
|
-
|
|
155
|
-
async def get_conversation_author(self, conversation_id: str) -> Optional[str]:
|
|
156
|
-
query = """
|
|
157
|
-
query ($id: ID!) {
|
|
158
|
-
conversation(id: $id) {
|
|
159
|
-
appUser {
|
|
160
|
-
username
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
"""
|
|
165
|
-
variables = {
|
|
166
|
-
"id": conversation_id,
|
|
167
|
-
}
|
|
168
|
-
res = await self.query(query, variables)
|
|
169
|
-
self.check_for_errors(res, raise_error=True)
|
|
170
|
-
data = res.get("data")
|
|
171
|
-
conversation = data.get("conversation") if data else None
|
|
172
|
-
if not conversation:
|
|
173
|
-
return None
|
|
174
|
-
return (
|
|
175
|
-
conversation["appUser"].get("username") if conversation["appUser"] else None
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
async def get_conversation(self, conversation_id: str) -> ConversationDict:
|
|
179
|
-
query = """
|
|
180
|
-
query ($id: ID!) {
|
|
181
|
-
conversation(id: $id) {
|
|
182
|
-
id
|
|
183
|
-
createdAt
|
|
184
|
-
tags
|
|
185
|
-
metadata
|
|
186
|
-
appUser {
|
|
187
|
-
id
|
|
188
|
-
username
|
|
189
|
-
}
|
|
190
|
-
messages {
|
|
191
|
-
id
|
|
192
|
-
isError
|
|
193
|
-
parentId
|
|
194
|
-
indent
|
|
195
|
-
author
|
|
196
|
-
content
|
|
197
|
-
waitForAnswer
|
|
198
|
-
humanFeedback
|
|
199
|
-
humanFeedbackComment
|
|
200
|
-
disableHumanFeedback
|
|
201
|
-
language
|
|
202
|
-
prompt
|
|
203
|
-
authorIsUser
|
|
204
|
-
createdAt
|
|
205
|
-
}
|
|
206
|
-
elements {
|
|
207
|
-
id
|
|
208
|
-
conversationId
|
|
209
|
-
type
|
|
210
|
-
name
|
|
211
|
-
mime
|
|
212
|
-
url
|
|
213
|
-
display
|
|
214
|
-
language
|
|
215
|
-
size
|
|
216
|
-
forIds
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
"""
|
|
221
|
-
variables = {
|
|
222
|
-
"id": conversation_id,
|
|
223
|
-
}
|
|
224
|
-
res = await self.query(query, variables)
|
|
225
|
-
self.check_for_errors(res, raise_error=True)
|
|
226
|
-
|
|
227
|
-
return res["data"]["conversation"]
|
|
228
|
-
|
|
229
|
-
async def update_conversation_metadata(self, conversation_id: str, metadata: Dict):
|
|
230
|
-
mutation = """mutation ($conversationId: ID!, $metadata: Json!) {
|
|
231
|
-
updateConversationMetadata(conversationId: $conversationId, metadata: $metadata) {
|
|
232
|
-
id
|
|
233
|
-
}
|
|
234
|
-
}"""
|
|
235
|
-
variables = {
|
|
236
|
-
"conversationId": conversation_id,
|
|
237
|
-
"metadata": metadata,
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
res = await self.mutation(mutation, variables)
|
|
241
|
-
self.check_for_errors(res, raise_error=True)
|
|
242
|
-
|
|
243
|
-
return True
|
|
244
|
-
|
|
245
|
-
async def get_conversations(
|
|
246
|
-
self, pagination: Pagination, filter: ConversationFilter
|
|
247
|
-
):
|
|
248
|
-
query = """query (
|
|
249
|
-
$first: Int
|
|
250
|
-
$cursor: String
|
|
251
|
-
$withFeedback: Int
|
|
252
|
-
$username: String
|
|
253
|
-
$search: String
|
|
254
|
-
) {
|
|
255
|
-
conversations(
|
|
256
|
-
first: $first
|
|
257
|
-
cursor: $cursor
|
|
258
|
-
withFeedback: $withFeedback
|
|
259
|
-
username: $username
|
|
260
|
-
search: $search
|
|
261
|
-
) {
|
|
262
|
-
pageInfo {
|
|
263
|
-
endCursor
|
|
264
|
-
hasNextPage
|
|
265
|
-
}
|
|
266
|
-
edges {
|
|
267
|
-
cursor
|
|
268
|
-
node {
|
|
269
|
-
id
|
|
270
|
-
createdAt
|
|
271
|
-
tags
|
|
272
|
-
appUser {
|
|
273
|
-
username
|
|
274
|
-
}
|
|
275
|
-
messages {
|
|
276
|
-
content
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}"""
|
|
282
|
-
|
|
283
|
-
variables = {
|
|
284
|
-
"first": pagination.first,
|
|
285
|
-
"cursor": pagination.cursor,
|
|
286
|
-
"withFeedback": filter.feedback,
|
|
287
|
-
"username": filter.username,
|
|
288
|
-
"search": filter.search,
|
|
289
|
-
}
|
|
290
|
-
res = await self.query(query, variables)
|
|
291
|
-
self.check_for_errors(res, raise_error=True)
|
|
292
|
-
|
|
293
|
-
conversations = []
|
|
294
|
-
|
|
295
|
-
for edge in res["data"]["conversations"]["edges"]:
|
|
296
|
-
node = edge["node"]
|
|
297
|
-
conversations.append(node)
|
|
298
|
-
|
|
299
|
-
page_info = res["data"]["conversations"]["pageInfo"]
|
|
300
|
-
|
|
301
|
-
return PaginatedResponse(
|
|
302
|
-
pageInfo=PageInfo(
|
|
303
|
-
hasNextPage=page_info["hasNextPage"],
|
|
304
|
-
endCursor=page_info["endCursor"],
|
|
305
|
-
),
|
|
306
|
-
data=conversations,
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
async def set_human_feedback(
|
|
310
|
-
self, message_id: str, feedback: int, feedbackComment: Optional[str]
|
|
311
|
-
) -> bool:
|
|
312
|
-
mutation = """mutation ($messageId: ID!, $humanFeedback: Int!, $humanFeedbackComment: String) {
|
|
313
|
-
setHumanFeedback(messageId: $messageId, humanFeedback: $humanFeedback, humanFeedbackComment: $humanFeedbackComment) {
|
|
314
|
-
id
|
|
315
|
-
humanFeedback
|
|
316
|
-
humanFeedbackComment
|
|
317
|
-
}
|
|
318
|
-
}"""
|
|
319
|
-
variables = {
|
|
320
|
-
"messageId": message_id,
|
|
321
|
-
"humanFeedback": feedback,
|
|
322
|
-
}
|
|
323
|
-
if feedbackComment:
|
|
324
|
-
variables["humanFeedbackComment"] = feedbackComment
|
|
325
|
-
res = await self.mutation(mutation, variables)
|
|
326
|
-
self.check_for_errors(res, raise_error=True)
|
|
327
|
-
|
|
328
|
-
return True
|
|
329
|
-
|
|
330
|
-
async def get_message(self):
|
|
331
|
-
raise NotImplementedError
|
|
332
|
-
|
|
333
|
-
async def create_message(self, variables: MessageDict) -> Optional[str]:
|
|
334
|
-
mutation = """
|
|
335
|
-
mutation ($id: ID!, $conversationId: ID!, $author: String!, $content: String!, $language: String, $prompt: Json, $isError: Boolean, $parentId: String, $indent: Int, $authorIsUser: Boolean, $disableHumanFeedback: Boolean, $waitForAnswer: Boolean, $createdAt: StringOrFloat) {
|
|
336
|
-
createMessage(id: $id, conversationId: $conversationId, author: $author, content: $content, language: $language, prompt: $prompt, isError: $isError, parentId: $parentId, indent: $indent, authorIsUser: $authorIsUser, disableHumanFeedback: $disableHumanFeedback, waitForAnswer: $waitForAnswer, createdAt: $createdAt) {
|
|
337
|
-
id
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
"""
|
|
341
|
-
res = await self.mutation(mutation, variables)
|
|
342
|
-
if self.check_for_errors(res):
|
|
343
|
-
logger.warning("Could not create message.")
|
|
344
|
-
return None
|
|
345
|
-
|
|
346
|
-
return res["data"]["createMessage"]["id"]
|
|
347
|
-
|
|
348
|
-
async def update_message(self, message_id: str, variables: MessageDict) -> bool:
|
|
349
|
-
mutation = """
|
|
350
|
-
mutation ($messageId: ID!, $author: String!, $content: String!, $parentId: String, $language: String, $prompt: Json, $disableHumanFeedback: Boolean) {
|
|
351
|
-
updateMessage(messageId: $messageId, author: $author, content: $content, parentId: $parentId, language: $language, prompt: $prompt, disableHumanFeedback: $disableHumanFeedback) {
|
|
352
|
-
id
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
"""
|
|
356
|
-
res = await self.mutation(mutation, dict(messageId=message_id, **variables))
|
|
357
|
-
|
|
358
|
-
if self.check_for_errors(res):
|
|
359
|
-
logger.warning("Could not update message.")
|
|
360
|
-
return False
|
|
361
|
-
|
|
362
|
-
return True
|
|
363
|
-
|
|
364
|
-
async def delete_message(self, message_id: str) -> bool:
|
|
365
|
-
mutation = """
|
|
366
|
-
mutation ($messageId: ID!) {
|
|
367
|
-
deleteMessage(messageId: $messageId) {
|
|
368
|
-
id
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
"""
|
|
372
|
-
res = await self.mutation(mutation, {"messageId": message_id})
|
|
373
|
-
|
|
374
|
-
if self.check_for_errors(res):
|
|
375
|
-
logger.warning("Could not delete message.")
|
|
376
|
-
return False
|
|
377
|
-
|
|
378
|
-
return True
|
|
379
|
-
|
|
380
|
-
async def get_element(
|
|
381
|
-
self, conversation_id: str, element_id: str
|
|
382
|
-
) -> Optional[ElementDict]:
|
|
383
|
-
query = """query (
|
|
384
|
-
$conversationId: ID!
|
|
385
|
-
$id: ID!
|
|
386
|
-
) {
|
|
387
|
-
element(
|
|
388
|
-
conversationId: $conversationId,
|
|
389
|
-
id: $id
|
|
390
|
-
) {
|
|
391
|
-
id
|
|
392
|
-
conversationId
|
|
393
|
-
type
|
|
394
|
-
name
|
|
395
|
-
mime
|
|
396
|
-
url
|
|
397
|
-
display
|
|
398
|
-
language
|
|
399
|
-
size
|
|
400
|
-
forIds
|
|
401
|
-
}
|
|
402
|
-
}"""
|
|
403
|
-
|
|
404
|
-
variables = {
|
|
405
|
-
"conversationId": conversation_id,
|
|
406
|
-
"id": element_id,
|
|
407
|
-
}
|
|
408
|
-
res = await self.query(query, variables)
|
|
409
|
-
self.check_for_errors(res, raise_error=True)
|
|
410
|
-
|
|
411
|
-
return res["data"]["element"]
|
|
412
|
-
|
|
413
|
-
async def create_element(self, variables: ElementDict) -> Optional[ElementDict]:
|
|
414
|
-
mutation = """
|
|
415
|
-
mutation ($conversationId: ID!, $type: String!, $name: String!, $display: String!, $forIds: [String!]!, $url: String, $objectKey: String, $size: String, $language: String, $mime: String) {
|
|
416
|
-
createElement(conversationId: $conversationId, type: $type, url: $url, objectKey: $objectKey, name: $name, display: $display, size: $size, language: $language, forIds: $forIds, mime: $mime) {
|
|
417
|
-
id,
|
|
418
|
-
type,
|
|
419
|
-
url,
|
|
420
|
-
objectKey,
|
|
421
|
-
name,
|
|
422
|
-
display,
|
|
423
|
-
size,
|
|
424
|
-
language,
|
|
425
|
-
forIds,
|
|
426
|
-
mime
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
"""
|
|
430
|
-
res = await self.mutation(mutation, variables)
|
|
431
|
-
|
|
432
|
-
if self.check_for_errors(res):
|
|
433
|
-
logger.warning("Could not create element.")
|
|
434
|
-
return None
|
|
435
|
-
|
|
436
|
-
return res["data"]["createElement"]
|
|
437
|
-
|
|
438
|
-
async def update_element(self, variables: ElementDict) -> Optional[ElementDict]:
|
|
439
|
-
mutation = """
|
|
440
|
-
mutation ($conversationId: ID!, $id: ID!, $forIds: [String!]!) {
|
|
441
|
-
updateElement(conversationId: $conversationId, id: $id, forIds: $forIds) {
|
|
442
|
-
id,
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
"""
|
|
446
|
-
|
|
447
|
-
res = await self.mutation(mutation, variables)
|
|
448
|
-
|
|
449
|
-
if self.check_for_errors(res):
|
|
450
|
-
logger.warning("Could not update element.")
|
|
451
|
-
return None
|
|
452
|
-
|
|
453
|
-
return res["data"]["updateElement"]
|
|
454
|
-
|
|
455
|
-
async def upload_element(
|
|
456
|
-
self, content: Union[bytes, str], mime: str, conversation_id: Optional[str]
|
|
457
|
-
) -> Dict:
|
|
458
|
-
id = str(uuid.uuid4())
|
|
459
|
-
body = {"fileName": id, "contentType": mime}
|
|
460
|
-
|
|
461
|
-
if conversation_id:
|
|
462
|
-
body["conversationId"] = conversation_id
|
|
463
|
-
|
|
464
|
-
path = "/api/upload/file"
|
|
465
|
-
|
|
466
|
-
async with httpx.AsyncClient() as client:
|
|
467
|
-
response = await client.post(
|
|
468
|
-
f"{self.chainlit_server}{path}",
|
|
469
|
-
json=body,
|
|
470
|
-
headers=self.headers,
|
|
471
|
-
)
|
|
472
|
-
if response.status_code != 200:
|
|
473
|
-
reason = response.text
|
|
474
|
-
logger.error(f"Failed to sign upload url: {reason}")
|
|
475
|
-
return {"object_key": None, "url": None}
|
|
476
|
-
json_res = response.json()
|
|
477
|
-
|
|
478
|
-
upload_details = json_res["post"]
|
|
479
|
-
object_key = upload_details["fields"]["key"]
|
|
480
|
-
signed_url = json_res["signedUrl"]
|
|
481
|
-
|
|
482
|
-
# Prepare form data
|
|
483
|
-
form_data = {} # type: Dict[str, Tuple[Union[str, None], Any]]
|
|
484
|
-
for field_name, field_value in upload_details["fields"].items():
|
|
485
|
-
form_data[field_name] = (None, field_value)
|
|
486
|
-
|
|
487
|
-
# Add file to the form_data
|
|
488
|
-
# Note: The content_type parameter is not needed here, as the correct MIME type should be set in the 'Content-Type' field from upload_details
|
|
489
|
-
form_data["file"] = (id, content)
|
|
490
|
-
|
|
491
|
-
async with httpx.AsyncClient() as client:
|
|
492
|
-
upload_response = await client.post(
|
|
493
|
-
upload_details["url"],
|
|
494
|
-
files=form_data,
|
|
495
|
-
)
|
|
496
|
-
try:
|
|
497
|
-
upload_response.raise_for_status()
|
|
498
|
-
url = f'{upload_details["url"]}/{object_key}'
|
|
499
|
-
return {"object_key": object_key, "url": signed_url}
|
|
500
|
-
except Exception as e:
|
|
501
|
-
logger.error(f"Failed to upload file: {str(e)}")
|
|
502
|
-
return {"object_key": None, "url": None}
|
chainlit/prompt.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Literal, Optional
|
|
2
|
-
|
|
3
|
-
from dataclasses_json import DataClassJsonMixin
|
|
4
|
-
from pydantic.dataclasses import dataclass
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dataclass
|
|
8
|
-
class BaseTemplate(DataClassJsonMixin):
|
|
9
|
-
template: Optional[str] = None
|
|
10
|
-
formatted: Optional[str] = None
|
|
11
|
-
template_format: Optional[str] = "f-string"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclass
|
|
15
|
-
class PromptMessage(BaseTemplate):
|
|
16
|
-
# This is used for Langchain's MessagesPlaceholder
|
|
17
|
-
placeholder_size: Optional[int] = None
|
|
18
|
-
# This is used for OpenAI's function message
|
|
19
|
-
name: Optional[str] = None
|
|
20
|
-
role: Optional[Literal["system", "assistant", "user", "function"]] = None
|
|
21
|
-
|
|
22
|
-
def to_openai(self):
|
|
23
|
-
msg_dict = {"role": self.role, "content": self.formatted}
|
|
24
|
-
if self.role == "function":
|
|
25
|
-
msg_dict["name"] = self.name or ""
|
|
26
|
-
return msg_dict
|
|
27
|
-
|
|
28
|
-
def to_string(self):
|
|
29
|
-
return f"{self.role}: {self.formatted}"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@dataclass
|
|
33
|
-
class Prompt(BaseTemplate):
|
|
34
|
-
provider: Optional[str] = None
|
|
35
|
-
id: Optional[str] = None
|
|
36
|
-
inputs: Optional[Dict[str, str]] = None
|
|
37
|
-
completion: Optional[str] = None
|
|
38
|
-
settings: Optional[Dict[str, Any]] = None
|
|
39
|
-
messages: Optional[List[PromptMessage]] = None
|
|
40
|
-
functions: Optional[List[Dict]] = None
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
chainlit/__init__.py,sha256=e215uKlKg0rvx3EIcwn1j9WSJoQwzbwRQx-bP2HI6go,8840
|
|
2
|
-
chainlit/__main__.py,sha256=7Vg3w3T3qDuz4KDu5lQhLH6lQ3cYdume7gHH7Z1V97U,87
|
|
3
|
-
chainlit/action.py,sha256=k-GsblVHI4DnDWFyF-RZgq3KfdfAFICFh2OBeU4w8N8,1410
|
|
4
|
-
chainlit/auth.py,sha256=kA9S1aTv7kPFfAzOmwkTlsyE4f17NEwvUCXo49vbUjY,2716
|
|
5
|
-
chainlit/cache.py,sha256=Bv3dT4eHhE6Fq3c6Do0ZTpiyoXgXYewdxTgpYghEd9g,1361
|
|
6
|
-
chainlit/chat_settings.py,sha256=2ByenmwS8O6jQjDVJjhhbLrBPGA5aY2F7R3VvQQxXPk,877
|
|
7
|
-
chainlit/cli/__init__.py,sha256=HpEonQCHdgYnNB0tBq8DXUO4S3MegHHuIn5YOvLLgY4,4793
|
|
8
|
-
chainlit/cli/utils.py,sha256=mE2d9oOk-B2b9ZvDV1zENoDWxjfMriGP7bVwEFduZP4,717
|
|
9
|
-
chainlit/client/base.py,sha256=7hzMJJJK10CQ13dIVgg93vDBy3Y6saDTMftjSF3FaPw,4365
|
|
10
|
-
chainlit/client/cloud.py,sha256=EXBYtEzt04KcnlGzzkPCx8sjSByNQQ21GB4ekXL81TI,16349
|
|
11
|
-
chainlit/config.py,sha256=zfpNwqD1Iob2CjqEjAazpqoWLCFTX3gF1wLADi6BITo,10646
|
|
12
|
-
chainlit/context.py,sha256=3hrRRB_joQjR8fjKRwpWZqUQNFxS3oXVmXuec7n6pj0,2195
|
|
13
|
-
chainlit/data/__init__.py,sha256=KHS56Bbh1Vx1BfNipO8jC-lTrY8gWSTgJSZK-OHotuQ,373
|
|
14
|
-
chainlit/data/acl.py,sha256=WNp4ytwRmLWLfcSsjAQSbbSwhV3Acbhx1F1gy5qLgMk,474
|
|
15
|
-
chainlit/element.py,sha256=1m-iK90aCAY8kK6nKim4TtKtzFz3hvYnjQW3iDOmtDo,11714
|
|
16
|
-
chainlit/emitter.py,sha256=SmIPoXNExhAIn3wSG0-tcKKyd9HZ3FXXA9S9qYiUEUs,8067
|
|
17
|
-
chainlit/frontend/dist/assets/index-71698725.js,sha256=SgMDc3pdA6Ae_CVniFSUlq7aTB6rx2bAOAlQsj0oebk,3084418
|
|
18
|
-
chainlit/frontend/dist/assets/index-8942cb2d.css,sha256=iULLLdx-rywLKpSdrJuSZwAF22WLkNdLKypNpaN5PQY,6557
|
|
19
|
-
chainlit/frontend/dist/assets/logo_dark-bc7401f6.svg,sha256=vHQB9g-n5OqOmuH3Fduuc7ZMg0EmMsGyO9cEnYwLbHg,8889
|
|
20
|
-
chainlit/frontend/dist/assets/logo_light-f19fc2ea.svg,sha256=8Z_C6t-0V9QL9ldmLjaLfp2REcGDuaTeNynj6-6muNI,8891
|
|
21
|
-
chainlit/frontend/dist/assets/react-plotly-2c0acdf0.js,sha256=acCLmJDbRgiv7mxSHC8_xofgCAIFPcrGDXIRH5231Ko,3739251
|
|
22
|
-
chainlit/frontend/dist/favicon.svg,sha256=0Cy8x28obT5eWW3nxZRhsEvu6_zMqrqbg0y6hT3D0Q0,6455
|
|
23
|
-
chainlit/frontend/dist/index.html,sha256=q8QL3ovB9FvmXo5wZjOQaiKdy7XzjeQWeafSBVSU1uo,959
|
|
24
|
-
chainlit/haystack/__init__.py,sha256=uZ77YiPy-qleSTi3dQCDO9HE6S6F6GpJWmh7jO4cxXA,217
|
|
25
|
-
chainlit/haystack/callbacks.py,sha256=VCy7v2zlRV9pSSrEfSsd8-dTcAIbIxINdBnJg8zjYXQ,3910
|
|
26
|
-
chainlit/hello.py,sha256=bqKP00i0FKHnZ9fdyVW1a2xDAA1g7IWT0EVzUNky7rA,417
|
|
27
|
-
chainlit/input_widget.py,sha256=1Z1qn3YwaZ7upqqxZXtbfDxBlVobDjbZ3HtlNOj-U3E,4880
|
|
28
|
-
chainlit/langchain/__init__.py,sha256=zErMw0_3ufSGeF9ye7X0ZX3wDat4mTOx97T40ePDO2g,217
|
|
29
|
-
chainlit/langchain/callbacks.py,sha256=bA9_QMuJHK40CLe4QN2fa1iyWSOXcif2hIdZu45QGYI,23191
|
|
30
|
-
chainlit/langflow/__init__.py,sha256=wxhxdsl1yxdsRyNTgZticxFF_8VFtJJ4OdIy3tnEIyM,817
|
|
31
|
-
chainlit/llama_index/__init__.py,sha256=c7wIUZmKTtZPU9zpdGpKTHctQaBWTuRGqTN0kkIkBcg,218
|
|
32
|
-
chainlit/llama_index/callbacks.py,sha256=2wIADRsy6njqPDyObW9NKZ5FXc-bBkgu5eWmVE03Dc4,4849
|
|
33
|
-
chainlit/logger.py,sha256=wTwRSZsLfXwWy6U4351IgWAm4KCMThgxm9EZpjGUEr4,373
|
|
34
|
-
chainlit/markdown.py,sha256=L2IPPWxIlrhJZcKPfO1akomHdN3sgC2EvC2ilxR8MQs,1624
|
|
35
|
-
chainlit/message.py,sha256=dPcVnJJ6hRIrU_Dlm66YuDReU_tr5Fizjyrtsayk_XY,19124
|
|
36
|
-
chainlit/oauth_providers.py,sha256=I8yF2tFBsGdGGtUo6GZtiwo6fEx6yxPrzF2F-Fdl6WY,14901
|
|
37
|
-
chainlit/playground/__init__.py,sha256=igNRcBgqLKPTjOQtTNhhGNJFmZn-Dl1fHRQzQSjDGTQ,80
|
|
38
|
-
chainlit/playground/config.py,sha256=a6fnIU2IrYQDKU6zHF8qUD3ssUBD9UiTEN10pMxgnGY,998
|
|
39
|
-
chainlit/playground/provider.py,sha256=NVg1OTdriSfMOqfRUcymIaiasNfGNzLjo6GM5K34z8U,4424
|
|
40
|
-
chainlit/playground/providers/__init__.py,sha256=L4Y7Udpexm769Jnf-mIeN-YGh6xaaMjF3rPxSfReiN4,225
|
|
41
|
-
chainlit/playground/providers/anthropic.py,sha256=9j13gtnA6_Y1MjXMLsp17MJwniZlUgqfMUEzE166FFk,3431
|
|
42
|
-
chainlit/playground/providers/huggingface.py,sha256=HQC14D8l0-JOJIP8YYsHrslZQf0d0gDpBOktQkZZLlA,2122
|
|
43
|
-
chainlit/playground/providers/langchain.py,sha256=1hh00W8M1aTr9O5D13zkEcCFdTMGVjLuQFZylxmDmzE,2776
|
|
44
|
-
chainlit/playground/providers/openai.py,sha256=-TMNUaYmj8Hw68JKuTCjLJXPbeoQtCI4gXRH7HShYyo,12428
|
|
45
|
-
chainlit/playground/providers/vertexai.py,sha256=TwFyhNmbStUso0ShvoRzOQ5b4l8ErG1szxqjv4IRXE0,3678
|
|
46
|
-
chainlit/prompt.py,sha256=GssulrgQdpkHGXBDFWCbTFWtrT2voorTXcHvjQj4SD4,1221
|
|
47
|
-
chainlit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
-
chainlit/secret.py,sha256=0MXq8YxTeL93K8IyAew5UgZmIIw9_yJ_Kg4iML6cdVM,296
|
|
49
|
-
chainlit/server.py,sha256=J6yQdbvmWwst2mPgzEkBaDfO4nYr5kYOsXyYemgBTXY,19241
|
|
50
|
-
chainlit/session.py,sha256=WOwyPZuqu73GcULkGTjV_Coal1d2cRgEZCmRuHydSyc,6424
|
|
51
|
-
chainlit/socket.py,sha256=Icz3ZlaaZHLTrG2H4g1KF8Uu2BlWfFUAI6rHn3RjFtc,8560
|
|
52
|
-
chainlit/sync.py,sha256=G1n-7-3WgXsN8y1bJkEyws_YwmHZIyDZoZUwhprigag,1235
|
|
53
|
-
chainlit/telemetry.py,sha256=sIZzYk0YEmtWbOS8B5tf6aQfW-uKzwvVtajpbj8bLMw,3210
|
|
54
|
-
chainlit/types.py,sha256=PLWsBVRyCRYeBshLgg3MpVSAT6rf_eAQ17M6v9Dnik0,2180
|
|
55
|
-
chainlit/user_session.py,sha256=-GjXsuyhx7bvRlCHOqRHh-r6PkCm8fCPJMX6-kTch64,1534
|
|
56
|
-
chainlit/utils.py,sha256=3HzhfZ4XJhBIe9sJ_3Lxv3lMH4mFXsi6nLBGqm8Gtdw,2571
|
|
57
|
-
chainlit/version.py,sha256=iosXhlXclBwBqlADFKEilxAC2wWKbtuBKi87AmPi7s8,196
|
|
58
|
-
chainlit-0.7.700.dist-info/METADATA,sha256=CGHGNtpTqdRXmPIyWpvY8gFsJkip1UYe5h9Hg36u9vY,6312
|
|
59
|
-
chainlit-0.7.700.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
60
|
-
chainlit-0.7.700.dist-info/entry_points.txt,sha256=FrkqdjrFl8juSnvBndniyX7XuKojmUwO4ghRh-CFMQc,45
|
|
61
|
-
chainlit-0.7.700.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|