import gradio as gr import requests OLLAMA_API_URL = "http://airun.is-an.ai:11434/v1/chat/completions" MODEL_NAME = "airun-chat:latest" def respond(message, history): if history is None: history = [] # history 복사 messages = history.copy() # 사용자 메시지 추가 messages.append({"role": "user", "content": message}) # (예: API 호출) assistant_reply = "API에서 받은 답변 텍스트" # 어시스턴트 메시지 추가 messages.append({"role": "assistant", "content": assistant_reply}) # 반드시 (응답 텍스트, 메시지 리스트) 반환 return assistant_reply, messages demo = gr.ChatInterface(respond, type="messages") if __name__ == "__main__": demo.launch()