Walterchamy's picture
Update app.py
1005767
raw
history blame
1.06 kB
import os
import openai
import streamlit as st
openai.api_key = os.getenv("OPENAI_API_KEY")
def generate_response(user_input):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "All your answers should be in swahili or english consider the language that the user has ask with, so here we start... Your virtual assistance of DON BOSCO KIITEC , you will reply the query that the user might ask !"},
{"role": "assistant", "content": "hi , there is any question concerning about DB kiitec that i might help?"},
{"role": "user", "content": user_input},
]
)
return response['choices'][0]['message']['content']
def main():
st.title("Chatbot Assistant")
user_input = st.text_input("Enter your question:")
if st.button("Generate"):
with st.spinner("Generating Response...."):
response_text = generate_response(user_input)
st.write("Response:", response_text)
if __name__ == '__main__':
main()