awacke1 commited on
Commit
1626664
1 Parent(s): ace6ada

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -45,23 +45,29 @@ generator1 = gr.Interface.load("huggingface/gpt2-large", api_key=HF_TOKEN)
45
  generator2 = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B", api_key=HF_TOKEN)
46
  generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOKEN)
47
 
48
- def calculator(text1, operation, text2):
49
- if operation == "add":
50
- output = generator1(text1) + generator2(text2)
51
- saved = AIMemory(text1 + " " + text2, output)
 
52
  return output
53
- elif operation == "subtract":
54
- output = generator1(text2) + generator2(text1)
55
- saved = AIMemory(text1 + " " + text2, output)
56
- return output.replace(text1, "").replace(text2, "")
57
- elif operation == "multiply":
58
- output = generator1(text1) + generator2(text2) + generator3(text1)
59
- saved = AIMemory(text1 + " " + text2, output)
 
 
 
 
 
 
 
 
 
60
  return output
61
- elif operation == "divide":
62
- output = generator1(text2) + generator2(text1) + generator3(text2)
63
- saved = AIMemory(text1 + " " + text2, output)
64
- return output.replace(text1, "").replace(text2, "")
65
 
66
  #with open('Mindfulness.txt', 'r') as file:
67
  # context = file.read()
@@ -91,6 +97,7 @@ demo = gr.Interface(
91
  ],
92
  "text",
93
  examples=examples,
 
94
  live=True,
95
  )
96
  demo.launch()
 
45
  generator2 = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B", api_key=HF_TOKEN)
46
  generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOKEN)
47
 
48
+ def calculator(intro, operator, outro):
49
+ if operator == "add":
50
+ output = generator2(intro) + generator3(outro)
51
+ title = intro + " " + outro
52
+ saved = AIMemory(title, output)
53
  return output
54
+ elif operator == "subtract":
55
+ output = generator2(outro) + generator3(intro)
56
+ title = outro + " " + intro
57
+ saved = AIMemory(title, output)
58
+ output = output.replace(intro, "").replace(outro, "")
59
+ return output
60
+ elif operator == "multiply":
61
+ output = generator1(intro) + generator2(outro) + generator3(intro)
62
+ title = intro + " " + outro + " " + intro
63
+ saved = AIMemory(title, output)
64
+ return output
65
+ elif operator == "divide":
66
+ output = generator1(outro) + generator2(intro) + generator3(outro)
67
+ title = outro + " " + intro + " " + outro
68
+ saved = AIMemory(title, output)
69
+ output = output.replace(intro, "").replace(outro, "")
70
  return output
 
 
 
 
71
 
72
  #with open('Mindfulness.txt', 'r') as file:
73
  # context = file.read()
 
97
  ],
98
  "text",
99
  examples=examples,
100
+ article="Saved story memory is at URL: https://huggingface.co/datasets/awacke1/MindfulStory.csv",
101
  live=True,
102
  )
103
  demo.launch()