File size: 1,061 Bytes
47b00df 1005767 47b00df ef21d5f 1005767 ef21d5f 1005767 ef21d5f 1005767 ef21d5f 1005767 5f739d5 ef21d5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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()
|