aaronemmanuel commited on
Commit
0b2a6bb
·
verified ·
1 Parent(s): db6d325

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -3,12 +3,13 @@ import pandas as pd
3
  from sklearn.ensemble import RandomForestClassifier
4
  import joblib
5
  import gradio as gr
 
6
 
7
  # Load the trained classifier model
8
  model = joblib.load('model_pkl')
9
 
10
- # OpenAI API key (assumed to be set in Hugging Face environment)
11
- openai.api_key = 'sk-hVMYjAtIAwnqbMnArtTm9dgt7fC_snc4P7On7AtxebT3BlbkFJPVg50uJ3R6G4O6_2l6IUqLKtRC3bn_VQBIt1S9HtAA'
12
 
13
  # Function to simulate the medical assistant's interaction
14
  def medical_assistant_interaction(pulse_rate, blood_pressure_systolic, blood_pressure_diastolic, temperature_celsius,
@@ -49,16 +50,15 @@ def medical_assistant_interaction(pulse_rate, blood_pressure_systolic, blood_pre
49
 
50
  The patient reported the following symptoms: {patient_responses}.
51
 
52
- Based on these readings and symptoms, what is the likelihood of Lassa fever? Provide additional follow-up questions if necessary.
53
  """
54
 
55
- # Call OpenAI's API for a response
56
- response = openai.Completion.create(
57
- engine="gpt-3.5-turbo",
58
- prompt=response_text,
59
- max_tokens=150
60
  )
61
- assistant_message = response['choices'][0]['text'].strip()
62
 
63
  # Combine the assistant's message with the model's prediction
64
  if prediction == 1:
 
3
  from sklearn.ensemble import RandomForestClassifier
4
  import joblib
5
  import gradio as gr
6
+ import google.generativeai as gai
7
 
8
  # Load the trained classifier model
9
  model = joblib.load('model_pkl')
10
 
11
+
12
+ gai.configure(api_key='AIzaSyAwP55Zlq9KqUBjHWWUjfzHcP4Sr8DVMuk')
13
 
14
  # Function to simulate the medical assistant's interaction
15
  def medical_assistant_interaction(pulse_rate, blood_pressure_systolic, blood_pressure_diastolic, temperature_celsius,
 
50
 
51
  The patient reported the following symptoms: {patient_responses}.
52
 
53
+ Based on these symptoms, what is the likelihood of Lassa fever? Provide additional follow-up questions if necessary.
54
  """
55
 
56
+ response = gai.chat(
57
+ model="chat-bison-001",
58
+ messages=[{"role": "user", "content": response_text}],
59
+ max_output_tokens=150
 
60
  )
61
+ assistant_message = response.last['content'].strip()
62
 
63
  # Combine the assistant's message with the model's prediction
64
  if prediction == 1: