chainlit
chainlit copied to clipboard
chainlit use graphsignal err
code
import logging
import os
import sys
import chainlit as cl
import graphsignal
from dotenv import load_dotenv
from graphsignal.callbacks.llama_index import GraphsignalCallbackHandler
from langchain.chat_models import ChatOpenAI
from llama_index import LLMPredictor, ServiceContext, GPTVectorStoreIndex, SimpleDirectoryReader
from llama_index.callbacks import CallbackManager
from llama_index.prompts.base import Prompt
load_dotenv()
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
@cl.on_message
def main(message: str):
graphsignal.configure(deployment='auto-fortune-telling-v1')
documents = SimpleDirectoryReader("source_documents/zhou_yi").load_data()
index = GPTVectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query(message)
cl.Message(content=str(response), ).send()
error:
Unknown max input size for gpt-3.5-turbo, using defaults.
Traceback (most recent call last):
File "src/gevent/_abstract_linkable.py", line 287, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
File "src/gevent/_abstract_linkable.py", line 333, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
AssertionError: (None, <callback at 0x7ff711ee0540 args=([],)>)
2023-06-02T04:54:12Z <callback at 0x7ff711ee0540 args=([],)> failed with AssertionError
I am not sure what causes the issue, I have played with llama_index so far. Will try to reproduce.
Quick recommendations (probably not the issue here but still):
- Chainlit already does
load_dotenv()for you, no need to do it yourself - I would not configure the index on every message. If you need to configure it once for all users just do it in the main scope of the file, if you do need to configure per user user @cl.on_chat_start