Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_groq import ChatGroq
|
| 3 |
+
from langchain.chains import LLMChain
|
| 4 |
+
from langchain.prompts import PromptTemplate
|
| 5 |
+
|
| 6 |
+
# Streamlit Application Title
|
| 7 |
+
st.title('AI Scientist')
|
| 8 |
+
st.subheader('Here you will find solutions for your problem')
|
| 9 |
+
|
| 10 |
+
# Input Fields
|
| 11 |
+
A = st.text_input('Enter Academic year')
|
| 12 |
+
B = st.text_input('Enter Streams of education')
|
| 13 |
+
|
| 14 |
+
details = f"""
|
| 15 |
+
Academic year: {A}
|
| 16 |
+
Stream: {B}
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
# Question Input and Submit Button
|
| 20 |
+
A1 = st.text_input('Enter your question')
|
| 21 |
+
SUB = st.button('SUBMIT')
|
| 22 |
+
|
| 23 |
+
# Define the Prompt Template for Questions
|
| 24 |
+
B2 = PromptTemplate(
|
| 25 |
+
input_variables=["details", "k"],
|
| 26 |
+
template="Tell me about {k} based on the following details: {details} in 20 words."
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# Initialize the ChatGroq Model
|
| 30 |
+
model = ChatGroq(
|
| 31 |
+
temperature=0.6,
|
| 32 |
+
groq_api_key='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' # Replace with your actual API key
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Process the Question on Button Click
|
| 36 |
+
if SUB and A1: # Ensure question input is provided
|
| 37 |
+
X = B2.format(k=A1, details=details)
|
| 38 |
+
response = model.predict(X) # Use predict method to interact with the model
|
| 39 |
+
st.write(response)
|