wop commited on
Commit
0906144
·
verified ·
1 Parent(s): c56b1c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -23,19 +23,6 @@ async def wait(job):
23
  while not job.done():
24
  await asyncio.sleep(0.2)
25
 
26
- def get_client(session: Optional[str] = None) -> grc.Client:
27
- client = grc.Client("https://wop-xxx-opengpt.hf.space/", hf_token=HF_TOKEN)
28
- if session:
29
- client.session_hash = session
30
- return client
31
-
32
- def truncate_response(response: str) -> str:
33
- ending = "...\nTruncating response to 2000 characters due to discord api limits."
34
- if len(response) > 2000:
35
- return response[: 2000 - len(ending)] + ending
36
- else:
37
- return response
38
-
39
  intents = discord.Intents.all()
40
  bot = commands.Bot(command_prefix="$", intents=intents, help_command=None)
41
 
@@ -68,10 +55,10 @@ async def ai(ctx, *, input_text: str):
68
  # Check if it's time to start a new session
69
  if session_count % 10 == 0:
70
  # Start a new session by passing a unique session hash
71
- client = get_client(session=str(datetime.datetime.now()))
72
  else:
73
  # Use the existing session
74
- client = get_client()
75
 
76
  # Make a request to the /chat endpoint
77
  result = client.predict(
 
23
  while not job.done():
24
  await asyncio.sleep(0.2)
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  intents = discord.Intents.all()
27
  bot = commands.Bot(command_prefix="$", intents=intents, help_command=None)
28
 
 
55
  # Check if it's time to start a new session
56
  if session_count % 10 == 0:
57
  # Start a new session by passing a unique session hash
58
+ client = grc.Client("https://wop-xxx-opengpt.hf.space/", hf_token=HF_TOKEN)
59
  else:
60
  # Use the existing session
61
+ print("skip ses")
62
 
63
  # Make a request to the /chat endpoint
64
  result = client.predict(