File size: 1,017 Bytes
8297f0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d60875c
07bdcb4
 
 
 
 
8297f0d
 
 
 
 
 
 
07bdcb4
 
 
 
 
 
 
ab4ff74
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from openai import AsyncOpenAI

from fastapi.responses import JSONResponse

from chainlit.auth import create_jwt
from chainlit.server import app

@app.get("/custom-auth")
async def custom_auth():
    # Verify the user's identity with custom logic.
    token = create_jwt(cl.User(identifier="Test User"))
    return JSONResponse({"token": token})



import langroid as lr
import langroid.language_models as lm
import chainlit as cl


import langroid as lr
import langroid.language_models as lm
import chainlit as cl


@cl.on_chat_start
async def on_chat_start():
      lm_config = lm.OpenAIGPTConfig(
        chat_model=model or lm.OpenAIChatModel.GPT4_TURBO,
        chat_context_length=8_000,
        temperature=0,
        max_output_tokens=200,
        timeout=45,
    )
        agent = lr.ChatAgent(lr.ChatAgentConfig(llm=lm_config))
        task = lr.Task(agent, interactive=True)
    
        msg = "Help me with some questions"
        lr.ChainlitTaskCallbacks(task)
        await task.run_async(msg)