yazanateer commited on
Commit
63ec81e
1 Parent(s): e14cbfd

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from groq import Groq
2
+ import gradio as gr
3
+
4
+
5
+ #initiale the API key
6
+ api_key = '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'
7
+ client = Groq(api_key=api_key)
8
+
9
+ def generate_ideas():
10
+ try:
11
+ chat_completion = client.chat.completions.create(
12
+ messages=[
13
+ {
14
+ "role": "user",
15
+ "content": "Generate for me 5 ideas for exciting web projects",
16
+ }
17
+ ],
18
+ model="llama3-8b-8192",
19
+ )
20
+ ideas = chat_completion.choices[0].message.content.strip()
21
+ return ideas
22
+ except Exception as e:
23
+ return f"An error occurred: {str(e)}"
24
+
25
+ #the front end of the page
26
+ interface = gr.Interface(
27
+ fn=generate_ideas,
28
+ inputs=[],
29
+ outputs="text",
30
+ title="AI Homework, using Gradio and Groq",
31
+ description="Click the button to generate your request."
32
+ )
33
+
34
+ interface.launch() #run the page
requirements.txt ADDED
Binary file (2.78 kB). View file