WYNN747 commited on
Commit
577f602
β€’
1 Parent(s): 8a41d92

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +53 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from streamlit import components
4
+ import os
5
+
6
+
7
+ # Accessing the secret
8
+ api_token = os.environ["api_key"]
9
+
10
+ # Endpoint Configuration
11
+ API_URL = "https://g68dcpgzzj69vo6p.us-east-1.aws.endpoints.huggingface.cloud"
12
+ headers = {
13
+ "Accept": "application/json",
14
+ "Authorization": f"Bearer {api_token}",
15
+ "Content-Type": "application/json"
16
+ }
17
+
18
+ # Function to query the API with the prompt template
19
+ def query(user_input):
20
+ system_prompt = 'You are a helpful assistant that provides accurate and concise responses.'
21
+ formatted_input = f"<<SYS>>\n{system_prompt}\n<</SYS>>\n\n{user_input.strip()} [INST]\n\n"
22
+ payload = {
23
+ "inputs": formatted_input,
24
+ "parameters": {}
25
+ }
26
+ response = requests.post(API_URL, headers=headers, json=payload)
27
+ return response.json()
28
+
29
+ # Streamlit interface
30
+ st.title('Burmese GPT Beta')
31
+
32
+ # Example prompt (styled)
33
+ example_prompt = "Example: ပုဂဢထကြောင်း α€•α€Όα€±α€¬α€•α€Όα€”α€­α€―α€„α€Ία€™α€œα€¬α€Έ?"
34
+ st.markdown(f'<p style="color:gray;">{example_prompt}</p>', unsafe_allow_html=True)
35
+
36
+ user_input = st.text_input("Ask a question in Burmese:")
37
+
38
+ if user_input:
39
+ with st.spinner('Waiting for response...'):
40
+ # Query the model
41
+ output = query(user_input)
42
+
43
+ # Display the result
44
+ if isinstance(output, list):
45
+ answer = output[0] if output else 'No response generated.'
46
+ st.write(answer)
47
+ elif 'error' in output:
48
+ st.error(f"Error: {output['error']}")
49
+ else:
50
+ st.write('Unexpected response format.')
51
+
52
+ st.markdown("---")
53
+ st.markdown("Contact: { Dr.WaiYan, dr.waiyan@learnx.chat}")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ requests