Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainlit ui example supporting incremental features. #1580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions examples/ui_with_chainlit/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chainlit as cl
from init_setup import ChainlitEnv

from chainlit.input_widget import Switch, TextInput
from metagpt.roles import (
Architect,
Engineer,
Expand Down Expand Up @@ -39,7 +39,20 @@ async def chat_profile() -> list[cl.ChatProfile]:
)
]


@cl.on_chat_start
async def start():
settings = await cl.ChatSettings(
[
TextInput(id="ProjectName", label="Project Name"),
TextInput(id="ProjectPath", label="Project Path"),
Switch(id="Incremental", label="Incremental Feature"),
]
).send()
@cl.on_settings_update
async def setup_agent(settings):
cl.user_session.set('incremental', settings['Incremental'])
cl.user_session.set('project_path', settings['ProjectPath'])
cl.user_session.set('project_name', settings['ProjectName'])
# https://docs.chainlit.io/concepts/message
@cl.on_message
async def startup(message: cl.Message) -> None:
Expand All @@ -61,7 +74,9 @@ async def startup(message: cl.Message) -> None:
QaEngineer(),
]
)

company.env.context.config.inc = cl.user_session.get('incremental')
company.env.context.config.project_path = cl.user_session.get('project_path')
company.env.context.config.project_name = cl.user_session.get('project_name')
company.invest(investment=3.0)
company.run_project(idea=idea)

Expand Down
Loading