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