kz919 commited on
Commit
93f83bf
1 Parent(s): 5499441

remove mandatory check for API keys

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -12,12 +12,11 @@ MODELS = [
12
  ]
13
 
14
  def create_client(api_key=None):
 
15
  if api_key:
16
  openai.api_key = api_key
17
- openai.api_base = "https://api.sambanova.ai/v1" # Fixed Base URL
18
  else:
19
  openai.api_key = os.getenv("API_KEY")
20
- openai.api_base = os.getenv("URL")
21
 
22
  def chat_with_ai(message, chat_history, system_prompt):
23
  messages = [
@@ -69,9 +68,9 @@ def parse_response(response):
69
 
70
  def process_chat(message, history, model, system_prompt, thinking_budget, api_key):
71
  print(f"Received message: {message}")
72
- if not api_key:
73
- print("API key missing")
74
- return history + [("System", "Please provide your API Key before starting the chat.")]
75
 
76
  try:
77
  formatted_system_prompt = system_prompt.format(budget=thinking_budget)
@@ -138,13 +137,13 @@ Example format:
138
 
139
  with gr.Blocks() as demo:
140
  gr.Markdown("# Llama3.1-Instruct-O1")
141
- gr.Markdown("[Powered by Llama3.1 models through SN Cloud](https://sambanova.ai/fast-api?api_ref=907266)")
142
 
143
  with gr.Row():
144
  api_key = gr.Textbox(
145
  label="API Key",
146
  type="password",
147
- placeholder="Enter your API key here"
148
  )
149
 
150
  with gr.Row():
 
12
  ]
13
 
14
  def create_client(api_key=None):
15
+ openai.api_base = "https://api.sambanova.ai/v1" # Fixed Base URL
16
  if api_key:
17
  openai.api_key = api_key
 
18
  else:
19
  openai.api_key = os.getenv("API_KEY")
 
20
 
21
  def chat_with_ai(message, chat_history, system_prompt):
22
  messages = [
 
68
 
69
  def process_chat(message, history, model, system_prompt, thinking_budget, api_key):
70
  print(f"Received message: {message}")
71
+ #if not api_key:
72
+ # print("API key missing")
73
+ # return history + [("System", "Please provide your API Key before starting the chat.")]
74
 
75
  try:
76
  formatted_system_prompt = system_prompt.format(budget=thinking_budget)
 
137
 
138
  with gr.Blocks() as demo:
139
  gr.Markdown("# Llama3.1-Instruct-O1")
140
+ gr.Markdown("[Powered by Llama3.1 models through SambaNova Cloud API](https://sambanova.ai/fast-api?api_ref=907266)")
141
 
142
  with gr.Row():
143
  api_key = gr.Textbox(
144
  label="API Key",
145
  type="password",
146
+ placeholder="(Optional) Enter your API key here for more availability"
147
  )
148
 
149
  with gr.Row():