Spaces:
Runtime error
Runtime error
File size: 1,425 Bytes
13dd34b |
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 46 47 |
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="./gen-lang-client-0086983119-574504dba064.json"
from langchain.llms import GooglePalm
from langchain import PromptTemplate
from langchain import LLMChain
from dotenv import load_dotenv
load_dotenv()
import streamlit as st
## Function to load OpenAI model and get respones
def get_openai_response(question):
llm = GooglePalm(google_api_key=os.environ["GOOGLE_API_KEY"], temperature=0.1)
template ="""Your a Mashette Bot, act like a chatbot, user will ask you question give then Good Answers without Toxic answers. also if they greet you, greet them well.
context:{question}
answer:
"""
prompt = PromptTemplate(template = template, input_variables= ["question"])
story_llm = LLMChain(llm = llm, prompt = prompt, verbose = True)
response = story_llm.predict(question = question)
# print("Generated_text:",response)
return response
# def get_openai_response(question):
# llm = GooglePalm(google_api_key=os.environ["GOOGLE_API_KEY"], temperature=0.1)
# response=llm(question)
# return response
##initialize our streamlit app
st.set_page_config(page_title="Q&A Demo")
st.header("Mashette-Bot")
input=st.text_input("Input: ",key="input")
submit=st.button("Submit the question")
response=get_openai_response(input)
## If ask button is clicked
if submit:
st.subheader("The Response is")
st.write(response)
|