- Notifications
You must be signed in to change notification settings - Fork0
An interactive platform to explore and experiment with various AI models powered by Groq. 🤖 Customize parameters, chat with AI, and export your conversations in multiple formats. 📄✨
SauravSrivastav/groq-ai-playground
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Groq AI Playground is an interactive platform to explore and experiment with various AI models powered by Groq. Customize parameters, chat with AI, and export your conversations in multiple formats.
- Fast and Efficient: Powered by Groq's LPU for low latency and high performance.
- Customizable: Modify system prompts and choose from various models.
- Interactive UI: Built with Streamlit for an intuitive user interface.
- Export Options: Export chat history in JSON, TXT, or PDF formats.
Clone the repository:
git clone https://github.com/SauravSrivastav/groq-ai-playground.gitcd groq-ai-playground
Create a virtual environment:
python -m venv venvsource venv/bin/activate# On Windows use `venv\Scripts\activate`
Install the dependencies:
pip install -r requirements.txt
Set up your Groq API Key:
- Sign up on theGroq website and generate an API key.
- Set the API key as an environment variable:
export GROQ_API_KEY=your_groq_api_key
Start the Streamlit app:
streamlit run app.py
Open your browser and navigate to
http://localhost:8501
to interact with the AI models.
- Enter your Groq API Key in the sidebar.
- Choose a model from the dropdown menu.
- Adjust parameters such as max tokens and temperature.
- Ask a question in the text input box and get responses from the AI.
importosimportstreamlitasstfromtypingimportGeneratorfromgroqimportGroqimportjsonfromdatetimeimportdatetimefromfpdfimportFPDFimportbase64importtorchfromtransformersimportpipelinefromdatasetsimportload_datasetfromtorch.nn.attentionimportSDPBackend,sdpa_kernel
- Import necessary libraries and modules.
- Set up the main function for the Streamlit application.
withst.sidebar:st.markdown("### Configuration")api_key=st.text_input("Enter your Groq API Key:",type="password",placeholder="Your API Key")ifapi_key:st.session_state.api_key=api_keyst.markdown("[Get your Groq API key here](https://console.groq.com/keys)")model_option=st.selectbox("Choose a model:",options=list(models.keys()),format_func=lambdax:models[x]["name"],index=0)st.markdown(f"**Name:**{models[model_option]['name']} **Max Tokens:**{models[model_option]['tokens']} **Developer:**{models[model_option]['developer']}")max_tokens=st.slider("Max Tokens:",min_value=512,max_value=models[model_option]["tokens"],value=4096,step=512)temperature=st.slider("Temperature:",min_value=0.0,max_value=1.0,value=0.7,step=0.1)ifst.button("Clear Chat"):st.session_state.messages= []export_format=st.selectbox("Choose export format:",options=["JSON","TXT","PDF"],index=0)ifst.button("Export Chat"):# Export logic here
- Provide instructions for obtaining the Groq API key.
- Input field for the user to enter their API key.
- Model selection and parameter adjustment.
ifinteraction_type=="Text Chat":ifprompt:=st.chat_input("Enter your prompt here..."):ifnotst.session_state.api_key:st.error("Please enter your Groq API Key in the sidebar.")else:st.session_state.messages.append({"role":"user","content":prompt})withst.chat_message("user",avatar="🧑💻"):st.markdown(prompt)client=create_groq_client()ifclient:try:chat_completion=client.chat.completions.create(model=model_option,messages=[{"role":m["role"],"content":m["content"]}forminst.session_state.messages],max_tokens=max_tokens,temperature=temperature,stream=True, )response_chunks= []withst.chat_message("assistant",avatar="🤖"):message_placeholder=st.empty()forchunkingenerate_chat_responses(chat_completion):response_chunks.append(chunk)message_placeholder.markdown(''.join(response_chunks)+"▌")full_response=''.join(response_chunks)message_placeholder.markdown(full_response)st.session_state.messages.append({"role":"assistant","content":full_response})exceptExceptionase:st.error(f"An error occurred:{str(e)}",icon="❌")
- Initialize session state for chat history.
- Handle user input and display chatbot responses.
Contributions are welcome! If you'd like to improve Groq AI Playground, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See theLICENSE file for details.
Have questions or suggestions? Reach out to us:
- 📧 Email:Sauravsrivastav2205@gmail.com
- 💼 LinkedIn:in/sauravsrivastav2205
- 🐙 GitHub:https://github.com/SauravSrivastav
Happy Chatting! 🎉
About
An interactive platform to explore and experiment with various AI models powered by Groq. 🤖 Customize parameters, chat with AI, and export your conversations in multiple formats. 📄✨
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.