gpt4omini2 / app.py
yoon2566's picture
Create app.py
04f2633 verified
raw
history blame contribute delete
627 Bytes
import os
os.environ["OPENAI_API_KEY"] = os.environ.get("GPT_API_KEY")
from langchain.chat_models import ChatOpenAI
from langchain import ConversationChain
import gradio as gr
# ๋žญ์ฒด์ธ ๋ชจ๋ธ ์ดˆ๊ธฐํ™”
llm = ChatOpenAI(temperature=0, model_name='gpt-4o-mini')
conversation = ConversationChain(llm=llm, verbose=True)
# Gradio ์ฑ—๋ด‡ ์‘๋‹ต ํ•จ์ˆ˜
def response(message, history):
# ๋žญ์ฒด์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€ํ™” ์˜ˆ์ธก
response_text = conversation.predict(input=message)
return response_text
# Gradio ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
gr.ChatInterface(
fn=response,
type="messages"
).launch()