Shinhati2023 commited on
Commit
d6bbfef
·
verified ·
1 Parent(s): ebf7fa9

Create Streamlit.Py

Browse files
Files changed (1) hide show
  1. Streamlit.Py +23 -0
Streamlit.Py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import the required libraries
2
+ import streamlit as st
3
+ from transformers import pipeline
4
+
5
+ # Create a calculator function using the Llama model
6
+ def calculator(expression):
7
+ # Initialize the Llama model from Hugging Face
8
+ model = pipeline("text2text-generation", model="EleutherAI/llama")
9
+ # Generate the answer using the model
10
+ answer = model(expression)[0]["generated_text"]
11
+ # Return the answer
12
+ return answer
13
+
14
+ # Create a Streamlit app to display the calculator
15
+ st.title("Calculator using Llama model")
16
+ # Get the user input
17
+ expression = st.text_input("Enter an expression to calculate:")
18
+ # Check if the input is not empty
19
+ if expression:
20
+ # Call the calculator function and display the answer
21
+ answer = calculator(expression)
22
+ st.write(f"The answer is: {answer}")
23
+