| import gradio as gr | |
| from langchain_ollama import ChatOllama | |
| from langchain_core.messages import ( | |
| convert_to_openai_messages, | |
| ) | |
| def chatbot(message, history): | |
| llm = ChatOllama(model="gemma3:4b", temperature=0) | |
| response = llm.invoke(message) | |
| response = convert_to_openai_messages([response]) | |
| return response | |
| demo = gr.ChatInterface( | |
| fn=chatbot, | |
| type = "messages", | |
| title="Simple Chatbot", | |
| description="Ask anything you want", | |
| examples=["Hello", "What is your name?", "What is the weather in Tokyo?"], | |
| ) | |
| demo.launch() | |