Vitrous commited on
Commit
8203e0a
·
verified ·
1 Parent(s): 5d663d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -8,15 +8,13 @@ from fastapi.responses import HTMLResponse
8
  from datetime import datetime
9
  import random
10
  import string
11
- from datasets import Dataset
12
  import json
13
 
14
  # Set environment variables for GPU usage and memory allocation
15
  os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
16
  torch.cuda.empty_cache()
17
  torch.cuda.set_per_process_memory_fraction(0.8) # Adjust the fraction as needed
18
- # Assuming you've created the file conversations.jsonl
19
- dataset = Dataset('json', data_files="articko/conversations/conversations.jsonl")
20
  # Initialize FastAPI application
21
  app = FastAPI(root_path="/api/v1")
22
  conversations = {}
@@ -283,10 +281,12 @@ async def chat_thread(request: Request, user_id: str):
283
  conversation_entry = {'thread_id': thread_id, 'message_id': message_id, 'user': msg_prompt, 'assistant': response}
284
 
285
  # Save conversation history to disk
286
- save_conversation(user_id, conversation_entry)
 
 
287
 
288
  # Return response and thread ID
289
- return {'response': conversation_entry}
290
  except HTTPException as e:
291
  raise e
292
  except Exception as e:
 
8
  from datetime import datetime
9
  import random
10
  import string
 
11
  import json
12
 
13
  # Set environment variables for GPU usage and memory allocation
14
  os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
15
  torch.cuda.empty_cache()
16
  torch.cuda.set_per_process_memory_fraction(0.8) # Adjust the fraction as needed
17
+
 
18
  # Initialize FastAPI application
19
  app = FastAPI(root_path="/api/v1")
20
  conversations = {}
 
281
  conversation_entry = {'thread_id': thread_id, 'message_id': message_id, 'user': msg_prompt, 'assistant': response}
282
 
283
  # Save conversation history to disk
284
+ conversation_thread = ({"user_id": user_id, "conversation": conversation})
285
+
286
+
287
 
288
  # Return response and thread ID
289
+ return {'response': conversation_thread}
290
  except HTTPException as e:
291
  raise e
292
  except Exception as e: