Skip to content

Commit

Permalink
add introduction to chainlit
Browse files Browse the repository at this point in the history
  • Loading branch information
tylertitsworth committed Dec 31, 2023
1 parent f53dc38 commit 47e6992
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def __init__(self):
exit(1)
self.convert_struct(**data)

def __getattr__(self, attr):
return self[attr]

def convert_struct(self, **kwargs):
for key, value in kwargs.items():
if isinstance(value, dict):
Expand Down Expand Up @@ -159,10 +156,7 @@ def create_chain():
return chain


# https://docs.chainlit.io/integrations/langchain
# https://docs.chainlit.io/examples/qa
@cl.on_chat_start
async def on_chat_start():
async def update_cl():
chain = create_chain()
# https://docs.chainlit.io/api-reference/chat-settings
inputs = [
Expand Down Expand Up @@ -223,11 +217,17 @@ async def on_chat_start():
)
)
await cl.ChatSettings(inputs).send()
# await cl.Message(content=wiki.introduction, disable_human_feedback=True).send()

cl.user_session.set("chain", chain)


# https://docs.chainlit.io/integrations/langchain
# https://docs.chainlit.io/examples/qa
@cl.on_chat_start
async def on_chat_start():
await update_cl()
await cl.Message(content=wiki.introduction, disable_human_feedback=True).send()


@cl.on_message
async def on_message(message: cl.Message):
chain = cl.user_session.get("chain")
Expand Down Expand Up @@ -262,7 +262,7 @@ async def on_message(message: cl.Message):
@cl.on_settings_update
async def setup_agent(settings):
wiki.set_chat_settings(settings)
await on_chat_start()
await update_cl()


if __name__ == "__main__":
Expand Down

0 comments on commit 47e6992

Please sign in to comment.