Spaces:
Runtime error
Runtime error
| 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) | |