Update main.py
Browse files
main.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
-
from
|
2 |
from gradio_client import Client
|
3 |
-
from flask_cors import CORS, cross_origin
|
4 |
|
5 |
-
app =
|
6 |
-
cors = CORS(app)
|
7 |
|
8 |
-
# Define the
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
-
#
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
def summarize_text():
|
16 |
-
if request.method == 'POST':
|
17 |
-
data = request.get_json()
|
18 |
-
file_content = data.get('file_content')
|
19 |
-
# app.logger.info(file_content)
|
20 |
-
result = summarize_file_with_gradio(file_content)
|
21 |
-
return jsonify(result)
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
from gradio_client import Client
|
|
|
3 |
|
4 |
+
app = FastAPI()
|
|
|
5 |
|
6 |
+
# Define a route for the prediction using FastAPI
|
7 |
+
@app.post("/predict")
|
8 |
+
async def predict(text: str):
|
9 |
+
# Replace this URL with the actual API endpoint URL
|
10 |
+
api_endpoint_url = "https://astro21-test-2.hf.space/--replicas/x5m8s/"
|
11 |
|
12 |
+
# Use the Gradio client to make the prediction request
|
13 |
+
client = Client(api_endpoint_url)
|
14 |
+
result = client.predict(
|
15 |
+
text,
|
16 |
+
api_name="/predict"
|
17 |
+
)
|
18 |
|
19 |
+
# Return the result as a response
|
20 |
+
return {"result": result}
|
|
|
|
|
|
|
|
|
|
|
|
|
|