leo-bourrel commited on
Commit
bc46efe
·
1 Parent(s): c89ea47

feat: add optional source documents to message

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. message.py +2 -1
app.py CHANGED
@@ -54,7 +54,9 @@ def on_click_callback():
54
  human_prompt = st.session_state.human_prompt
55
  llm_response = st.session_state.conversation(human_prompt)
56
  st.session_state.history.append(Message("human", human_prompt))
57
- st.session_state.history.append(Message("ai", llm_response["answer"]))
 
 
58
  st.session_state.token_count += cb.total_tokens
59
 
60
 
 
54
  human_prompt = st.session_state.human_prompt
55
  llm_response = st.session_state.conversation(human_prompt)
56
  st.session_state.history.append(Message("human", human_prompt))
57
+ st.session_state.history.append(
58
+ Message("ai", llm_response["answer"], llm_response["source_documents"])
59
+ )
60
  st.session_state.token_count += cb.total_tokens
61
 
62
 
message.py CHANGED
@@ -1,5 +1,5 @@
1
  from dataclasses import dataclass
2
- from typing import Literal
3
 
4
 
5
  @dataclass
@@ -8,3 +8,4 @@ class Message:
8
 
9
  origin: Literal["human", "ai"]
10
  message: str
 
 
1
  from dataclasses import dataclass
2
+ from typing import Literal, Optional
3
 
4
 
5
  @dataclass
 
8
 
9
  origin: Literal["human", "ai"]
10
  message: str
11
+ metadata: Optional[dict] = None