aliss77777 commited on
Commit
70201ee
1 Parent(s): ebf11d7

using literal.ai data layer instead of local csv

Browse files
Files changed (2) hide show
  1. app.py +10 -10
  2. helper_functions.py +1 -1
app.py CHANGED
@@ -279,17 +279,17 @@ async def run_conversation(message_from_ui: cl.Message):
279
  elif res_feedback.get("value") in ["no_good", "IDK"]:
280
  res_reason = await cl.AskUserMessage(content="Could you please tell us why?").send()
281
 
282
- # Step 4: Capture user open-ended comments and write to a CSV file
283
- filename = f"feedback_logs/feedback_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
284
 
285
- with open(filename, "a", newline='') as csvfile:
286
- feedback_writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
287
- # Write column headers if the file is new/empty
288
- if csvfile.tell() == 0:
289
- feedback_writer.writerow(["Thread ID", "Feedback Value", "Reason Output"])
290
- # Assuming thread_id is available from earlier in your session
291
- thread = cl.user_session.get("thread")
292
- feedback_writer.writerow([thread.id, res_feedback.get('value'), res_reason['output'] if res_reason['output'] is not None else ''])
293
 
294
  thank_you_message = cl.Message(author="Climate Change Assistant", content="Thanks for your feedback!")
295
  await thank_you_message.send()
 
279
  elif res_feedback.get("value") in ["no_good", "IDK"]:
280
  res_reason = await cl.AskUserMessage(content="Could you please tell us why?").send()
281
 
282
+ # Step 4: Capture user open-ended comments and write to a CSV file // UPDATE: Literal.AI data layer handles this
283
+ #filename = f"feedback_logs/feedback_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
284
 
285
+ #with open(filename, "a", newline='') as csvfile:
286
+ # feedback_writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
287
+ # # Write column headers if the file is new/empty
288
+ # if csvfile.tell() == 0:
289
+ # feedback_writer.writerow(["Thread ID", "Feedback Value", "Reason Output"])
290
+ # # Assuming thread_id is available from earlier in your session
291
+ # thread = cl.user_session.get("thread")
292
+ # feedback_writer.writerow([thread.id, res_feedback.get('value'), res_reason['output'] if res_reason['output'] is not None else ''])
293
 
294
  thank_you_message = cl.Message(author="Climate Change Assistant", content="Thanks for your feedback!")
295
  await thank_you_message.send()
helper_functions.py CHANGED
@@ -28,7 +28,7 @@ pf_api_url = "https://graphql.probablefutures.org"
28
  #pf_token_url = "https://probablefutures.us.auth0.com/oauth/token"
29
 
30
  load_dotenv()
31
- api_key = os.environ.get("OPENAI_API_KEY")
32
  client = OpenAI(api_key=api_key)
33
 
34
  model = "gpt-4o" #"gpt-4-0125-preview" # gpt-4 #gpt-3.5-turbo-16k
 
28
  #pf_token_url = "https://probablefutures.us.auth0.com/oauth/token"
29
 
30
  load_dotenv()
31
+ api_key = os.getenv("OPENAI_API_KEY")
32
  client = OpenAI(api_key=api_key)
33
 
34
  model = "gpt-4o" #"gpt-4-0125-preview" # gpt-4 #gpt-3.5-turbo-16k