enotkrutoy commited on
Commit
928cca7
·
verified ·
1 Parent(s): 8d6a62a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,12 +1,28 @@
1
  import gradio as gr
2
  import groq_gradio
3
  import os
 
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- os.environ["GROQ_API_KEY"] = "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"
7
 
8
  gr.load(
9
- name = "llama-3.2-3b-preview",
10
  src = groq_gradio.registry,
11
  title = "Groq-Gradio Chat",
12
  theme = "upsatwal/mlsc_tiet",
 
1
  import gradio as gr
2
  import groq_gradio
3
  import os
4
+ import openai
5
 
6
+ # Set up the client to interact with Groq API through OpenAI's endpoint
7
+ client = openai.OpenAI(
8
+ base_url="https://api.groq.com/openai/v1", # URL for Groq's API endpoint
9
+ api_key=os.environ.get("GROQ_API_KEY") # Retrieve the API key from environment variables
10
+ )
11
+
12
+ # Example usage of the client (sending a request to Groq API)
13
+ response = client.completions.create(
14
+ model="gpt-4", # You can replace with the desired model
15
+ prompt="Provide a summary of the Groq API documentation",
16
+ max_tokens=100
17
+ )
18
+
19
+
20
+
21
+ print(response.choices[0].text.strip()) # Output the response from Groq API
22
 
 
23
 
24
  gr.load(
25
+ name = "Ai;)",
26
  src = groq_gradio.registry,
27
  title = "Groq-Gradio Chat",
28
  theme = "upsatwal/mlsc_tiet",