Sephfox commited on
Commit
1d99f89
·
verified ·
1 Parent(s): 4144978

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -1,8 +1,3 @@
1
- import warnings
2
-
3
- # Suppress specific warnings from huggingface_hub
4
- warnings.filterwarnings("ignore", category=FutureWarning, module="huggingface_hub.file_download")
5
-
6
  import numpy as np
7
  import pandas as pd
8
  import os
@@ -14,7 +9,7 @@ from sklearn.model_selection import train_test_split
14
  from sklearn.preprocessing import OneHotEncoder
15
  from sklearn.neural_network import MLPClassifier
16
  from deap import base, creator, tools, algorithms
17
- from transformers import GPTNeoXForCausalLM, GPTNeoXTokenizerFast
18
  import torch
19
 
20
  # Initialize Example Emotions Dataset
@@ -226,9 +221,9 @@ def handle_idle_state():
226
 
227
  # S.O.U.L. (Self-Organizing Universal Learning) Function
228
  class SOUL:
229
- def __init__(self, model_name='EleutherAI/gpt-neox-2.7B'):
230
- self.tokenizer = GPTNeoXTokenizerFast.from_pretrained(model_name)
231
- self.model = GPTNeoXForCausalLM.from_pretrained(model_name)
232
  self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
233
  self.model.to(self.device)
234
 
@@ -251,22 +246,21 @@ class SOUL:
251
  return self.tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
252
 
253
  def bridge_ai(self, prompt):
254
- # Generate the response using GPT-NeoX
255
- neox_response = self.generate_text(prompt)
256
 
257
  # Get the emotional response
258
- emotional_response = get_emotional_response(neox_response)
259
 
260
- return neox_response, emotional_response
261
 
262
  # Example usage of S.O.U.L. function
263
  soul = SOUL()
264
 
265
  def interact_with_soul(user_input):
266
- neox_response, emotional_response = soul.bridge_ai(user_input)
267
- return neox_response, emotional_response
268
 
269
- # Gradio interface setup
270
  iface = gr.Interface(
271
  fn=interact_with_soul,
272
  inputs="text",
@@ -275,5 +269,4 @@ iface = gr.Interface(
275
  description="Enter a prompt to interact with the S.O.U.L AI, which will generate a response and provide an emotional analysis."
276
  )
277
 
278
- # Launch the interface
279
  iface.launch()
 
 
 
 
 
 
1
  import numpy as np
2
  import pandas as pd
3
  import os
 
9
  from sklearn.preprocessing import OneHotEncoder
10
  from sklearn.neural_network import MLPClassifier
11
  from deap import base, creator, tools, algorithms
12
+ from transformers import BloomForCausalLM, BloomTokenizerFast
13
  import torch
14
 
15
  # Initialize Example Emotions Dataset
 
221
 
222
  # S.O.U.L. (Self-Organizing Universal Learning) Function
223
  class SOUL:
224
+ def __init__(self, model_name='bigscience/bloom-1b1'):
225
+ self.tokenizer = BloomTokenizerFast.from_pretrained(model_name)
226
+ self.model = BloomForCausalLM.from_pretrained(model_name)
227
  self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
228
  self.model.to(self.device)
229
 
 
246
  return self.tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
247
 
248
  def bridge_ai(self, prompt):
249
+ # Generate the response using BLOOM
250
+ bloom_response = self.generate_text(prompt)
251
 
252
  # Get the emotional response
253
+ emotional_response = get_emotional_response(bloom_response)
254
 
255
+ return bloom_response, emotional_response
256
 
257
  # Example usage of S.O.U.L. function
258
  soul = SOUL()
259
 
260
  def interact_with_soul(user_input):
261
+ bloom_response, emotional_response = soul.bridge_ai(user_input)
262
+ return bloom_response, emotional_response
263
 
 
264
  iface = gr.Interface(
265
  fn=interact_with_soul,
266
  inputs="text",
 
269
  description="Enter a prompt to interact with the S.O.U.L AI, which will generate a response and provide an emotional analysis."
270
  )
271
 
 
272
  iface.launch()