saikumar27 commited on
Commit
9720f44
Β·
verified Β·
1 Parent(s): d0accd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -17,8 +17,8 @@ if not api_key:
17
  # βœ… Configure Gemini Model
18
  model = ChatGoogleGenerativeAI(model="gemini-1.5-pro", api_key=api_key)
19
 
20
- # βœ… Add Memory to Make It Context-Aware
21
- memory = ConversationBufferMemory()
22
 
23
  # βœ… Define Prompt for Data Science Focus
24
  prompt_template = """
@@ -28,15 +28,18 @@ You are an AI Data Science tutor.
28
  - Provide clear, detailed, and accurate explanations with examples where applicable.
29
  - Avoid overly technical language unless necessary.
30
 
 
 
 
31
  User: {input}
32
  AI:
33
  """
34
 
35
- # βœ… Create Conversation Chain
36
  conversation = ConversationChain(
37
  llm=model,
38
  memory=memory,
39
- prompt=PromptTemplate(template=prompt_template, input_variables=["input"])
40
  )
41
 
42
  # βœ… Streamlit UI
 
17
  # βœ… Configure Gemini Model
18
  model = ChatGoogleGenerativeAI(model="gemini-1.5-pro", api_key=api_key)
19
 
20
+ # βœ… Add Memory to Make It Context-Aware (Fix for 'history' error)
21
+ memory = ConversationBufferMemory(input_key="input")
22
 
23
  # βœ… Define Prompt for Data Science Focus
24
  prompt_template = """
 
28
  - Provide clear, detailed, and accurate explanations with examples where applicable.
29
  - Avoid overly technical language unless necessary.
30
 
31
+ Chat History:
32
+ {history}
33
+
34
  User: {input}
35
  AI:
36
  """
37
 
38
+ # βœ… Create Conversation Chain (Matching Memory Keys)
39
  conversation = ConversationChain(
40
  llm=model,
41
  memory=memory,
42
+ prompt=PromptTemplate(template=prompt_template, input_variables=["history", "input"])
43
  )
44
 
45
  # βœ… Streamlit UI