chainlit 1.1.101__py3-none-any.whl → 1.1.200__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/config.py +6 -0
- chainlit/copilot/dist/index.js +218 -222
- chainlit/discord/app.py +18 -9
- chainlit/frontend/dist/assets/{index-37c9a5a9.js → index-d9bad4f1.js} +125 -129
- chainlit/frontend/dist/assets/{react-plotly-c55d0c95.js → react-plotly-48cc0858.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/message.py +2 -2
- chainlit/server.py +3 -1
- chainlit/slack/app.py +18 -7
- chainlit/step.py +11 -12
- chainlit/types.py +1 -0
- {chainlit-1.1.101.dist-info → chainlit-1.1.200.dist-info}/METADATA +1 -1
- {chainlit-1.1.101.dist-info → chainlit-1.1.200.dist-info}/RECORD +15 -15
- {chainlit-1.1.101.dist-info → chainlit-1.1.200.dist-info}/WHEEL +0 -0
- {chainlit-1.1.101.dist-info → chainlit-1.1.200.dist-info}/entry_points.txt +0 -0
chainlit/discord/app.py
CHANGED
|
@@ -3,13 +3,12 @@ import mimetypes
|
|
|
3
3
|
import re
|
|
4
4
|
import uuid
|
|
5
5
|
from io import BytesIO
|
|
6
|
-
from typing import Dict, List, Optional, Union
|
|
6
|
+
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from discord.abc import MessageableChannel
|
|
10
10
|
|
|
11
11
|
import discord
|
|
12
|
-
|
|
13
12
|
import filetype
|
|
14
13
|
import httpx
|
|
15
14
|
from chainlit.config import config
|
|
@@ -19,11 +18,10 @@ from chainlit.element import Element, ElementDict
|
|
|
19
18
|
from chainlit.emitter import BaseChainlitEmitter
|
|
20
19
|
from chainlit.logger import logger
|
|
21
20
|
from chainlit.message import Message, StepDict
|
|
21
|
+
from chainlit.telemetry import trace
|
|
22
22
|
from chainlit.types import Feedback
|
|
23
23
|
from chainlit.user import PersistedUser, User
|
|
24
24
|
from chainlit.user_session import user_session
|
|
25
|
-
from chainlit.telemetry import trace
|
|
26
|
-
|
|
27
25
|
from discord.ui import Button, View
|
|
28
26
|
|
|
29
27
|
|
|
@@ -36,7 +34,9 @@ class FeedbackView(View):
|
|
|
36
34
|
async def thumbs_down(self, interaction: discord.Interaction, button: Button):
|
|
37
35
|
if data_layer := get_data_layer():
|
|
38
36
|
try:
|
|
39
|
-
|
|
37
|
+
thread_id = context_var.get().session.thread_id
|
|
38
|
+
feedback = Feedback(forId=self.step_id, threadId=thread_id, value=0)
|
|
39
|
+
await data_layer.upsert_feedback(feedback)
|
|
40
40
|
except Exception as e:
|
|
41
41
|
logger.error(f"Error upserting feedback: {e}")
|
|
42
42
|
if interaction.message:
|
|
@@ -47,7 +47,9 @@ class FeedbackView(View):
|
|
|
47
47
|
async def thumbs_up(self, interaction: discord.Interaction, button: Button):
|
|
48
48
|
if data_layer := get_data_layer():
|
|
49
49
|
try:
|
|
50
|
-
|
|
50
|
+
thread_id = context_var.get().session.thread_id
|
|
51
|
+
feedback = Feedback(forId=self.step_id, threadId=thread_id, value=1)
|
|
52
|
+
await data_layer.upsert_feedback(feedback)
|
|
51
53
|
except Exception as e:
|
|
52
54
|
logger.error(f"Error upserting feedback: {e}")
|
|
53
55
|
if interaction.message:
|
|
@@ -98,10 +100,16 @@ class DiscordEmitter(BaseChainlitEmitter):
|
|
|
98
100
|
if not self.enabled:
|
|
99
101
|
return
|
|
100
102
|
|
|
103
|
+
step_type = step_dict.get("type")
|
|
104
|
+
is_message = step_type in [
|
|
105
|
+
"user_message",
|
|
106
|
+
"assistant_message",
|
|
107
|
+
"system_message",
|
|
108
|
+
]
|
|
101
109
|
is_chain_of_thought = bool(step_dict.get("parentId"))
|
|
102
110
|
is_empty_output = not step_dict.get("output")
|
|
103
111
|
|
|
104
|
-
if is_chain_of_thought or is_empty_output:
|
|
112
|
+
if is_chain_of_thought or is_empty_output or not is_message:
|
|
105
113
|
return
|
|
106
114
|
else:
|
|
107
115
|
enable_feedback = not step_dict.get("disableFeedback") and get_data_layer()
|
|
@@ -123,6 +131,7 @@ intents.message_content = True
|
|
|
123
131
|
|
|
124
132
|
client = discord.Client(intents=intents)
|
|
125
133
|
|
|
134
|
+
|
|
126
135
|
@trace
|
|
127
136
|
def init_discord_context(
|
|
128
137
|
session: HTTPSession,
|
|
@@ -145,7 +154,7 @@ USER_PREFIX = "discord_"
|
|
|
145
154
|
async def get_user(discord_user: Union[discord.User, discord.Member]):
|
|
146
155
|
if discord_user.id in users_by_discord_id:
|
|
147
156
|
return users_by_discord_id[discord_user.id]
|
|
148
|
-
|
|
157
|
+
|
|
149
158
|
metadata = {
|
|
150
159
|
"name": discord_user.name,
|
|
151
160
|
"id": discord_user.id,
|
|
@@ -161,7 +170,7 @@ async def get_user(discord_user: Union[discord.User, discord.Member]):
|
|
|
161
170
|
users_by_discord_id[discord_user.id] = persisted_user
|
|
162
171
|
except Exception as e:
|
|
163
172
|
logger.error(f"Error creating user: {e}")
|
|
164
|
-
|
|
173
|
+
|
|
165
174
|
return users_by_discord_id[discord_user.id]
|
|
166
175
|
|
|
167
176
|
|