Simple only current message conversational chatbot
Browse files
app.py
CHANGED
|
@@ -1 +1,26 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from langchain_ollama import ChatOllama
|
| 3 |
+
from langchain_core.messages import (
|
| 4 |
+
convert_to_openai_messages,
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
def chatbot(message, history):
|
| 8 |
+
llm = ChatOllama(model="gemma3:4b", temperature=0)
|
| 9 |
+
response = llm.invoke(message)
|
| 10 |
+
response = convert_to_openai_messages([response])
|
| 11 |
+
return response
|
| 12 |
+
|
| 13 |
+
demo = gr.ChatInterface(
|
| 14 |
+
fn=chatbot,
|
| 15 |
+
type = "messages",
|
| 16 |
+
title="Simple Chatbot",
|
| 17 |
+
description="Ask anything you want",
|
| 18 |
+
examples=["Hello", "What is your name?", "What is the weather in Tokyo?"],
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
demo.launch()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|