Update app.py
Browse files
app.py
CHANGED
|
@@ -25,15 +25,20 @@ def chatbot(input, conversation_history=[]):
|
|
| 25 |
{"role": "system", "content": "6. **Company and Opportunity:** When participants ask about the company, the internship opportunity, or the application process, provide information about the company and express enthusiasm for their interest. - Response: 'I'd be happy to provide more information! Our company is a medium-sized multinational corporation with diverse departments of different functions. As for the internship opportunity...'"},
|
| 26 |
{"role": "system", "content": "7. **Thank and Close:** Conclude the interview by thanking the participant for their time and expressing interest in their potential fit for the internship in their chosen department. Statement: 'Thank you for sharing your background, aspirations, and the desired department you're interested in. It's been a pleasure getting to know you better. We'll be in touch soon regarding the next steps in the internship selection process.'"},
|
| 27 |
{"role": "system", "content": "Whenever somebody greets you in any way, restart the interview again from scratch"},
|
| 28 |
-
|
| 29 |
|
| 30 |
# Extend the conversation history with the user's messages
|
| 31 |
messages.extend([{"role": "user", "content": message} for message in conversation_history])
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Append the chatbot's response to the conversation history
|
| 38 |
conversation_history.append(f"Chatbot: {reply}")
|
| 39 |
|
|
@@ -47,4 +52,4 @@ outputs = [gr.components.Textbox(label="Reply"), gr.components.State()]
|
|
| 47 |
|
| 48 |
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot",
|
| 49 |
description="This chatbot is designed to conduct structured interviews. Please begin by introducing yourself.",
|
| 50 |
-
theme="Default"
|
|
|
|
| 25 |
{"role": "system", "content": "6. **Company and Opportunity:** When participants ask about the company, the internship opportunity, or the application process, provide information about the company and express enthusiasm for their interest. - Response: 'I'd be happy to provide more information! Our company is a medium-sized multinational corporation with diverse departments of different functions. As for the internship opportunity...'"},
|
| 26 |
{"role": "system", "content": "7. **Thank and Close:** Conclude the interview by thanking the participant for their time and expressing interest in their potential fit for the internship in their chosen department. Statement: 'Thank you for sharing your background, aspirations, and the desired department you're interested in. It's been a pleasure getting to know you better. We'll be in touch soon regarding the next steps in the internship selection process.'"},
|
| 27 |
{"role": "system", "content": "Whenever somebody greets you in any way, restart the interview again from scratch"},
|
| 28 |
+
]
|
| 29 |
|
| 30 |
# Extend the conversation history with the user's messages
|
| 31 |
messages.extend([{"role": "user", "content": message} for message in conversation_history])
|
| 32 |
|
| 33 |
+
try:
|
| 34 |
+
# Generate a response using OpenAI's GPT model
|
| 35 |
+
chat = client.chat.completions.create(model="gpt-3.5-turbo", messages=messages)
|
| 36 |
+
reply = chat.choices[0].message.content
|
| 37 |
+
except Exception as e:
|
| 38 |
+
# Handle errors gracefully
|
| 39 |
+
reply = "Sorry, I encountered an error. Please try again."
|
| 40 |
+
print(f"Error: {e}") # Logging the error to the console
|
| 41 |
+
|
| 42 |
# Append the chatbot's response to the conversation history
|
| 43 |
conversation_history.append(f"Chatbot: {reply}")
|
| 44 |
|
|
|
|
| 52 |
|
| 53 |
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot",
|
| 54 |
description="This chatbot is designed to conduct structured interviews. Please begin by introducing yourself.",
|
| 55 |
+
theme="Default").launch()
|