Zhuoxuan-Zhang commited on
Commit
cc37116
·
verified ·
1 Parent(s): 6286b47

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. chatgpt.py +8 -8
chatgpt.py CHANGED
@@ -12,8 +12,8 @@ from interview_protocol import protocols as interview_protocols
12
 
13
  model = whisper.load_model("base")
14
 
15
- base_url = "https://llm4socialisolation-fd4082d0a518.herokuapp.com"
16
- # base_url = "http://localhost:8080"
17
 
18
  timeout = 60
19
 
@@ -130,7 +130,7 @@ async def get_biography():
130
  headers = {'Content-Type': 'application/json'}
131
  async with httpx.AsyncClient(timeout=timeout) as client:
132
  try:
133
- response = await client.get(url, headers=headers)
134
  if response.status_code == 200:
135
  biography_data = response.json()
136
  biography_text = biography_data.get('biography', '')
@@ -143,10 +143,11 @@ async def get_biography():
143
  def download_biography():
144
  biography_text = asyncio.run(get_biography())
145
  if not biography_text or "Failed" in biography_text or "Error" in biography_text:
146
- return gr.update(value=None, visible=False), biography_text # Return the error message
147
- with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as temp_file:
 
 
148
  temp_file.write(biography_text)
149
- temp_file_path = temp_file.name
150
  return temp_file_path, "Biography generated successfully."
151
 
152
  def transcribe_audio(audio_file):
@@ -315,7 +316,7 @@ with gr.Blocks() as app:
315
  submit_button = gr.Button("Submit", variant="primary", size="large")
316
  save_conversation_button = gr.Button("End and Save Conversation", variant="secondary")
317
  download_button = gr.Button("Download Conversations", variant="secondary")
318
- download_biography_button = gr.Button("Download Biography", variant="secondary") # New button
319
 
320
  memory_graph_table = gr.Dataframe(
321
  headers=["Date", "Topic", "Description", "People Involved"],
@@ -345,7 +346,6 @@ with gr.Blocks() as app:
345
  outputs=gr.Files()
346
  )
347
 
348
- # Set up the download biography button
349
  download_biography_button.click(
350
  fn=download_biography,
351
  inputs=None,
 
12
 
13
  model = whisper.load_model("base")
14
 
15
+ # base_url = "https://llm4socialisolation-fd4082d0a518.herokuapp.com"
16
+ base_url = "http://localhost:8080"
17
 
18
  timeout = 60
19
 
 
130
  headers = {'Content-Type': 'application/json'}
131
  async with httpx.AsyncClient(timeout=timeout) as client:
132
  try:
133
+ response = await client.post(url, headers=headers)
134
  if response.status_code == 200:
135
  biography_data = response.json()
136
  biography_text = biography_data.get('biography', '')
 
143
  def download_biography():
144
  biography_text = asyncio.run(get_biography())
145
  if not biography_text or "Failed" in biography_text or "Error" in biography_text:
146
+ return gr.update(value=None, visible=False), biography_text
147
+ temp_dir = tempfile.mkdtemp()
148
+ temp_file_path = os.path.join(temp_dir, "biography.txt")
149
+ with open(temp_file_path, 'w') as temp_file:
150
  temp_file.write(biography_text)
 
151
  return temp_file_path, "Biography generated successfully."
152
 
153
  def transcribe_audio(audio_file):
 
316
  submit_button = gr.Button("Submit", variant="primary", size="large")
317
  save_conversation_button = gr.Button("End and Save Conversation", variant="secondary")
318
  download_button = gr.Button("Download Conversations", variant="secondary")
319
+ download_biography_button = gr.Button("Download Biography", variant="secondary")
320
 
321
  memory_graph_table = gr.Dataframe(
322
  headers=["Date", "Topic", "Description", "People Involved"],
 
346
  outputs=gr.Files()
347
  )
348
 
 
349
  download_biography_button.click(
350
  fn=download_biography,
351
  inputs=None,