-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
66 lines (52 loc) · 2.28 KB
/
app.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import streamlit as st
import utils
import time
st.set_page_config(page_title="LangChain: Model Comparison", layout="wide")
st.title("LangChain: Model Comparison")
st.divider()
col_prompt, col_settings = st.columns([2,3])
with col_prompt:
prompt = st.text_input(label="Ask me a question...")
st.divider()
submit_btn = st.button("Submit")
with col_settings:
temperature = st.slider(label="Temperature", min_value=0.0, max_value=1.0, value=0.7)
max_tokens = st.slider(label="Maximum Tokens", min_value=100, max_value=500, value=200, step=100)
st.divider()
col_gpt, col_gemini, col_claude, col_command = st.columns(4)
with col_gpt:
if submit_btn:
with st.spinner("GPT Thinking..."):
st.success("GPT-4 Turbo")
start_time = time.perf_counter()
st.write(utils.ask_gpt(prompt=prompt, temperature=temperature, max_tokens=max_tokens))
end_time = time.perf_counter()
elapsed_time = end_time - start_time
st.caption(f"| :hourglass: {round(elapsed_time)} seconds")
with col_gemini:
if submit_btn:
with st.spinner("Gemini Thinking..."):
st.info("Gemini Pro")
start_time = time.perf_counter()
st.write(utils.ask_gemini(prompt=prompt, temperature=temperature))
end_time = time.perf_counter()
elapsed_time = end_time - start_time
st.caption(f"| :hourglass: {round(elapsed_time)} seconds")
with col_claude:
if submit_btn:
with st.spinner("Claude Thinking..."):
st.error("Claude 2.1")
start_time = time.perf_counter()
st.write(utils.ask_claude(prompt=prompt, temperature=temperature, max_tokens=max_tokens))
end_time = time.perf_counter()
elapsed_time = end_time - start_time
st.caption(f"| :hourglass: {round(elapsed_time)} seconds")
with col_command:
if submit_btn:
with st.spinner("Command Thinking..."):
st.warning("Command")
start_time = time.perf_counter()
st.write(utils.ask_command(prompt=prompt, temperature=temperature, max_tokens=max_tokens))
end_time = time.perf_counter()
elapsed_time = end_time - start_time
st.caption(f"| :hourglass: {round(elapsed_time)} seconds")