File size: 855 Bytes
762be87
5afaecc
0b6f8c4
444f78b
762be87
 
 
0b6f8c4
 
 
762be87
0b6f8c4
 
444f78b
 
762be87
0b6f8c4
b4ef92f
0b6f8c4
389f6b6
0b6f8c4
 
 
 
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
import os
import streamlit as st
from clarifai.client.model import Model

# Read API key from environment variable
api_key = os.getenv("CLARIFAI_PAT")

# Function to get prediction from the model
def get_model_prediction(prompt):
    model_url = "https://clarifai.com/mistralai/completion/models/codestral-22b-instruct"
    model = Model(url=model_url, pat=api_key)
    model_prediction = model.predict_by_bytes(prompt.encode(), input_type="text")
    return model_prediction.outputs[0].data.text.raw

# Streamlit interface
st.title("AI Model Prediction with Clarifai")
st.write("Enter a prompt and get a prediction from the Clarifai model.")

prompt = st.text_input("Enter your prompt:", "What's the future of AI?")

if st.button("Get Prediction"):
    prediction = get_model_prediction(prompt)
    st.write("Model Prediction:")
    st.write(prediction)