-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Chainlit/wd/rework-elements
Wd/rework elements
- Loading branch information
Showing
38 changed files
with
495 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import chainlit as cl | ||
|
||
|
||
@cl.action("action1") | ||
@cl.action("test action") | ||
def on_action(): | ||
cl.send_message("Executed action 1!") | ||
cl.send_message("Executed test action!") | ||
|
||
|
||
@cl.action("removable action") | ||
def on_action(action: cl.Action): | ||
cl.send_message("Executed removable action!") | ||
action.remove() | ||
|
||
|
||
@cl.on_chat_start | ||
def main(): | ||
cl.send_message("Hello, here is a clickable action!") | ||
cl.send_action(name="action1", trigger="clickable action", | ||
description="Click on this to run action1!") | ||
actions = [ | ||
cl.Action(name="test action", value="test"), | ||
cl.Action(name="removable action", value="test"), | ||
] | ||
cl.send_message("Hello, this is a test message!", actions=actions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import chainlit as cl | ||
|
||
|
||
@cl.on_chat_start | ||
def start(): | ||
cl.LocalImage(path="./cat.jpeg", name="image1", display="inline").send() | ||
cl.Text(text="Here is a side text document", name="text1", display="side").send() | ||
cl.Text(text="Here is a page text document", name="text2", display="page").send() | ||
|
||
cl.send_message( | ||
content="Here is image1, a nice image of a cat! As well as text1 and text2!", | ||
) |
2 changes: 1 addition & 1 deletion
2
cypress/e2e/elements/spec.cy.ts → cypress/e2e/global_elements/spec.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[project] | ||
# Name of the app and chatbot. | ||
name = "Chatbot" | ||
|
||
# If true (default), the app will be available to anonymous users (once deployed). | ||
# If false, users will need to authenticate and be part of the project to use the app. | ||
public = true | ||
|
||
# The project ID (found on https://cloud.chainlit.io). | ||
# If provided, all the message data will be stored in the cloud. | ||
# The project ID is required when public is set to false. | ||
#id = "" | ||
|
||
# Whether to enable telemetry (default: true). No personal data is collected. | ||
enable_telemetry = true | ||
|
||
# List of environment variables to be provided by each user to use the app. | ||
user_env = [] | ||
|
||
# Hide the chain of thought details from the user in the UI. | ||
hide_cot = false | ||
|
||
# Limit the number of requests per user. | ||
#request_limit = "10 per day" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import chainlit as cl | ||
|
||
|
||
@cl.on_chat_start | ||
def start(): | ||
elements = [ | ||
cl.LocalImage(path="./cat.jpeg", name="image1", display="inline"), | ||
cl.Text(text="Here is a side text document", name="text1", display="side"), | ||
cl.Text(text="Here is a page text document", name="text2", display="page"), | ||
] | ||
|
||
# Element should not be inlined or referenced | ||
cl.send_message( | ||
content="Here is image1, a nice image of a cat! As well as text1 and text2!", | ||
) | ||
# Image should be inlined even if not referenced | ||
cl.send_message( | ||
content="Here a nice image of a cat! As well as text1 and text2!", | ||
elements=elements, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe("Scoped Elements", () => { | ||
before(() => { | ||
cy.intercept("/project/settings").as("settings"); | ||
cy.visit("http://127.0.0.1:8000"); | ||
cy.wait(["@settings"]); | ||
}); | ||
|
||
it("should be able to display inlined, side and page elements", () => { | ||
cy.get(".message").should("have.length", 2); | ||
|
||
cy.get(".message").eq(0).find(".inlined-image").should("have.length", 0); | ||
cy.get(".message").eq(0).find(".element-link").should("have.length", 0); | ||
|
||
cy.get(".message").eq(1).find(".inlined-image").should("have.length", 1); | ||
cy.get(".message").eq(1).find(".element-link").should("have.length", 2); | ||
}); | ||
}); |
Oops, something went wrong.