VeuReu commited on
Commit
5a08dcb
·
verified ·
1 Parent(s): d155856

Upload schat_client.py

Browse files
Files changed (1) hide show
  1. schat_client.py +28 -0
schat_client.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.environ["CUDA_VISIBLE_DEVICES"] = "1"
3
+
4
+ from gradio_client import Client, handle_file
5
+ from typing import Any, Dict, List, Optional, Tuple, Union
6
+ import requests
7
+ import json
8
+
9
+ # Lazy initialization to avoid crash if Space is down at import time
10
+ _stools_client = None
11
+
12
+
13
+ def _get_stools_client():
14
+ """Get or create the svision client (lazy initialization)."""
15
+ global _stools_client
16
+ if _stools_client is None:
17
+ _stools_client = Client("VeuReu/stools")
18
+ return _stools_client
19
+
20
+ def get_from_prompt(prompt):
21
+ client = _get_stools_client()
22
+
23
+ result = client.predict(
24
+ prompt=prompt,
25
+ api_name="/generate_out_from_prompt"
26
+ )
27
+
28
+ return result