NikosKprl commited on
Commit
2170662
·
verified ·
1 Parent(s): 9225db2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -33,14 +33,21 @@ else:
33
 
34
  model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
35
 
36
- token = os.environ["GITHUB_TOKEN"]
37
- endpoint = "https://models.inference.ai.azure.com"
38
- model_name = "gpt-4o"
39
 
40
- client = OpenAI(
41
- base_url=endpoint,
42
- api_key=token,
43
- )
 
 
 
 
 
 
 
 
 
 
44
 
45
 
46
  async def fetch_url(session, url):
@@ -157,7 +164,6 @@ async def mains(name, single, combi):
157
  except:
158
  pass
159
 
160
- # Save QIDs to file
161
  with open(f"/home/user/app/qids_folder/{name}.json", "w") as f:
162
  json.dump(list(qids), f)
163
 
@@ -202,7 +208,7 @@ async def retriever(qid):
202
  if results["results"]["bindings"]:
203
  for result in results["results"]["bindings"]:
204
  for key, value in result.items():
205
- label = value.get("value", {}).lower() # Get label and convert to lower case
206
 
207
  query_alias = f"""SELECT ?alias
208
  WHERE {{
@@ -264,7 +270,6 @@ async def retriever(qid):
264
 
265
  return list_with_sent
266
 
267
- # Main async function to handle multiple QIDs with batching
268
  async def main(name):
269
  with open(f"/home/user/app/qids_folder/{name}.json", "r") as f:
270
  final_list = []
 
33
 
34
  model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
35
 
 
 
 
36
 
37
+ api_token = st.text_input("Enter your personal access token from [GitHub](https://github.com/marketplace/models/azure-openai/gpt-4o):", "")
38
+
39
+ if api_token:
40
+ token = os.environ["GITHUB_TOKEN"] = api_token # security reasons
41
+ endpoint = "https://models.inference.ai.azure.com"
42
+ model_name = "gpt-4o"
43
+
44
+ client = OpenAI(
45
+ base_url=endpoint,
46
+ api_key=token,
47
+ )
48
+ st.success("API Token set for this session.")
49
+ else:
50
+ st.warning("Please enter an API token to proceed.")
51
 
52
 
53
  async def fetch_url(session, url):
 
164
  except:
165
  pass
166
 
 
167
  with open(f"/home/user/app/qids_folder/{name}.json", "w") as f:
168
  json.dump(list(qids), f)
169
 
 
208
  if results["results"]["bindings"]:
209
  for result in results["results"]["bindings"]:
210
  for key, value in result.items():
211
+ label = value.get("value", {}).lower()
212
 
213
  query_alias = f"""SELECT ?alias
214
  WHERE {{
 
270
 
271
  return list_with_sent
272
 
 
273
  async def main(name):
274
  with open(f"/home/user/app/qids_folder/{name}.json", "r") as f:
275
  final_list = []