File size: 1,317 Bytes
7f91398
 
 
 
 
44a05a0
7f91398
 
 
 
 
 
 
6a4f556
7f91398
 
6a4f556
7f91398
 
 
 
 
 
 
b1f36e5
7f91398
 
 
 
5271f0d
7f91398
 
5271f0d
7f91398
 
5271f0d
7f91398
5271f0d
7f91398
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
35
36
37
38
39
40
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

# Load the data from the CSV file
@st.cache_data
def load_data():
    df = pd.read_csv("llm_data.csv")  # Update with your CSV file path
    return df

df = load_data()

# Calculate example cost
def calculate_example_cost(input_text, output_text, input_ratio=0.000001, output_ratio=0.000001):
    input_tokens = len(input_text) / 5
    output_tokens = len(output_text) / 5
    example_cost = (input_tokens * input_ratio) + (output_tokens * output_ratio)
    return example_cost

# Sidebar inputs
input_text = st.sidebar.text_area("Input text")
output_text = st.sidebar.text_area("Output text")

# Calculate example cost for each row
df['Example cost'] = df.apply(lambda row: calculate_example_cost(input_text, output_text, row['Input']/1000000, row['Output']/1000000), axis=1)

# Display sorted LLM costs
st.write("Sorted LLM Costs:")
sorted_df = df.sort_values(by='Example cost', ascending=False)
st.write(sorted_df[['Company', 'Model', 'Example cost']])

# Plot visualization
st.write("Visualization of LLM Costs ($USD):")
plt.figure(figsize=(10, 6))
plt.barh(sorted_df['Model'], sorted_df['Example cost'], color='skyblue')
plt.xlabel('Example Cost ($USD)')
plt.ylabel('LLM Model')
plt.title('LLM Usage Cost in US Dollars')
st.pyplot(plt)