Googolplexic commited on
Commit
00ccbad
·
1 Parent(s): db4bc9c

Remove auth token parameter from APIClient and update Gradio interface to reflect changes in API call structure

Browse files
Files changed (2) hide show
  1. apiCall.py +2 -8
  2. main.py +5 -7
apiCall.py CHANGED
@@ -3,16 +3,14 @@ import json
3
 
4
 
5
  class APIClient:
6
- def __init__(self, base_url, auth_token=None):
7
  """
8
- Initialize the API client with a base URL and optional auth token.
9
 
10
  Parameters:
11
  - base_url: The base URL of the API
12
- - auth_token: Optional authentication token
13
  """
14
  self.base_url = base_url.rstrip("/")
15
- self.auth_token = auth_token
16
 
17
  def make_request(self, endpoint="", params=None, headers=None, method="GET"):
18
  """
@@ -33,10 +31,6 @@ class APIClient:
33
  if headers is None:
34
  headers = {}
35
 
36
- # Add authorization if token is provided
37
- if self.auth_token:
38
- headers["Authorization"] = f"Bearer {self.auth_token}"
39
-
40
  try:
41
  if method.upper() == "GET":
42
  response = requests.get(url, params=params, headers=headers)
 
3
 
4
 
5
  class APIClient:
6
+ def __init__(self, base_url):
7
  """
8
+ Initialize the API client with a base URL
9
 
10
  Parameters:
11
  - base_url: The base URL of the API
 
12
  """
13
  self.base_url = base_url.rstrip("/")
 
14
 
15
  def make_request(self, endpoint="", params=None, headers=None, method="GET"):
16
  """
 
31
  if headers is None:
32
  headers = {}
33
 
 
 
 
 
34
  try:
35
  if method.upper() == "GET":
36
  response = requests.get(url, params=params, headers=headers)
main.py CHANGED
@@ -99,7 +99,6 @@ demo = gr.Interface(
99
  placeholder="Enter base URL",
100
  value="https://v2.xivapi.com/api",
101
  ),
102
- gr.Textbox(label="Auth Token", placeholder="Enter auth token (optional)"),
103
  gr.Textbox(label="Endpoint", placeholder="Enter endpoint", value="search"),
104
  gr.Textbox(
105
  label="Parameter Key-Value Pairs",
@@ -125,7 +124,6 @@ demo = gr.Interface(
125
  title="Universal API Client",
126
  description="Make API calls to any endpoint with custom parameters. \n\n"
127
  + "- **Base URL**: Enter the full API base URL (e.g., 'https://api.example.com') \n"
128
- + "- **Auth Token**: Provide if the API requires authentication \n"
129
  + "- **Endpoint**: The specific endpoint to call (without leading slash) \n"
130
  + "- **Parameter Key-Value Pairs**: Format as 'key: value' with each pair on a new line \n"
131
  + " Example: \n```\nquery: search term\nlimit: 10\nfilter: active\n``` \n"
@@ -153,12 +151,12 @@ demo = gr.Interface(
153
  "GET",
154
  ],
155
  [
156
- "https://api.anthropic.com/v1/messages",
157
  "",
158
- "",
159
- "",
160
- "x-api-key: YOUR_API_KEY\nanthropic-version: 2023-06-01\ncontent-type: application/json",
161
- '{"model":"claude-opus-4-20250514","max_tokens":1024,"messages":[{"role":"user","content":"Hello, world"}]}',
162
  "POST",
163
  ],
164
  ],
 
99
  placeholder="Enter base URL",
100
  value="https://v2.xivapi.com/api",
101
  ),
 
102
  gr.Textbox(label="Endpoint", placeholder="Enter endpoint", value="search"),
103
  gr.Textbox(
104
  label="Parameter Key-Value Pairs",
 
124
  title="Universal API Client",
125
  description="Make API calls to any endpoint with custom parameters. \n\n"
126
  + "- **Base URL**: Enter the full API base URL (e.g., 'https://api.example.com') \n"
 
127
  + "- **Endpoint**: The specific endpoint to call (without leading slash) \n"
128
  + "- **Parameter Key-Value Pairs**: Format as 'key: value' with each pair on a new line \n"
129
  + " Example: \n```\nquery: search term\nlimit: 10\nfilter: active\n``` \n"
 
151
  "GET",
152
  ],
153
  [
154
+ "https://api.anthropic.com",
155
  "",
156
+ "v1/messages",
157
+ "model: claude-opus-4-20250514\nmax_tokens: 1024",
158
+ "x-api-key: API-KEY-HERE\nanthropic-version: 2023-06-01\ncontent-type: application/json",
159
+ '{"messages": [{"role": "user", "content": "Hello there!"}]}',
160
  "POST",
161
  ],
162
  ],