Spaces:
Build error
Build error
File size: 948 Bytes
63b0800 ab4aae3 63b0800 |
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 |
import streamlit as st
import os
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.prompts import ChatPromptTemplate
# Set your Google API key from environment variables
gemini_api_key = os.getenv("GOOGLE_API_KEY")
# Initialize the Gemini API-powered chatbot model
model_gemini = ChatGoogleGenerativeAI(
model='gemini-pro',
temperature=0,
max_output_tokens=500,
convert_system_message_to_human=True
)
# Create a chat prompt template
prompt = ChatPromptTemplate.from_template("{content}")
chain = prompt | model_gemini
# Streamlit app title
st.title("Non-Interactive Chat Bot")
# Text area for user input
input_text = st.text_area('Ask your Question :', height=100)
# Button to submit user query
if st.button('Submit'):
# Invoke the chain with user input text
response = chain.invoke({'content': input_text})
# Display the chatbot response
st.write(response.content)
|