vmalapaka commited on
Commit
0273f37
·
verified ·
1 Parent(s): 77ae245

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -14
app.py CHANGED
@@ -23,20 +23,29 @@ if summarise_button:
23
  response_container = st.container()
24
  container = st.container()
25
 
 
 
 
 
 
 
 
26
  def get_response(User_input):
27
 
28
- llm = ChatOpenAI(
29
- temperature=0,
30
- model_name='gpt-3.5-turbo-0125'
31
- )
32
-
33
- conversation = ConversationChain(
34
- llm=llm,
35
- verbose=True,
36
- memory=ConversationBufferMemory()
37
- )
38
-
39
- response = conversation.predict(input=User_input)
 
 
40
 
41
  return response
42
 
@@ -47,9 +56,12 @@ with container:
47
  user_input = st.text_area("Your question goes here:", key='input', height=100)
48
  submit_button = st.form_submit_button(label='Send')
49
  if submit_button:
50
- answer = get_response(user_input)
 
 
 
51
  with response_container:
52
- st.write(answer)
53
 
54
 
55
 
 
23
  response_container = st.container()
24
  container = st.container()
25
 
26
+ if 'conversation' not in st.session_state:
27
+ st.session_state['conversation'] =None
28
+ if 'messages' not in st.session_state:
29
+ st.session_state['messages'] =[]
30
+ if 'API_Key' not in st.session_state:
31
+ st.session_state['API_Key'] =''
32
+
33
  def get_response(User_input):
34
 
35
+ if st.session_state['conversation'] is None:
36
+
37
+ llm = ChatOpenAI(
38
+ temperature=0,
39
+ model_name='gpt-3.5-turbo-0125'
40
+ )
41
+
42
+ st.session_state['conversation'] = ConversationChain(
43
+ llm=llm,
44
+ verbose=True,
45
+ memory=ConversationBufferMemory()
46
+ )
47
+
48
+ response = st.session_state['conversation'].predict(input=User_input)
49
 
50
  return response
51
 
 
56
  user_input = st.text_area("Your question goes here:", key='input', height=100)
57
  submit_button = st.form_submit_button(label='Send')
58
  if submit_button:
59
+ st.session_state['messages'].append(user_input)
60
+ model_response = get_response(user_input)
61
+ st.session_state['messages'].append(model_response)
62
+ st.write(st.session_state['messages'])
63
  with response_container:
64
+ st.write(model_response)
65
 
66
 
67