Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
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 |
-
|
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,
|