yoon2566 commited on
Commit
04f2633
ยท
verified ยท
1 Parent(s): f5c3861

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.environ["OPENAI_API_KEY"] = os.environ.get("GPT_API_KEY")
3
+
4
+ from langchain.chat_models import ChatOpenAI
5
+ from langchain import ConversationChain
6
+ import gradio as gr
7
+
8
+ # ๋žญ์ฒด์ธ ๋ชจ๋ธ ์ดˆ๊ธฐํ™”
9
+ llm = ChatOpenAI(temperature=0, model_name='gpt-4o-mini')
10
+ conversation = ConversationChain(llm=llm, verbose=True)
11
+
12
+ # Gradio ์ฑ—๋ด‡ ์‘๋‹ต ํ•จ์ˆ˜
13
+ def response(message, history):
14
+ # ๋žญ์ฒด์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€ํ™” ์˜ˆ์ธก
15
+ response_text = conversation.predict(input=message)
16
+ return response_text
17
+
18
+ # Gradio ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
19
+ gr.ChatInterface(
20
+ fn=response,
21
+ type="messages"
22
+ ).launch()