Spaces:
Sleeping
Sleeping
File size: 848 Bytes
9548958 f0e8cfd 3ebab61 f0e8cfd 3ebab61 290179a 3b29101 2003369 f0e8cfd 9df41bd f0e8cfd 1b2a00c f0e8cfd 1b2a00c f0e8cfd 95c1831 f0e8cfd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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()
|