import os import streamlit as st from groq import Groq # Set your Groq API key here or load it from an environment variable api_key = os.getenv("GROQ_API_KEY") # Or hardcode it securely # Streamlit app setup st.title("Groq API Content Writer Specialist") st.write("Generate humanized, engaging content based on your input.") if api_key: # Initialize the Groq client with the pre-configured API key client = Groq(api_key=api_key) # User input for content requirements user_input = st.text_input("Enter your topic or content requirements:") if st.button("Generate Content"): # Ensure user input is not empty if user_input: try: # Set the role of the model as a "Humanized Content Writer" system_message = { "role": "system", "content": "You are a skilled content writer specializing in creating humanized, engaging, and relatable content. Write with a conversational tone that connects with the reader, while still being professional and informative." } user_message = { "role": "user", "content": user_input } # Create the chat completion with a system role of a humanized content writer chat_completion = client.chat.completions.create( messages=[ system_message, user_message ], model="llama3-8b-8192", # Use your specific model here ) # Display the response response = chat_completion.choices[0].message.content st.write("### Generated Humanized Content") st.write(response) except Exception as e: st.error(f"An error occurred: {e}") else: st.warning("Please enter your content requirements before clicking 'Generate Content'") else: st.error("API key not found. Please set the API key in your environment.")