JUNGU commited on
Commit
4888c0f
β€’
1 Parent(s): f7a9654

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -12,10 +12,7 @@ from dotenv import load_dotenv
12
  import openai
13
 
14
  load_dotenv()
15
- #λΉ„λ°€ν‚€ κ°€μ Έμ˜€κΈ° μ‹œλ„μ€‘
16
- # api_key = os.getenv('OPENAI_API_KEY') ## .env 파일 μ—…λ‘œλ“œν•˜λ©΄ μˆ¨κ²¨μ§€μ§€ μ•ŠμŒ μ•ˆλ¨
17
- # api_key = os.environ['my_secret'] ## μ•ˆλΆˆλŸ¬μ™€μ§
18
- # api_key = os.getenv('my_secret') ## 3트 .env λŒ€μ‹  secretν‚€λ₯Ό λΆˆλŸ¬μ˜€λŠ” ν˜•νƒœλ‘œ 도전
19
  os.environ["OPENAI_API_KEY"] = os.environ['my_secret']
20
 
21
  loader = PyPDFLoader("/home/user/app/docs.pdf")
@@ -32,7 +29,7 @@ retriever = vector_store.as_retriever(search_kwargs={"k": 2})
32
  from langchain.chat_models import ChatOpenAI
33
  from langchain.chains import RetrievalQAWithSourcesChain
34
 
35
- llm = ChatOpenAI(model_name="gpt-4", temperature=0) # Modify model_name if you have access to GPT-4
36
 
37
  chain = RetrievalQAWithSourcesChain.from_chain_type(
38
  llm=llm,
@@ -66,7 +63,7 @@ from langchain.chains import RetrievalQAWithSourcesChain
66
 
67
  chain_type_kwargs = {"prompt": prompt}
68
 
69
- llm = ChatOpenAI(model_name="gpt-4", temperature=0) # Modify model_name if you have access to GPT-4
70
 
71
  chain = RetrievalQAWithSourcesChain.from_chain_type(
72
  llm=llm,
@@ -100,7 +97,7 @@ def respond(message, chat_history): # μ±„νŒ…λ΄‡μ˜ 응닡을 μ²˜λ¦¬ν•˜λŠ” 함
100
  return "", chat_history # μˆ˜μ •λœ μ±„νŒ… 기둝을 λ°˜ν™˜ν•©λ‹ˆλ‹€.
101
 
102
  with gr.Blocks(theme='gstaff/sketch') as demo: # gr.Blocks()λ₯Ό μ‚¬μš©ν•˜μ—¬ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
103
- gr.Markdown("# μ•ˆλ…•ν•˜μ„Έμš”. 세이노와 λŒ€ν™”ν•΄λ³΄μ„Έμš”.")
104
  chatbot = gr.Chatbot(label="μ±„νŒ…μ°½") # 'μ±„νŒ…μ°½'μ΄λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 μ±„νŒ…λ΄‡ μ»΄ν¬λ„ŒνŠΈλ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
105
  msg = gr.Textbox(label="μž…λ ₯") # 'μž…λ ₯'μ΄λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 ν…μŠ€νŠΈλ°•μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
106
  clear = gr.Button("μ΄ˆκΈ°ν™”") # 'μ΄ˆκΈ°ν™”'λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 λ²„νŠΌμ„ μƒμ„±ν•©λ‹ˆλ‹€.
 
12
  import openai
13
 
14
  load_dotenv()
15
+
 
 
 
16
  os.environ["OPENAI_API_KEY"] = os.environ['my_secret']
17
 
18
  loader = PyPDFLoader("/home/user/app/docs.pdf")
 
29
  from langchain.chat_models import ChatOpenAI
30
  from langchain.chains import RetrievalQAWithSourcesChain
31
 
32
+ llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0) # Modify model_name if you have access to GPT-4
33
 
34
  chain = RetrievalQAWithSourcesChain.from_chain_type(
35
  llm=llm,
 
63
 
64
  chain_type_kwargs = {"prompt": prompt}
65
 
66
+ llm = ChatOpenAI(model_name="gpt-3.5", temperature=0) # Modify model_name if you have access to GPT-4
67
 
68
  chain = RetrievalQAWithSourcesChain.from_chain_type(
69
  llm=llm,
 
97
  return "", chat_history # μˆ˜μ •λœ μ±„νŒ… 기둝을 λ°˜ν™˜ν•©λ‹ˆλ‹€.
98
 
99
  with gr.Blocks(theme='gstaff/sketch') as demo: # gr.Blocks()λ₯Ό μ‚¬μš©ν•˜μ—¬ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
100
+ gr.Markdown("# μ•ˆλ…•ν•˜μ„Έμš”. 세이노와 λŒ€ν™”ν•΄λ³΄μ„Έμš”. \n λ‹΅λ³€ 생성에 쑰금 μ‹œκ°„μ΄ μ†Œμš”λ  수 μžˆμŠ΅λ‹ˆλ‹€.")
101
  chatbot = gr.Chatbot(label="μ±„νŒ…μ°½") # 'μ±„νŒ…μ°½'μ΄λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 μ±„νŒ…λ΄‡ μ»΄ν¬λ„ŒνŠΈλ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
102
  msg = gr.Textbox(label="μž…λ ₯") # 'μž…λ ₯'μ΄λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 ν…μŠ€νŠΈλ°•μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
103
  clear = gr.Button("μ΄ˆκΈ°ν™”") # 'μ΄ˆκΈ°ν™”'λΌλŠ” λ ˆμ΄λΈ”μ„ 가진 λ²„νŠΌμ„ μƒμ„±ν•©λ‹ˆλ‹€.