rodolfoocampo commited on
Commit
fd378ee
·
1 Parent(s): b1aa375

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -12
app.py CHANGED
@@ -10,19 +10,19 @@ SCOPE = ["https://www.googleapis.com/auth/drive"]
10
  SERVICE_ACCOUNT_FILE = "./check"
11
 
12
  os.environ['GOOGLE_SHEETS_TOKEN']
 
 
13
  creds = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_FILE, SCOPE)
14
  client = gspread.authorize(creds)
15
  sheet = client.open("Feedback").sheet1
16
 
17
 
18
-
19
  def continueStory(blank, messageHistory):
20
 
21
  openai.api_key = os.environ['OPENAI_KEY']
22
 
23
  messageHistory.append({"role": "user", "content": blank + "\n\nGenerate the next paragraph with a blank in the last line for me to fill. There should only be one and only one blank in the paragraph. The blank should be at the end of the last line of the paragraph. It is very importat that there is only one blank and that it is at the end!"})
24
 
25
-
26
  response = openai.ChatCompletion.create(
27
  model="gpt-3.5-turbo",
28
  messages = messageHistory
@@ -45,10 +45,6 @@ with gr.Blocks(css='''
45
  background-image: url('file=https://cdn.discordapp.com/attachments/941582479117127680/1080730421425344542/rodotcom_colorful_abstract_illustration_for_the_background_of_c_f1b331d7-6493-4a33-9063-345d31a66ddb.png');
46
 
47
  }
48
-
49
- .wrap {
50
- opacity: 0;
51
- }
52
  h1 {
53
  font-size: 3rem;
54
  font-weight: 700;
@@ -56,7 +52,36 @@ with gr.Blocks(css='''
56
  margin-bottom: 1rem;
57
  color: white;
58
  }
59
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  ''') as demo:
62
  title = gr.HTML('''
@@ -109,8 +134,6 @@ with gr.Blocks(css='''
109
 
110
  def submitFeedback(comment, rating, character, messageHistory):
111
 
112
-
113
-
114
  readableHistory = ''
115
  for m in messageHistory:
116
  readableHistory += m['content']
@@ -156,7 +179,7 @@ with gr.Blocks(css='''
156
  return story, messageHistory
157
 
158
  def createNewStory():
159
- return {character: gr.update(value=""), story_output: gr.update(value=""), blank: gr.update(value="")}
160
 
161
  def hideContinueBtn():
162
  return {continueStoryCol: gr.update(visible=False), newStoryCol: gr.update(visible=True), finishCol: gr.update(visible=False)}
@@ -173,7 +196,6 @@ with gr.Blocks(css='''
173
 
174
  submitFeedbackBtn.click(submitFeedback, [feedback_text, ratingRadio, character, messageHistory], [thankyou, feedbackForm])
175
 
176
- newStoryBtn.click(createNewStory, [], [character, story_output, blank])
177
-
178
 
179
  demo.launch(share=False)
 
10
  SERVICE_ACCOUNT_FILE = "./check"
11
 
12
  os.environ['GOOGLE_SHEETS_TOKEN']
13
+
14
+ # os.environ['GOOGLE_SHEETS_TOKEN']
15
  creds = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_FILE, SCOPE)
16
  client = gspread.authorize(creds)
17
  sheet = client.open("Feedback").sheet1
18
 
19
 
 
20
  def continueStory(blank, messageHistory):
21
 
22
  openai.api_key = os.environ['OPENAI_KEY']
23
 
24
  messageHistory.append({"role": "user", "content": blank + "\n\nGenerate the next paragraph with a blank in the last line for me to fill. There should only be one and only one blank in the paragraph. The blank should be at the end of the last line of the paragraph. It is very importat that there is only one blank and that it is at the end!"})
25
 
 
26
  response = openai.ChatCompletion.create(
27
  model="gpt-3.5-turbo",
28
  messages = messageHistory
 
45
  background-image: url('file=https://cdn.discordapp.com/attachments/941582479117127680/1080730421425344542/rodotcom_colorful_abstract_illustration_for_the_background_of_c_f1b331d7-6493-4a33-9063-345d31a66ddb.png');
46
 
47
  }
 
 
 
 
48
  h1 {
49
  font-size: 3rem;
50
  font-weight: 700;
 
52
  margin-bottom: 1rem;
53
  color: white;
54
  }
55
+ p {
56
+ font-size: 1.25rem;
57
+ margin-bottom: 2rem;
58
+ color: white;
59
+ }
60
+ label {
61
+ font-size: 1.25rem;
62
+ font-weight: 500;
63
+ margin-bottom: 0.5rem;
64
+ }
65
+ input[type="text"], textarea {
66
+ font-size: 1.25rem;
67
+ padding: 0.5rem;
68
+ border: 2px solid #ccc;
69
+ border-radius: 5px;
70
+ width: 100%;
71
+ }
72
+ .gradio-button {
73
+ background-color: #2196f3;
74
+ color: #fff;
75
+ font-size: 1.25rem;
76
+ font-weight: 500;
77
+ padding: 0.75rem 1.5rem;
78
+ border-radius: 5px;
79
+ cursor: pointer;
80
+ transition: all 0.2s ease-in-out;
81
+ }
82
+ .gradio-button:hover {
83
+ background-color: #0c7cd5;
84
+ }
85
 
86
  ''') as demo:
87
  title = gr.HTML('''
 
134
 
135
  def submitFeedback(comment, rating, character, messageHistory):
136
 
 
 
137
  readableHistory = ''
138
  for m in messageHistory:
139
  readableHistory += m['content']
 
179
  return story, messageHistory
180
 
181
  def createNewStory():
182
+ return {character: gr.update(value=""), story_output: gr.update(value=""), blank: gr.update(value=""), continueStoryCol: gr.update(visible=True), finishCol: gr.update(visible=True), newStoryCol: gr.update(visible=False) }
183
 
184
  def hideContinueBtn():
185
  return {continueStoryCol: gr.update(visible=False), newStoryCol: gr.update(visible=True), finishCol: gr.update(visible=False)}
 
196
 
197
  submitFeedbackBtn.click(submitFeedback, [feedback_text, ratingRadio, character, messageHistory], [thankyou, feedbackForm])
198
 
199
+ newStoryBtn.click(createNewStory, [], [character, story_output, blank, continueStoryCol, finishCol, newStoryCol])
 
200
 
201
  demo.launch(share=False)