| 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() | |