import gradio as gr from groq import Groq import os system_prompt = """ You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information. Your response should be complete, and not end abruptly. """ client = Groq( api_key=os.environ.get("groq_api_key"), ) def chat_with_llama(prompt): chat_completion = client.chat.completions.create( messages=[{"role": "system", "content": system_prompt},{"role": "user", "content": prompt}], model="llama-3.1-8b-instant", ) return chat_completion.choices[0].message.content def clear_fields(): return "", "" # Clear prompt and output, but not the API key #demo = gr.Interface(fn=chat_with_Mixtral, inputs=[gr.Textbox(label="Question"),gr.Textbox(label="Hugging Face API Key", type="password")],outputs="text") with gr.Blocks(theme='freddyaboulton/test-blue') as demo: gr.Markdown("