Update main.py
Browse files
main.py
CHANGED
@@ -7,17 +7,13 @@ app = FastAPI()
|
|
7 |
# Define the Gradio API endpoint
|
8 |
gradio_api_url = "https://astro21-test-2.hf.space/--replicas/x5m8s/"
|
9 |
|
|
|
10 |
# Function to summarize a file using the Gradio API
|
11 |
async def summarize_file_with_gradio(file_content: str) -> Dict[str, str]:
|
12 |
try:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
result = response.json()
|
17 |
-
print(result)
|
18 |
-
return {"summary": result[0]}
|
19 |
-
else:
|
20 |
-
return {"error": "Gradio API request failed"}
|
21 |
except Exception as e:
|
22 |
return {"error": str(e)}
|
23 |
|
|
|
7 |
# Define the Gradio API endpoint
|
8 |
gradio_api_url = "https://astro21-test-2.hf.space/--replicas/x5m8s/"
|
9 |
|
10 |
+
# Function to summarize a file using the Gradio API
|
11 |
# Function to summarize a file using the Gradio API
|
12 |
async def summarize_file_with_gradio(file_content: str) -> Dict[str, str]:
|
13 |
try:
|
14 |
+
client = GradioClient(gradio_api_url)
|
15 |
+
result = await client.predict(file_content, api_name="/predict")
|
16 |
+
return {"summary": result[0]}
|
|
|
|
|
|
|
|
|
|
|
17 |
except Exception as e:
|
18 |
return {"error": str(e)}
|
19 |
|