Spaces:
Runtime error
Runtime error
Commit
·
2e5d594
1
Parent(s):
cee61fd
Added inference api
Browse files- app.py +4 -2
- pages/turna.py +28 -0
app.py
CHANGED
@@ -5,8 +5,10 @@ import pages.home
|
|
5 |
import pages.turna
|
6 |
|
7 |
st.set_page_config(
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
PAGES = {
|
12 |
"Home": pages.home,
|
|
|
5 |
import pages.turna
|
6 |
|
7 |
st.set_page_config(
|
8 |
+
page_title="About Turna",
|
9 |
+
page_icon="📖",
|
10 |
+
layout='wide'
|
11 |
+
)
|
12 |
|
13 |
PAGES = {
|
14 |
"Home": pages.home,
|
pages/turna.py
CHANGED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import streamlit as st
|
3 |
+
import time
|
4 |
+
|
5 |
+
API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/TURNA"
|
6 |
+
|
7 |
+
def write():
|
8 |
+
|
9 |
+
st.title('Turkish Language Generation')
|
10 |
+
st.write('...with Turna')
|
11 |
+
input_al = st.text_area(label='Enter a text: ', height=300,
|
12 |
+
value="Türkiye'nin başkeni neresidir?")
|
13 |
+
with st.spinner('Generating...'):
|
14 |
+
|
15 |
+
output = query(input_al)
|
16 |
+
print(output)
|
17 |
+
st.success(output)
|
18 |
+
|
19 |
+
def query(payload):
|
20 |
+
while True:
|
21 |
+
response = requests.post(API_URL, json=payload)
|
22 |
+
if 'error' not in response.json():
|
23 |
+
output = response.json()[0]["generated_text"]
|
24 |
+
return output
|
25 |
+
else:
|
26 |
+
time.sleep(15)
|
27 |
+
print('Sending request again', flush=True)
|
28 |
+
|