Spaces:
Sleeping
Sleeping
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM | |
from langchain_nvidia_ai_endpoints import ChatNVIDIA | |
from langchain_core.output_parsers import StrOutputParser | |
from langchain_core.prompts import ChatPromptTemplate | |
import gradio as gr | |
import os | |
prompt = ChatPromptTemplate.from_messages([("system", "You are a helpful AI assistant named Arun."), ("user", "{input}")]) | |
llm = ChatNVIDIA(model="mistralai/mixtral-8x7b-instruct-v0.1") | |
chain = prompt | llm | StrOutputParser() | |
def chat(prompt, history): | |
output = "" | |
for chunk in chain.stream({"input": prompt}): | |
output += chunk | |
yield output | |
demo = gr.ChatInterface(chat, title="ArunGPT",theme = gr.themes.Soft(), description="Hello this is chatbot is created for only educational purpose and is powered by mistral 8x 7b model").queue() | |
demo.launch() | |