Spaces:
Sleeping
Sleeping
File size: 948 Bytes
63ec81e |
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 |
from groq import Groq
import gradio as gr
#initiale the API key
api_key = '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'
client = Groq(api_key=api_key)
def generate_ideas():
try:
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Generate for me 5 ideas for exciting web projects",
}
],
model="llama3-8b-8192",
)
ideas = chat_completion.choices[0].message.content.strip()
return ideas
except Exception as e:
return f"An error occurred: {str(e)}"
#the front end of the page
interface = gr.Interface(
fn=generate_ideas,
inputs=[],
outputs="text",
title="AI Homework, using Gradio and Groq",
description="Click the button to generate your request."
)
interface.launch() #run the page
|