Skip to content

Commit

Permalink
Wd/fix element (#608)
Browse files Browse the repository at this point in the history
* fix element url when authenticated

* fix file url

* fix chat resume first interaction

* hide copy button is disable_feeback is true

* add changelog

* fix flaky tasklist test
  • Loading branch information
willydouhard authored Dec 21, 2023
1 parent 5f8c1b6 commit 9bd5973
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

Nothing is unreleased!

## [1.0.0rc3] - 2023-12-21

### Fixed

- Elements are now working when authenticated
- First interaction is correctly set when resuming a chat

### Changed

- The copy button is hidden if `disable_feedback` is `true`

## [1.0.0rc2] - 2023-12-18

### Added
Expand Down
5 changes: 4 additions & 1 deletion backend/chainlit/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@ async def create_element(self, element: "Element"):
"page": getattr(element, "page", None),
}

if not element.for_id:
return

await self.client.api.create_attachment(
thread_id=element.thread_id,
step_id=element.for_id or "",
step_id=element.for_id,
mime=element.mime,
name=element.name,
url=element.url,
Expand Down
2 changes: 0 additions & 2 deletions backend/chainlit/playground/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ async def create_completion(self, request):
api_version=env_settings["api_version"],
azure_endpoint=env_settings["azure_endpoint"],
azure_ad_token=self.get_var(request, "AZURE_AD_TOKEN"),
azure_ad_token_provider=self.get_var(request, "AZURE_AD_TOKEN_PROVIDER"),
azure_deployment=self.get_var(request, "AZURE_DEPLOYMENT"),
)
llm_settings = request.generation.settings
Expand Down Expand Up @@ -290,7 +289,6 @@ async def create_completion(self, request):
api_version=env_settings["api_version"],
azure_endpoint=env_settings["azure_endpoint"],
azure_ad_token=self.get_var(request, "AZURE_AD_TOKEN"),
azure_ad_token_provider=self.get_var(request, "AZURE_AD_TOKEN_PROVIDER"),
azure_deployment=self.get_var(request, "AZURE_DEPLOYMENT"),
)

Expand Down
1 change: 1 addition & 0 deletions backend/chainlit/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ async def connection_successful(sid):
if thread:
context.session.has_first_interaction = True
await context.emitter.clear_ask()
await context.emitter.emit("first_interaction", "resume")
await context.emitter.resume_thread(thread)
await config.code.on_chat_resume(thread)
return
Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chainlit"
version = "1.0.0rc2"
version = "1.0.0rc3"
keywords = ['LLM', 'Agents', 'gen ai', 'chat ui', 'chatbot ui', 'langchain']
description = "A faster way to build chatbot UIs."
authors = ["Chainlit"]
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/tasklist/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def on_message():
@cl.on_chat_start
async def main():
global task_list

await cl.sleep(0.5)
task_list = cl.TaskList()
task_list.status = "Running..."
for i in range(17):
Expand Down
11 changes: 6 additions & 5 deletions libs/react-client/src/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,14 @@ export class ChainlitAPI extends APIBase {
}

getElementUrl(id: string, sessionId: string, accessToken?: string) {
let tokenParam = '';
let queryParams = `?session_id=${sessionId}`;
if (accessToken) {
tokenParam = `?token=${accessToken}`;
if (accessToken.startsWith('Bearer ')) {
accessToken = accessToken.slice(7);
}
queryParams += `&token=${accessToken}`;
}
return this.buildEndpoint(
`/project/file/${id}?session_id=${sessionId}${tokenParam}`
);
return this.buildEndpoint(`/project/file/${id}${queryParams}`);
}

getLogoEndpoint(theme: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const MessageButtons = ({ message }: Props) => {
const isUser = message.type === 'user_message';
const isAsk = message.waitForAnswer;
const hasContent = !!message.output;
const showCopyButton = hasContent && !isUser && !isAsk;
const showCopyButton =
hasContent && !isUser && !isAsk && !message.disableFeedback;

const showFeedbackButtons =
showFbButtons &&
Expand Down

0 comments on commit 9bd5973

Please sign in to comment.