NikosKprl commited on
Commit
5ae1368
·
verified ·
1 Parent(s): 2d6d80e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -17
app.py CHANGED
@@ -36,27 +36,15 @@ model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote
36
 
37
  api_token = st.text_input("Enter your API key from [GitHub](https://github.com/marketplace/models/azure-openai/gpt-4o):", "", type="password")
38
 
39
- def validate_token(token, endpoint):
40
- try:
41
- headers = {"Authorization": f"Bearer {token}"}
42
- response = requests.get(f"{endpoint}/models", headers=headers)
43
- return response.status_code == 200
44
- except:
45
- st.error(f"Token validation error: {e}")
46
- return False
47
 
48
  if api_token:
49
  endpoint = "https://models.inference.ai.azure.com"
50
  model_name = "gpt-4o"
51
-
52
- if validate_token(api_token, endpoint):
53
- client = OpenAI(
54
- base_url=endpoint,
55
- api_key=api_token,
56
- )
57
- st.success("API Token is valid and set for this session.")
58
- else:
59
- st.error("Invalid API token. Please check and try again.")
60
  else:
61
  st.warning("Please enter an API token to proceed.")
62
 
 
36
 
37
  api_token = st.text_input("Enter your API key from [GitHub](https://github.com/marketplace/models/azure-openai/gpt-4o):", "", type="password")
38
 
 
 
 
 
 
 
 
 
39
 
40
  if api_token:
41
  endpoint = "https://models.inference.ai.azure.com"
42
  model_name = "gpt-4o"
43
+ client = OpenAI(
44
+ base_url=endpoint,
45
+ api_key=api_token,
46
+ )
47
+ st.success("API Token is set for this session.")
 
 
 
 
48
  else:
49
  st.warning("Please enter an API token to proceed.")
50