NealCaren commited on
Commit
9e020a8
1 Parent(s): c9aecbe

Better Output

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -84,8 +84,14 @@ NEVER USE HASHTAGS.
84
  )
85
  r = json.loads(completion.choices[0].message.function_call.arguments)
86
  tweets = [{'type': tweet_type.split('_')[0], 'text': t['content']} for tweet_type in r for t in r[tweet_type]]
87
-
88
- return pd.DataFrame(tweets)
 
 
 
 
 
 
89
 
90
 
91
 
@@ -94,8 +100,8 @@ with gr.Blocks() as app:
94
  api_key_input = gr.Textbox(label="Password", placeholder="Enter the super secret password")
95
  abstract_input = gr.Textbox(label="Article Abstract", placeholder="Enter the article abstract here")
96
  generate_button = gr.Button("Generate Tweets")
97
- output_dataframe = gr.Dataframe()
98
 
99
- generate_button.click(fn=write_tweets, inputs=[api_key_input, abstract_input], outputs=output_dataframe)
100
 
101
  app.launch()
 
84
  )
85
  r = json.loads(completion.choices[0].message.function_call.arguments)
86
  tweets = [{'type': tweet_type.split('_')[0], 'text': t['content']} for tweet_type in r for t in r[tweet_type]]
87
+ df = pd.DataFrame(tweets)
88
+ grouped = df.groupby('type')['text'].apply(list).reset_index()
89
+ markdown = ""
90
+ for _, row in grouped.iterrows():
91
+ markdown += f"- **{row['type']}**\n"
92
+ for text in row['text']:
93
+ markdown += f" - {text}\n"
94
+ return markdown
95
 
96
 
97
 
 
100
  api_key_input = gr.Textbox(label="Password", placeholder="Enter the super secret password")
101
  abstract_input = gr.Textbox(label="Article Abstract", placeholder="Enter the article abstract here")
102
  generate_button = gr.Button("Generate Tweets")
103
+ output_markdown = gr.Markdown()
104
 
105
+ generate_button.click(fn=write_tweets, inputs=[api_key_input, abstract_input], outputs=output_markdown)
106
 
107
  app.launch()