lugiiing commited on
Commit
f4684a2
β€’
1 Parent(s): 7447dda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -12,19 +12,6 @@ from langchain.document_loaders import TextLoader
12
  from langchain.document_loaders import DirectoryLoader
13
 
14
 
15
- # from streamlit_chat import message
16
-
17
- # μŠ€νŠΈλ¦Όλ¦Ώμ΄λž‘ 파이썬, vsμ½”λ“œ 같은 폴더에
18
- # 이 νŒŒμΌλ„ 같은 폴더에 λ„£μ–΄μ•Όν•˜λŠ”μ§€λŠ” λͺ¨λ₯΄κ² μ›€,,
19
-
20
- # import streamlit as st
21
- # from io import StringIO
22
-
23
- # 경둜 /Users/gyuribyun/Documents/legoapp
24
- # 경둜 터미널에 μž…λ ₯ ν›„(cd 경둜 볡뢙)
25
- # streamlit run app.py둜 링크 λ°›κΈ°
26
-
27
-
28
  # 타이틀 적용, # 특수 이λͺ¨ν‹°μ½˜ μ‚½μž… μ˜ˆμ‹œ
29
  # emoji: https://streamlit-emoji-shortcodes-streamlit-app-gwckff.streamlit.app/
30
  st.title(':robot_face:ν•œκ΅­μ‚¬λ΄‡? λ„ˆ 정말 λ˜‘λ˜‘ν•˜λ‹ˆ?')
@@ -38,10 +25,12 @@ st.markdown('###### 질문, μš”μ•½ λ“± λ‹€μ–‘ν•œ 뢀탁을 ν•΄ λ³΄μ„Έμš”! ꡐ과
38
 
39
 
40
  api_key = st.text_input(label='OpenAI API ν‚€λ₯Ό μž…λ ₯ν•˜μ„Έμš”', type='password')
 
 
41
 
42
  if api_key:
43
  # OpenAI APIλ₯Ό μ‚¬μš©ν•˜κΈ° μœ„ν•œ 처리 과정을 ν•¨μˆ˜λ‘œ μ •μ˜
44
- def initialize_openai_processing(api_key):
45
 
46
  loader = DirectoryLoader('./khistory_data', glob="*.txt", loader_cls=TextLoader)
47
  documents = loader.load()
@@ -49,8 +38,8 @@ if api_key:
49
  texts = text_splitter.split_documents(documents)
50
 
51
  persist_directory = 'db'
52
- #embedding = OpenAIEmbeddings()
53
- embedding = OpenAIEmbeddings(api_key=api_key) # API ν‚€λ₯Ό μƒμ„±μžμ— 전달
54
  vectordb = Chroma.from_documents(
55
  documents=texts,
56
  embedding=embedding,
 
12
  from langchain.document_loaders import DirectoryLoader
13
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # 타이틀 적용, # 특수 이λͺ¨ν‹°μ½˜ μ‚½μž… μ˜ˆμ‹œ
16
  # emoji: https://streamlit-emoji-shortcodes-streamlit-app-gwckff.streamlit.app/
17
  st.title(':robot_face:ν•œκ΅­μ‚¬λ΄‡? λ„ˆ 정말 λ˜‘λ˜‘ν•˜λ‹ˆ?')
 
25
 
26
 
27
  api_key = st.text_input(label='OpenAI API ν‚€λ₯Ό μž…λ ₯ν•˜μ„Έμš”', type='password')
28
+ OpenAI.api_key = api_key
29
+
30
 
31
  if api_key:
32
  # OpenAI APIλ₯Ό μ‚¬μš©ν•˜κΈ° μœ„ν•œ 처리 과정을 ν•¨μˆ˜λ‘œ μ •μ˜
33
+ def initialize_openai_processing():
34
 
35
  loader = DirectoryLoader('./khistory_data', glob="*.txt", loader_cls=TextLoader)
36
  documents = loader.load()
 
38
  texts = text_splitter.split_documents(documents)
39
 
40
  persist_directory = 'db'
41
+ embedding = OpenAIEmbeddings()
42
+ #embedding = OpenAIEmbeddings(api_key=api_key) # API ν‚€λ₯Ό μƒμ„±μžμ— 전달
43
  vectordb = Chroma.from_documents(
44
  documents=texts,
45
  embedding=embedding,