Skip to content

Commit

Permalink
Use custom build to serve the copilot index.html file (#95)
Browse files Browse the repository at this point in the history
- This simplifies the copilot demo by removing the dependency on the `http-server` node cli package
  • Loading branch information
tpatel committed Mar 28, 2024
1 parent 89be87f commit 9dce8cf
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 27 deletions.
106 changes: 106 additions & 0 deletions copilot/.chainlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[project]
# 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

# Authorized origins
allow_origins = ["*"]

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

[features]
# Show the prompt playground
prompt_playground = true

# Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
unsafe_allow_html = false

# Process and display mathematical expressions. This can clash with "$" characters in messages.
latex = false

# Authorize users to upload files with messages
[features.multi_modal]
enabled = true
accept = ["*/*"]
max_files = 20
max_size_mb = 500

# Allows user to use speech to text
[features.speech_to_text]
enabled = false
# See all languages here https://github.com/JamesBrill/react-speech-recognition/blob/HEAD/docs/API.md#language-string
# language = "en-US"

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

# Show the readme while the thread is empty.
show_readme_as_default = true

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

# Large size content are by default collapsed for a cleaner ui
default_collapse_content = true

# 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 = ""

# Specify a CSS file that can be used to customize the user interface.
# The CSS file can be served from the public directory or via an external link.
# custom_css = "/public/test.css"

# Specify a Javascript file that can be used to customize the user interface.
# The Javascript file can be served from the public directory.
# custom_js = "/public/test.js"

# Specify a custom font url.
# custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"

# Specify a custom build directory for the frontend.
# This can be used to customize the frontend code.
# Be careful: If this is a relative path, it should not start with a slash.
custom_build = "./"

# Override default MUI light theme. (Check theme.ts)
[UI.theme]
#font_family = "Inter, sans-serif"
[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 = "1.0.301"
9 changes: 2 additions & 7 deletions copilot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
Run the chainlit application:

```shell
chainlit run app.py -h
```

Serve the `index.html` file:

```shell
npx http-server
chainlit run app.py
```
This demo uses the custom build feature to serve the frontend through chainlit, although you can serve it through any other server.
Empty file.
24 changes: 24 additions & 0 deletions copilot/frontend/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
</head>

<body>
<h1>Chainlit Copilot Test</h1>
<script src="http://localhost:8000/copilot/index.js"></script>
<script>
window.mountChainlitWidget({
chainlitServer: "http://localhost:8000",
});
window.addEventListener("chainlit-call-fn", (e) => {
const { name, args, callback } = e.detail;
if (name === "test") {
callback("You sent: " + args.msg);
}
});
</script>
</body>

</html>
20 changes: 0 additions & 20 deletions copilot/index.html

This file was deleted.

0 comments on commit 9dce8cf

Please sign in to comment.