truera / trulens

Evaluation and Tracking for LLM Experiments
https://www.trulens.org/
MIT License
2.16k stars 188 forks source link

ArrowInvalid: ('cannot mix struct and non-struct, non-null values', 'Conversion failed for column statement with type object') #763

Closed budhewarvijay0407 closed 9 months ago

budhewarvijay0407 commented 10 months ago

While running dashboard , Im getting this error :

ArrowInvalid: ('cannot mix struct and non-struct, non-null values', 'Conversion failed for column statement with type object') Traceback: File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script exec(code, module.dict) File "C:\anaconda_setup\envs\SDG-goal\Lib\site-packages\trulens_eval\pages\Evaluations.py", line 369, in display_feedback_call(feedback_calls) File "C:\anaconda_setup\envs\SDG-goal\Lib\site-packages\trulens_eval\pages\Evaluations.py", line 358, in display_feedback_call st.dataframe( File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\streamlit\runtime\metrics_util.py", line 396, in wrapped_func result = non_optional_func(*args, **kwargs) File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\streamlit\elements\arrow.py", line 230, in dataframe proto.data = type_util.data_frame_to_bytes(data_df) File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\streamlit\type_util.py", line 821, in data_frame_to_bytes table = pa.Table.from_pandas(df) File "pyarrow\table.pxi", line 3869, in pyarrow.lib.Table.from_pandas File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\pyarrow\pandas_compat.py", line 613, in dataframe_to_arrays arrays = [convert_column(c, f) File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\pyarrow\pandas_compat.py", line 613, in arrays = [convert_column(c, f) File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\pyarrow\pandas_compat.py", line 600, in convert_column raise e File "C:\anaconda_setup\envs\SDG-goal\lib\site-packages\pyarrow\pandas_compat.py", line 594, in convertcolumn result = pa.array(col, type=type, from_pandas=True, safe=safe) File "pyarrow\array.pxi", line 340, in pyarrow.lib.array File "pyarrow\array.pxi", line 86, in pyarrow.lib._ndarray_to_array File "pyarrow\error.pxi", line 91, in pyarrow.lib.check_status

more info :

I'm running only context relevance feedback function as follow

f_context_relevance = ( Feedback(fopenai.qs_relevance_with_cot_reasons, name = "Context Relevance") .on(Select.RecordCalls.retrieve.args.query) .on(Select.RecordCalls.retrieve.rets.collect()) .aggregate(np.mean) )

My Rag from scratch ::

class RAG_from_scratch: @instrument def retrieve(self, query: str) -> list: """ Retrieve relevant text from vector store. """ results = db_faiss.similarity_search_with_relevance_scores(query,2) return results

@instrument
def generate_completion(self, query: str, context_str: list) -> str:
    """
    Generate answer from context.
    """
    total_supporting_text = ''
    for action_information in range(len(context_str)):
        total_supporting_text = context_str[action_information][0].page_content + total_supporting_text
    completion = openai.chat.completions.create(
  model="gpt-4",
  messages=[{}],  # I have removed the messages 
  max_tokens = 60,
  temperature = 0.6,
  frequency_penalty = 1.6
).choices[0].message.content
    return completion

@instrument
def query(self, query: str) -> str:
    context_str = self.retrieve(query)
    completion = self.generate_completion(query, context_str)
    return completion

rag = RAG_from_scratch()

Note : The app (dashboard) does not throw this error for QA relevance feedback function

joshreini1 commented 9 months ago

Hey @budhewarvijay0407 - can you install from github and retry? This may have already been resolved

joshreini1 commented 9 months ago

Closing because this is stale. Please re-open if the issue persists.