vortex123 commited on
Commit
9481506
·
verified ·
1 Parent(s): 60e3903

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -10
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import openai
3
  import time
4
  import re
5
  import os
@@ -12,14 +11,6 @@ MODELS = [
12
  # Sambanova API base URL
13
  API_BASE = "https://api.sambanova.ai/v1"
14
 
15
- def create_client(api_key=None):
16
- """Creates an OpenAI client instance."""
17
- if api_key:
18
- openai.api_key = api_key
19
- else:
20
- openai.api_key = os.getenv("API_KEY")
21
-
22
- return openai.OpenAI(api_key=openai.api_key, base_url=API_BASE)
23
 
24
  def chat_with_ai(message, chat_history, system_prompt):
25
  """Formats the chat history for the API call."""
@@ -34,7 +25,7 @@ def chat_with_ai(message, chat_history, system_prompt):
34
 
35
  def respond(message, chat_history, model, system_prompt, thinking_budget, api_key):
36
  """Sends the message to the API and gets the response."""
37
- client = create_client(api_key)
38
  messages = chat_with_ai(message, chat_history, system_prompt.format(budget=thinking_budget))
39
  start_time = time.time()
40
 
 
1
  import gradio as gr
 
2
  import time
3
  import re
4
  import os
 
11
  # Sambanova API base URL
12
  API_BASE = "https://api.sambanova.ai/v1"
13
 
 
 
 
 
 
 
 
 
14
 
15
  def chat_with_ai(message, chat_history, system_prompt):
16
  """Formats the chat history for the API call."""
 
25
 
26
  def respond(message, chat_history, model, system_prompt, thinking_budget, api_key):
27
  """Sends the message to the API and gets the response."""
28
+
29
  messages = chat_with_ai(message, chat_history, system_prompt.format(budget=thinking_budget))
30
  start_time = time.time()
31