import os from openai import OpenAI import google.generativeai as genai from anthropic import AI_PROMPT, HUMAN_PROMPT, Anthropic import streamlit as st from dotenv import load_dotenv load_dotenv() anthropic = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY")) genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) st.set_page_config(page_title="strftime AI", page_icon="🕘") with open("static/style.css") as f: st.markdown(f"", unsafe_allow_html=True) st.header("strftime AI") with st.sidebar: provider = st.radio( "Choose AI Provider", options=["Anthropic", "Google Gemini", "OpenAI"] ) text = st.text_input("Enter datetime text eg. 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 == "Anthropic": completion = anthropic.completions.create( model="claude-2", max_tokens_to_sample=300, prompt=f"{HUMAN_PROMPT} {prompt}{AI_PROMPT}", ) st.markdown(completion.completion) elif provider == "Google Gemini": model = genai.GenerativeModel("gemini-pro") response = model.generate_content(prompt) st.markdown(response.text) elif provider == "OpenAI": chat_completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}] ) st.markdown(chat_completion.choices[0].message.content)