Manyue-DataScientist commited on
Commit
951a139
·
verified ·
1 Parent(s): 10f99c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -101,16 +101,18 @@ def get_chat_response(query: str, knowledge_base: dict) -> str:
101
  client = get_openai_client()
102
 
103
  # Generate response
104
- response = client.create_completion(
105
- model="gpt-4o-mini",
 
 
 
 
106
  max_tokens=200,
107
- temperature=0.7,
108
- n=1,
109
- stop=None
110
  )
111
 
112
  # Extract and clean response
113
- response_text = response.choices[0].text.strip()
114
 
115
  return response_text
116
 
@@ -173,7 +175,7 @@ def main():
173
  "What is your educational background?"
174
  ]
175
 
176
- for question in example_questions:
177
  if st.button(question):
178
  st.session_state.messages.append({"role": "user", "content": question})
179
  st.experimental_rerun()
 
101
  client = get_openai_client()
102
 
103
  # Generate response
104
+ response = client.ChatCompletion.create(
105
+ model="gpt-4-mini",
106
+ messages=[
107
+ {"role": "system", "content": prompt},
108
+ {"role": "user", "content": query}
109
+ ],
110
  max_tokens=200,
111
+ temperature=0.7
 
 
112
  )
113
 
114
  # Extract and clean response
115
+ response_text = response.choices[0].message.content.strip()
116
 
117
  return response_text
118
 
 
175
  "What is your educational background?"
176
  ]
177
 
178
+ for question in example_question:
179
  if st.button(question):
180
  st.session_state.messages.append({"role": "user", "content": question})
181
  st.experimental_rerun()