Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,11 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
# Tokenize the input text
|
12 |
-
input_ids = tokenizer.encode(input_text, truncation=True, padding=True, return_tensors="pt")
|
13 |
-
|
14 |
-
# Generate the summary
|
15 |
-
summary_ids = model.generate(input_ids, max_length=150, num_beams=2, early_stopping=True)
|
16 |
-
summary = tokenizer.decode(summary_ids.squeeze(), skip_special_tokens=True)
|
17 |
-
|
18 |
-
return summary
|
19 |
-
|
20 |
-
gr.Interface(fn=summarize_text, inputs='text', outputs='text').launch()
|
|
|
1 |
+
import requests
|
2 |
import gradio as gr
|
3 |
|
4 |
+
API_URL = "https://api-inference.huggingface.co/models/project-baize/baize-v2-7b"
|
5 |
+
headers = {"Authorization": "Bearer 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"}
|
6 |
|
7 |
+
def query(payload):
|
8 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
9 |
+
return response.json()
|
10 |
+
|
11 |
+
gr.Interface(fn=query, inputs='text', outputs = 'text').launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|