import streamlit as st import requests from streamlit import components import os # Accessing the secret api_token = os.environ["api_key"] # Endpoint Configuration API_URL = "https://g68dcpgzzj69vo6p.us-east-1.aws.endpoints.huggingface.cloud" headers = { "Accept": "application/json", "Authorization": f"Bearer {api_token}", "Content-Type": "application/json" } # Function to query the API with the prompt template def query(user_input): system_prompt = 'You are a helpful assistant that provides accurate and concise responses.' formatted_input = f"<>\n{system_prompt}\n<>\n\n{user_input.strip()} [INST]\n\n" payload = { "inputs": formatted_input, "parameters": {} } response = requests.post(API_URL, headers=headers, json=payload) return response.json() # Streamlit interface st.title('Burmese GPT Beta') # Example prompt (styled) example_prompt = "Example: ပုဂံအကြောင်း ပြောပြနိုင်မလား?" st.markdown(f'

{example_prompt}

', unsafe_allow_html=True) user_input = st.text_input("Ask a question in Burmese:") if user_input: with st.spinner('Waiting for response...'): # Query the model output = query(user_input) # Display the result if isinstance(output, list): answer = output[0] if output else 'No response generated.' st.write(answer) elif 'error' in output: st.error(f"Error: {output['error']}") else: st.write('Unexpected response format.') st.markdown("---") st.markdown("Contact: { Dr.WaiYan, dr.waiyan@learnx.chat}")