kaosnet commited on
Commit
0f11385
·
verified ·
1 Parent(s): 52d73bb

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -1,21 +1,29 @@
1
  import os
2
  import gradio as gr
3
- from zeroclaw import ZeroClaw
4
 
5
  def query_zeroclaw(user_input):
6
- api_key = os.getenv("ZEROCLAW_API_KEY")
7
  if not api_key:
8
- return "Error: ZEROCLAW_API_KEY not set in Spaces secrets."
9
- client = ZeroClaw.remote(api_key=api_key)
10
- response = client.agent.run(user_input)
11
- return response.text
 
 
 
 
 
 
 
 
12
 
13
  demo = gr.Interface(
14
  fn=query_zeroclaw,
15
- inputs=gr.Textbox(label="Enter your query for ZeroClaw"),
16
- outputs=gr.Textbox(label="ZeroClaw Response"),
17
- title="ZeroClaw on Hugging Face Spaces",
18
- description="Run ZeroClaw agent queries via this web interface. Add your ZeroClaw API key to Spaces secrets as ZEROCLAW_API_KEY."
19
  )
20
 
21
  if __name__ == "__main__":
 
1
  import os
2
  import gradio as gr
3
+ import openai
4
 
5
  def query_zeroclaw(user_input):
6
+ api_key = os.getenv("OPENROUTER_API_KEY")
7
  if not api_key:
8
+ return "Error: OPENROUTER_API_KEY not set in Spaces secrets. Get one at https://openrouter.ai/keys"
9
+
10
+ client = openai.OpenAI(
11
+ base_url="https://openrouter.ai/api/v1",
12
+ api_key=api_key,
13
+ )
14
+
15
+ response = client.chat.completions.create(
16
+ model="anthropic/claude-3.5-sonnet:beta",
17
+ messages=[{"role": "user", "content": user_input}]
18
+ )
19
+ return response.choices[0].message.content
20
 
21
  demo = gr.Interface(
22
  fn=query_zeroclaw,
23
+ inputs=gr.Textbox(label="Enter your query", lines=3),
24
+ outputs=gr.Textbox(label="AI Response", lines=10),
25
+ title="ZeroClaw-style AI Agent on Hugging Face Spaces",
26
+ description="AI agent powered by OpenRouter. Get your free API key at https://openrouter.ai/keys and add it to Spaces secrets as OPENROUTER_API_KEY."
27
  )
28
 
29
  if __name__ == "__main__":