Nexchan commited on
Commit
6390ee2
1 Parent(s): 7df9884

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -8
main.py CHANGED
@@ -6,7 +6,9 @@ from typing import List
6
  from fastapi import FastAPI, HTTPException, Request
7
 
8
  app = FastAPI()
9
-
 
 
10
 
11
  # Character----------------------------------------------------------------------------
12
  character_info = """
@@ -132,7 +134,7 @@ async def run_provider_duplicate(provider: g4f.Provider.OpenaiChat, messages):
132
  model="gpt-3.5-turbo",
133
  messages=messages,
134
  provider=provider,
135
- access_token="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaEVOVUpHTkVNMVFURTRNMEZCTWpkQ05UZzVNRFUxUlRVd1FVSkRNRU13UmtGRVFrRXpSZyJ9.eyJodHRwczovL2FwaS5vcGVuYWkuY29tL3Byb2ZpbGUiOnsiZW1haWwiOiJhbm90aGVyLjAxMDAxQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlfSwiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS9hdXRoIjp7InBvaWQiOiJvcmctR1BiYlpReUxrN1h4SHJpU0podEFpMkE3IiwidXNlcl9pZCI6InVzZXItdFZZcVg2UEpPRVBITVhERWxSVmFxbUVpIn0sImlzcyI6Imh0dHBzOi8vYXV0aDAub3BlbmFpLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDEwNDA4OTQ0NTIzMDg1ODI4NDk3NyIsImF1ZCI6WyJodHRwczovL2FwaS5vcGVuYWkuY29tL3YxIiwiaHR0cHM6Ly9vcGVuYWkub3BlbmFpLmF1dGgwYXBwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE3MDgxMjEwNzEsImV4cCI6MTcwODk4NTA3MSwiYXpwIjoiVGRKSWNiZTE2V29USHROOTVueXl3aDVFNHlPbzZJdEciLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIG1vZGVsLnJlYWQgbW9kZWwucmVxdWVzdCBvcmdhbml6YXRpb24ucmVhZCBvcmdhbml6YXRpb24ud3JpdGUgb2ZmbGluZV9hY2Nlc3MifQ.blRxc815g8lH91EFiG-YRvjLpaED-jeBpOoqO20FuQWZqsyQey88Lvg5V4oMCGrrZKGEA-NSemVf7h_TG_EaNMSDbThBXMz8hgIKxiey9qMDjiRW0InOm_-rD7u6MDKK-F_SIFt5_zH7y-122mlzEcTIATYSMQtVVEhy8DPLD3JhPZ3go9V_LizsIP40vGvwpf3fbPpidPZX8ceCg381vTwc6fAKX5gaDNgy5FlTBWfnRUKtayxrPITkRVnkvlqOqt7srFjLhrxeML5KvMur_8xFP_GPPGe5C97asRZenaT5Z1MwPx0VqADgL5tGoYuBB8ZsbE4fmEEQVQ9NavPzzQ"
136
  )
137
  return response
138
  except Exception as e:
@@ -253,10 +255,6 @@ async def history_chat_duplicate(id: str):
253
 
254
 
255
 
256
-
257
-
258
-
259
-
260
  # ---------------- GPT 3.5 TURBO NORMAL ----------------------------------------------------------------------------
261
  _providers = [g4f.Provider.OpenaiChat]
262
  chat_history = {}
@@ -272,7 +270,7 @@ async def run_provider(provider: g4f.Provider.OpenaiChat, messages):
272
  model='gpt-3.5-turbo',
273
  messages=messages,
274
  provider=provider,
275
- access_token="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaEVOVUpHTkVNMVFURTRNMEZCTWpkQ05UZzVNRFUxUlRVd1FVSkRNRU13UmtGRVFrRXpSZyJ9.eyJodHRwczovL2FwaS5vcGVuYWkuY29tL3Byb2ZpbGUiOnsiZW1haWwiOiJhbm90aGVyLjAxMDAxQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlfSwiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS9hdXRoIjp7InBvaWQiOiJvcmctR1BiYlpReUxrN1h4SHJpU0podEFpMkE3IiwidXNlcl9pZCI6InVzZXItdFZZcVg2UEpPRVBITVhERWxSVmFxbUVpIn0sImlzcyI6Imh0dHBzOi8vYXV0aDAub3BlbmFpLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDEwNDA4OTQ0NTIzMDg1ODI4NDk3NyIsImF1ZCI6WyJodHRwczovL2FwaS5vcGVuYWkuY29tL3YxIiwiaHR0cHM6Ly9vcGVuYWkub3BlbmFpLmF1dGgwYXBwLmNvbS91c2VyaW5mbyJdLCJpYXQiOjE3MDgxMjEwNzEsImV4cCI6MTcwODk4NTA3MSwiYXpwIjoiVGRKSWNiZTE2V29USHROOTVueXl3aDVFNHlPbzZJdEciLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIG1vZGVsLnJlYWQgbW9kZWwucmVxdWVzdCBvcmdhbml6YXRpb24ucmVhZCBvcmdhbml6YXRpb24ud3JpdGUgb2ZmbGluZV9hY2Nlc3MifQ.blRxc815g8lH91EFiG-YRvjLpaED-jeBpOoqO20FuQWZqsyQey88Lvg5V4oMCGrrZKGEA-NSemVf7h_TG_EaNMSDbThBXMz8hgIKxiey9qMDjiRW0InOm_-rD7u6MDKK-F_SIFt5_zH7y-122mlzEcTIATYSMQtVVEhy8DPLD3JhPZ3go9V_LizsIP40vGvwpf3fbPpidPZX8ceCg381vTwc6fAKX5gaDNgy5FlTBWfnRUKtayxrPITkRVnkvlqOqt7srFjLhrxeML5KvMur_8xFP_GPPGe5C97asRZenaT5Z1MwPx0VqADgL5tGoYuBB8ZsbE4fmEEQVQ9NavPzzQ"
276
  )
277
  return response
278
  except Exception as e:
@@ -344,4 +342,9 @@ async def history_chat(id: str):
344
  if id not in chat_history:
345
  raise HTTPException(status_code=404, detail="Session ID not found")
346
 
347
- return {"history": chat_history[id]['message']}
 
 
 
 
 
 
6
  from fastapi import FastAPI, HTTPException, Request
7
 
8
  app = FastAPI()
9
+ key = {
10
+ "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaEVOVUpHTkVNMVFURTRNMEZCTWpkQ05UZzVNRFUxUlRVd1FVSkRN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Q9NavPzzQ"
11
+ }
12
 
13
  # Character----------------------------------------------------------------------------
14
  character_info = """
 
134
  model="gpt-3.5-turbo",
135
  messages=messages,
136
  provider=provider,
137
+ access_token=key["token"]
138
  )
139
  return response
140
  except Exception as e:
 
255
 
256
 
257
 
 
 
 
 
258
  # ---------------- GPT 3.5 TURBO NORMAL ----------------------------------------------------------------------------
259
  _providers = [g4f.Provider.OpenaiChat]
260
  chat_history = {}
 
270
  model='gpt-3.5-turbo',
271
  messages=messages,
272
  provider=provider,
273
+ access_token=key["token"]
274
  )
275
  return response
276
  except Exception as e:
 
342
  if id not in chat_history:
343
  raise HTTPException(status_code=404, detail="Session ID not found")
344
 
345
+ return {"history": chat_history[id]['message']}
346
+
347
+ @app.get("/key")
348
+ async def change_key(id_key: str):
349
+ key["token"] = id_key
350
+ return {"key": id_key}