Skip to content

Commit

Permalink
Merge pull request #358 from Chainlit/clement/cha-302-add-an-option-t…
Browse files Browse the repository at this point in the history
…o-disable-the-prompt-playground

Add an option to disable the prompt playground
  • Loading branch information
clementsirieix authored Sep 4, 2023
2 parents 9bd8694 + c1487bc commit e4c81af
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ venv
.DS_Store

.chainlit
!cypress/e2e/**/*/.chainlit
chainlit.md

cypress/screenshots
Expand Down
5 changes: 5 additions & 0 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
# Link to your github repo. This will add a github button in the UI's header.
# github = ""
# Show the prompt playground
show_prompt_playground = true
# Override default MUI light theme. (Check theme.ts)
[UI.theme.light]
#background = "#FAFAFA"
Expand Down Expand Up @@ -148,6 +151,8 @@ class UISettings(DataClassJsonMixin):
default_expand_messages: bool = False
github: Optional[str] = None
theme: Optional[Theme] = None
# Show the prompt playground
show_prompt_playground: bool = True


@dataclass()
Expand Down
3 changes: 3 additions & 0 deletions backend/chainlit/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ async def _create(self):
raise e
logger.error(f"Failed to persist message: {str(e)}")

if not config.ui.show_prompt_playground:
msg_dict.pop("prompt", None)

return msg_dict

async def update(
Expand Down
72 changes: 72 additions & 0 deletions cypress/e2e/file_upload/.chainlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[project]
# If true (default), the app will be available to anonymous users.
# 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).
# The project ID is required when public is set to false or when using the cloud database.
#id = ""

# Uncomment if you want to persist the chats.
# local will create a database in your .chainlit directory (requires node.js installed).
# cloud will use the Chainlit cloud database.
# custom will load use your custom client.
# database = "local"

# 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 = []

# Duration (in seconds) during which the session is saved when the connection is lost
session_timeout = 3600

# Enable third parties caching (e.g LangChain cache)
cache = false

# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
# follow_symlink = false

# Chainlit server address
# chainlit_server = ""

[UI]
# Name of the app and chatbot.
name = "Chatbot"

# Description of the app and chatbot. This is used for HTML tags.
# description = ""

# The default value for the expand messages settings.
default_expand_messages = false

# Hide the chain of thought details from the user in the UI.
hide_cot = false

# Link to your github repo. This will add a github button in the UI's header.
# github = ""

# Override default MUI light theme. (Check theme.ts)
[UI.theme.light]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.light.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"

# Override default MUI dark theme. (Check theme.ts)
[UI.theme.dark]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.dark.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"


[meta]
generated_by = "0.6.402"
75 changes: 75 additions & 0 deletions cypress/e2e/hide_prompt_playground/.chainlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[project]
# If true (default), the app will be available to anonymous users.
# 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).
# The project ID is required when public is set to false or when using the cloud database.
#id = ""

# Uncomment if you want to persist the chats.
# local will create a database in your .chainlit directory (requires node.js installed).
# cloud will use the Chainlit cloud database.
# custom will load use your custom client.
# database = "local"

# 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 = []

# Duration (in seconds) during which the session is saved when the connection is lost
session_timeout = 3600

# Enable third parties caching (e.g LangChain cache)
cache = false

# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
# follow_symlink = false

# Chainlit server address
# chainlit_server = ""

[UI]
# Name of the app and chatbot.
name = "Chatbot"

# Description of the app and chatbot. This is used for HTML tags.
# description = ""

# The default value for the expand messages settings.
default_expand_messages = false

# Hide the chain of thought details from the user in the UI.
hide_cot = false

# Link to your github repo. This will add a github button in the UI's header.
# github = ""

# Show the prompt playground.
show_prompt_playground = false

# Override default MUI light theme. (Check theme.ts)
[UI.theme.light]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.light.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"

# Override default MUI dark theme. (Check theme.ts)
[UI.theme.dark]
#background = "#FAFAFA"
#paper = "#FFFFFF"

[UI.theme.dark.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"


[meta]
generated_by = "0.6.402"
31 changes: 31 additions & 0 deletions cypress/e2e/hide_prompt_playground/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from chainlit.prompt import Prompt

import chainlit as cl

template = """Hello, this is a template.
This is a simple variable {variable1}
This is a another simple {variable2}
Those are two simple variables {variable1} + {variable2}
This is a formatting test {{variable1}} {{{variable2}}} {variable3}
This is another formatting test {{{{variable1}}}} {{{{{variable1}}}}}
This is a curly braces formatting test {{ {{{{ }} }}}}
"""

inputs = {
"variable1": "variable1 value",
"variable2": "variable2 value",
"variable3": "{{variable3 value}}",
}

completion = "This is the original completion"


@cl.on_chat_start
async def start():
await cl.Message(
content="This is a message with a basic prompt",
prompt=Prompt(
template=template,
inputs=inputs,
),
).send()
13 changes: 13 additions & 0 deletions cypress/e2e/hide_prompt_playground/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { runTestServer } from '../../support/testUtils';

describe('HidePromptPlayground', () => {
before(() => {
runTestServer();
});

describe('Basic template', () => {
it('should not display the playground button', () => {
cy.get('.playground-button').should('not.exist');
});
});
});

0 comments on commit e4c81af

Please sign in to comment.