DrishtiSharma commited on
Commit
399d645
1 Parent(s): d8b5474

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -28,10 +28,36 @@ api = st.sidebar.text_input("API-key", type = "password")
28
  MODEL = st.sidebar.selectbox(label = "Model", options = ["gpt-3.5-turbo", "text-davinci-003"])
29
 
30
  if api:
 
31
  llm = OpenAI(
32
  temperature = 0,
33
  open_api_key = api,
34
  model_name = MODEL
35
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
 
 
28
  MODEL = st.sidebar.selectbox(label = "Model", options = ["gpt-3.5-turbo", "text-davinci-003"])
29
 
30
  if api:
31
+
32
  llm = OpenAI(
33
  temperature = 0,
34
  open_api_key = api,
35
  model_name = MODEL
36
  )
37
+
38
+ #Create Conv Memory
39
+
40
+ if "entity_memory" not in st.session_state:
41
+ st.session_state.entity_memory = ConversationEntityMemory(
42
+ llm = llm,
43
+ k = 10
44
+ )
45
+
46
+ # Create Conv Chain
47
+
48
+ Conversation = ConversationChain(
49
+ llm = llm,
50
+ prompt = ENTITY_MEMORY_CONVERSATION_TEMPLATE,
51
+ memory = st.session_state.entity_memory
52
+ )
53
+
54
+ else:
55
+ st.error("No API found!")
56
+
57
+
58
+ if user_input:
59
+ output = Conversation.run(input = user_input)
60
+ st.session_state.past.append(user_input)
61
+ st.session_state.generated.append(output)
62
 
63