Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- README.md +13 -10
- app.py +9 -0
- chainlit.md +14 -0
- index.html +20 -0
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Software Copilot with Chainlit
|
| 2 |
+
|
| 3 |
+
Run the chainlit application:
|
| 4 |
+
|
| 5 |
+
```shell
|
| 6 |
+
chainlit run app.py -h
|
| 7 |
+
```
|
| 8 |
+
|
| 9 |
+
Serve the `index.html` file:
|
| 10 |
+
|
| 11 |
+
```shell
|
| 12 |
+
npx http-server
|
| 13 |
+
```
|
app.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import chainlit as cl
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
@cl.on_message
|
| 5 |
+
async def on_message(msg: cl.Message):
|
| 6 |
+
if cl.context.session.client_type == "copilot":
|
| 7 |
+
fn = cl.CopilotFunction(name="test", args={"msg": msg.content})
|
| 8 |
+
res = await fn.acall()
|
| 9 |
+
await cl.Message(content=res).send()
|
chainlit.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Welcome to Chainlit! ππ€
|
| 2 |
+
|
| 3 |
+
Hi there, Developer! π We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
|
| 4 |
+
|
| 5 |
+
## Useful Links π
|
| 6 |
+
|
| 7 |
+
- **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) π
|
| 8 |
+
- **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! π¬
|
| 9 |
+
|
| 10 |
+
We can't wait to see what you create with Chainlit! Happy coding! π»π
|
| 11 |
+
|
| 12 |
+
## Welcome screen
|
| 13 |
+
|
| 14 |
+
To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
|
index.html
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<html>
|
| 2 |
+
<head>
|
| 3 |
+
<meta charset="UTF-8" />
|
| 4 |
+
</head>
|
| 5 |
+
<body>
|
| 6 |
+
<h1>Chainlit Copilot Test</h1>
|
| 7 |
+
<script src="http://localhost:8000/copilot/index.js"></script>
|
| 8 |
+
<script>
|
| 9 |
+
window.mountChainlitWidget({
|
| 10 |
+
chainlitServer: "http://localhost:8000",
|
| 11 |
+
});
|
| 12 |
+
window.addEventListener("chainlit-call-fn", (e) => {
|
| 13 |
+
const { name, args, callback } = e.detail;
|
| 14 |
+
if (name === "test") {
|
| 15 |
+
callback("You sent: " + args.msg);
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
</script>
|
| 19 |
+
</body>
|
| 20 |
+
</html>
|