Update app.py
Browse files
app.py
CHANGED
|
@@ -34,15 +34,6 @@ def get_response(query):
|
|
| 34 |
response = completion.choices[0].message.content
|
| 35 |
return response
|
| 36 |
|
| 37 |
-
# Function to transcribe audio using Whisper model
|
| 38 |
-
def transcribe_audio(file):
|
| 39 |
-
transcription = client.audio.transcriptions.create(
|
| 40 |
-
file=(file.name, file.read()),
|
| 41 |
-
model="whisper-large-v3-turbo",
|
| 42 |
-
response_format="verbose_json"
|
| 43 |
-
)
|
| 44 |
-
return transcription.text
|
| 45 |
-
|
| 46 |
def main():
|
| 47 |
st.title("Programming Developer Advisor Chatbot")
|
| 48 |
|
|
@@ -50,17 +41,8 @@ def main():
|
|
| 50 |
topic = st.selectbox("Choose a programming topic", developer_topics)
|
| 51 |
user_input = st.text_area("Or ask a programming-related question:", "")
|
| 52 |
|
| 53 |
-
# Use the transcribed text as the query for the chatbot if no custom query was provided
|
| 54 |
-
query = transcription if not user_input else user_input
|
| 55 |
-
|
| 56 |
-
# Get response from the chatbot based on the query
|
| 57 |
-
if query:
|
| 58 |
-
response = get_response(query)
|
| 59 |
-
st.write("### Response:")
|
| 60 |
-
st.write(response)
|
| 61 |
-
|
| 62 |
# If the user provides a query (not from audio), use that directly
|
| 63 |
-
|
| 64 |
query = user_input
|
| 65 |
response = get_response(query)
|
| 66 |
st.write("### Response:")
|
|
@@ -71,4 +53,4 @@ def main():
|
|
| 71 |
st.write("Sorry, I can only answer programming-related questions.")
|
| 72 |
|
| 73 |
if __name__ == "__main__":
|
| 74 |
-
main()
|
|
|
|
| 34 |
response = completion.choices[0].message.content
|
| 35 |
return response
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
def main():
|
| 38 |
st.title("Programming Developer Advisor Chatbot")
|
| 39 |
|
|
|
|
| 41 |
topic = st.selectbox("Choose a programming topic", developer_topics)
|
| 42 |
user_input = st.text_area("Or ask a programming-related question:", "")
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# If the user provides a query (not from audio), use that directly
|
| 45 |
+
if user_input:
|
| 46 |
query = user_input
|
| 47 |
response = get_response(query)
|
| 48 |
st.write("### Response:")
|
|
|
|
| 53 |
st.write("Sorry, I can only answer programming-related questions.")
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
+
main()
|