File size: 1,639 Bytes
ace2f35 a25c1ff ace2f35 40a4dba 0f3f2f2 ace2f35 0f3f2f2 ace2f35 0f3f2f2 ace2f35 0f3f2f2 |
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 43 44 45 |
import streamlit as st
from langchain.prompts import PromptTemplate
from langchain.llms import CTransformers
import gradio as gr
## Function To get response from LLAma 2 model
def getLLamaresponse(input_text = "home decoration" ,no_words = 100,blog_style = "lifestyle"):
### LLama2 model
llm=CTransformers(model='TheBloke/OpenHermes-2.5-Mistral-7B-GGUF',
model_type='llama',
config={'max_new_tokens':256,
'temperature':0.01})
## Prompt Template
template="""
Write a blog for {blog_style} job profile for a topic {input_text}
within {no_words} words.
"""
prompt=PromptTemplate(input_variables=["blog_style","input_text",'no_words'],
template=template)
## Generate the ressponse from the LLama 2 model
response=llm(prompt.format(blog_style=blog_style,input_text=input_text,no_words=no_words))
print(response)
return response
with gr.Blocks() as demo:
gr.Markdown("# AI Patient Chatbot")
with gr.Group():
with gr.Tab("Patient Chatbot"):
chatbot = gr.Chatbot()
message = gr.Textbox(label="Enter your message to Barry", placeholder="Type here...", lines=2)
send_message = gr.Button("Submit")
send_message.click(AIPatient, inputs=[message], outputs=[chatbot])
save_chatlog = gr.Button("Save Chatlog")
#send_message.click(SaveChatlog, inputs=[message], outputs=[chatbot])
#message.submit(AIPatient, inputs=[message], outputs=[chatbot])
demo.launch(debug=True) |