Spaces:
Running
Running
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() |