【RAG 项目实战 02】 Chainlit 持久化对话历史

【RAG 项目实战 02】Chainlit 持久化对话历史


NLP Github 项目:


01 创建账号

1、登录 Literal AI 
2、创建一个项目

3、在设置页面复制API Key

02 创建密码

1、 使用  chainlit create-secret 命令创建密钥,并复制到 .env

2、添加密码验证

from typing import Optional
import chainlit as cl

@cl.password_auth_callback
def auth_callback(username: str, password: str):
    # Fetch the user matching username from your database
    # and compare the hashed password with the value stored in the database
    if (username, password) == ("admin", "admin"):
        return cl.User(
            identifier="admin", metadata={"role": "admin", "provider": "credentials"}
        )
    else:
        return None

【动手学 RAG】系列文章:

本文由mdnice多平台发布

posted @   青松^_^  阅读(63)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示