freddyaboulton HF staff commited on
Commit
274649e
1 Parent(s): e0d6040

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -1,9 +1,7 @@
1
  import gradio as gr
2
- from gradio_webrtc import WebRTC, ReplyOnStopWords, AdditionalOutputs, audio_to_bytes, get_twilio_turn_credentials
3
  import numpy as np
4
- import os
5
  import base64
6
- import openai
7
  import re
8
  from groq import Groq
9
 
@@ -12,7 +10,7 @@ load_dotenv()
12
 
13
  spinner_html = open("spinner.html").read()
14
 
15
- rtc_configuration = get_twilio_turn_credentials()
16
 
17
  print("rtc_configuration", rtc_configuration)
18
 
@@ -33,14 +31,9 @@ logger = logging.getLogger("gradio_webrtc")
33
  logger.setLevel(logging.DEBUG)
34
  logger.addHandler(console_handler)
35
 
36
- client = openai.OpenAI(
37
- api_key=os.environ.get("SAMBANOVA_API_KEY"),
38
- base_url="https://api.sambanova.ai/v1",
39
- )
40
 
41
  groq_client = Groq()
42
 
43
-
44
  system_prompt = "You are an AI coding assistant. Your task is to write single-file HTML applications based on a user's request. Only return the necessary code. Include all necessary imports and styles. You may also be asked to edit your original response."
45
  user_prompt = "Please write a single-file HTML application to fulfill the following request.\nThe message:{user_message}\nCurrent code you have written:{code}"
46
 
@@ -75,12 +68,16 @@ def generate(user_message: tuple[int, np.ndarray],
75
  user_msg_formatted = user_prompt.format(user_message=text, code=code)
76
  history.append({"role": "user", "content": user_msg_formatted})
77
 
78
- response = client.chat.completions.create(
79
- model='Meta-Llama-3.1-70B-Instruct',
 
80
  messages=history,
81
- temperature = 0.1,
82
- top_p = 0.1
 
 
83
  )
 
84
 
85
  output = response.choices[0].message.content
86
  html_code = extract_html_content(output)
 
1
  import gradio as gr
2
+ from gradio_webrtc import WebRTC, ReplyOnStopWords, AdditionalOutputs, audio_to_bytes
3
  import numpy as np
 
4
  import base64
 
5
  import re
6
  from groq import Groq
7
 
 
10
 
11
  spinner_html = open("spinner.html").read()
12
 
13
+ rtc_configuration = None
14
 
15
  print("rtc_configuration", rtc_configuration)
16
 
 
31
  logger.setLevel(logging.DEBUG)
32
  logger.addHandler(console_handler)
33
 
 
 
 
 
34
 
35
  groq_client = Groq()
36
 
 
37
  system_prompt = "You are an AI coding assistant. Your task is to write single-file HTML applications based on a user's request. Only return the necessary code. Include all necessary imports and styles. You may also be asked to edit your original response."
38
  user_prompt = "Please write a single-file HTML application to fulfill the following request.\nThe message:{user_message}\nCurrent code you have written:{code}"
39
 
 
68
  user_msg_formatted = user_prompt.format(user_message=text, code=code)
69
  history.append({"role": "user", "content": user_msg_formatted})
70
 
71
+ print("generating response")
72
+ response = groq_client.chat.completions.create(
73
+ model="llama-3.3-70b-versatile",
74
  messages=history,
75
+ temperature=1,
76
+ max_tokens=1024,
77
+ top_p=1,
78
+ stream=False,
79
  )
80
+ print("finished generating response")
81
 
82
  output = response.choices[0].message.content
83
  html_code = extract_html_content(output)