Spaces:
Sleeping
Sleeping
File size: 2,224 Bytes
706f617 0214b2e 02dbdf8 0214b2e 02dbdf8 0214b2e 706f617 0214b2e 706f617 02dbdf8 0214b2e 706f617 f99419a 706f617 02dbdf8 706f617 0214b2e 706f617 0214b2e 706f617 0214b2e 02dbdf8 0214b2e 02dbdf8 0214b2e 706f617 4845e1d 0214b2e |
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 67 68 |
import os
from groq import Groq
from openai import OpenAI
from anthropic import Anthropic
import google.generativeai as genai
from dotenv import load_dotenv
import streamlit as st
load_dotenv()
st.set_page_config(page_title="strftime AI", page_icon="🕘")
with open("static/style.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
st.header("strftime AI")
with st.sidebar:
provider = st.radio(
"Choose AI Provider",
options=[
"Groq",
"Anthropic",
"OpenAI",
"Google Gemini",
]
)
text = st.text_input("Enter datetime text eg. 2023-09-28T15:27:58Z", value="2023-09-28T15:27:58Z")
if text:
prompt = (
"Convert the following datetime string into strftime format, "
"show the strftime string on top and then breakdown of % symbols: " + text
)
if provider == "Groq":
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="mixtral-8x7b-32768",
max_tokens=1024,
)
st.markdown(chat_completion.choices[0].message.content)
elif provider == "OpenAI":
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="gpt-3.5-turbo",
max_tokens=1024,
)
st.markdown(chat_completion.choices[0].message.content)
elif provider == "Anthropic":
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
message = client.messages.create(
messages=[{"role": "user", "content": prompt}],
model="claude-3-haiku-20240307",
max_tokens=1024,
)
st.markdown(message.content[0].text)
elif provider == "Google Gemini":
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel("gemini-pro")
response = model.generate_content(prompt)
st.markdown(response.text)
|