taewon99 commited on
Commit
38c660f
β€’
1 Parent(s): 6332bb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -85,23 +85,24 @@ def get_vectorstore(text_chunks):
85
 
86
 
87
  def get_conversation_chain(vectorstore):
88
- model_name_or_path = "TheBloke/Llama-2-7B-chat-GGUF"
89
- model_basename = "llama-2-7b-chat.Q2_K.gguf"
90
  model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename)
91
 
92
- llm = LlamaCpp(
93
- model_path=model_path,
94
- n_ctx=4086,
95
- input={"temperature": 0.75, "max_length": 2000, "top_p": 1},
96
- verbose=True,
97
- )
98
  # λŒ€ν™” 기둝을 μ €μž₯ν•˜κΈ° μœ„ν•œ λ©”λͺ¨λ¦¬λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
99
- memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
 
100
  # λŒ€ν™” 검색 체인을 μƒμ„±ν•©λ‹ˆλ‹€.
101
  conversation_chain = ConversationalRetrievalChain.from_llm(
102
- llm=llm, retriever=vectorstore.as_retriever(), memory=memory
 
 
103
  )
104
- return conversation_chain # μƒμ„±λœ λŒ€ν™” 체인을 λ°˜ν™˜ν•©λ‹ˆλ‹€.
105
 
106
 
107
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
85
 
86
 
87
  def get_conversation_chain(vectorstore):
88
+ model_name_or_path = 'TheBloke/Llama-2-7B-chat-GGUF'
89
+ model_basename = 'llama-2-7b-chat.Q2_K.gguf'
90
  model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename)
91
 
92
+ llm = LlamaCpp(model_path=model_path,
93
+ n_ctx=4086,
94
+ input={"temperature": 0.75, "max_length": 2000, "top_p": 1},
95
+ verbose=True, )
 
 
96
  # λŒ€ν™” 기둝을 μ €μž₯ν•˜κΈ° μœ„ν•œ λ©”λͺ¨λ¦¬λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
97
+ memory = ConversationBufferMemory(
98
+ memory_key='chat_history', return_messages=True)
99
  # λŒ€ν™” 검색 체인을 μƒμ„±ν•©λ‹ˆλ‹€.
100
  conversation_chain = ConversationalRetrievalChain.from_llm(
101
+ llm=llm,
102
+ retriever=vectorstore.as_retriever(),
103
+ memory=memory
104
  )
105
+ return conversation_chain # μƒμ„±λœ λŒ€ν™” 체인을 λ°˜ν™˜ν•©λ‹ˆλ‹€.
106
 
107
 
108
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.