Spaces:
Sleeping
Sleeping
File size: 1,310 Bytes
f0e8cfd 3ebab61 f0e8cfd 880159c 3ebab61 290179a 3b29101 2003369 f0e8cfd 880159c 9df41bd f0e8cfd 880159c 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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
from smolagents import HfApiModel
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()
model = HfApiModel(model_id="mistralai/Mixtral-8x7B-Instruct-v0.1", token=os.environ.get("HF_TOKEN"))
def chat(prompt, history):
data = [
{
"role":"system",
"content":[
{
"type":"text",
"text": "You are a doctor who specializes on helping patients with addiction issues"
}
]
},
{
"role":"user",
"content":[
{
"type":"text",
"text": prompt
}
]
}
]
return model(data).content
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()
|