Radosław Wolnik commited on
Commit
12b4ccb
·
1 Parent(s): dd959b4
Files changed (1) hide show
  1. app.py +1 -25
app.py CHANGED
@@ -42,7 +42,7 @@ async def on_message(message):
42
  message_counts[message.channel.id] = 0 # Reset the counter
43
 
44
 
45
- response = generate(str(message), temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
46
  splited_response = split_string(str(response))
47
  for part in splited_response:
48
  await channel.send(part)
@@ -53,30 +53,6 @@ def split_string(text: str) -> list[str]:
53
  """Helper function to split text into chunks"""
54
  return [text[i:i+3900] for i in range(0, len(text), 3900)]
55
 
56
- def generate(
57
- prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0
58
- ):
59
- temperature = float(temperature)
60
- if temperature < 1e-2:
61
- temperature = 1e-2
62
- top_p = float(top_p)
63
-
64
- generate_kwargs = dict(
65
- temperature=temperature,
66
- max_new_tokens=max_new_tokens,
67
- top_p=top_p,
68
- repetition_penalty=repetition_penalty,
69
- do_sample=True,
70
- seed=42,
71
- )
72
-
73
- stream = ai.text_generation(prompt, **generate_kwargs, stream=False, details=True, return_full_text=True)
74
- output = ""
75
- for response in stream:
76
- output += response.token.text
77
- yield output
78
- return output
79
-
80
  @bot.event
81
  async def on_ready():
82
  print(f'Logged in as {bot.user}') # Logs bot login in console
 
42
  message_counts[message.channel.id] = 0 # Reset the counter
43
 
44
 
45
+ response = ai.text_generation(message, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
46
  splited_response = split_string(str(response))
47
  for part in splited_response:
48
  await channel.send(part)
 
53
  """Helper function to split text into chunks"""
54
  return [text[i:i+3900] for i in range(0, len(text), 3900)]
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  @bot.event
57
  async def on_ready():
58
  print(f'Logged in as {bot.user}') # Logs bot login in console