Spaces:
Sleeping
Sleeping
Commit
·
0bb76a8
1
Parent(s):
6159237
Update main.py
Browse files
main.py
CHANGED
|
@@ -36,7 +36,7 @@ class InputImage(BaseModel):
|
|
| 36 |
cfg: int = 7
|
| 37 |
seed: int = -1
|
| 38 |
|
| 39 |
-
class
|
| 40 |
nomeSpazio: str
|
| 41 |
input: str = ''
|
| 42 |
api_name: str = "/chat"
|
|
@@ -78,6 +78,7 @@ def format_prompt(message, history):
|
|
| 78 |
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 79 |
prompt += f"[{now}] [INST] {message} [/INST]"
|
| 80 |
return prompt
|
|
|
|
| 81 |
|
| 82 |
#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
|
| 83 |
@app.post("/Immagine")
|
|
@@ -111,15 +112,16 @@ def generate_image(request: Request, input_data: InputImage):
|
|
| 111 |
return {"error": "Errore interno del server persistente"}
|
| 112 |
return {"error": "Numero massimo di tentativi raggiunto"}
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
client = Client(input_data.nomeSpazio)
|
| 118 |
result = client.predict(
|
| 119 |
input_data.input,
|
| 120 |
api_name=input_data.api_name
|
| 121 |
)
|
| 122 |
-
return {"response":
|
| 123 |
|
| 124 |
@app.get("/")
|
| 125 |
def read_general():
|
|
|
|
| 36 |
cfg: int = 7
|
| 37 |
seed: int = -1
|
| 38 |
|
| 39 |
+
class PostSpazio(BaseModel):
|
| 40 |
nomeSpazio: str
|
| 41 |
input: str = ''
|
| 42 |
api_name: str = "/chat"
|
|
|
|
| 78 |
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
|
| 79 |
prompt += f"[{now}] [INST] {message} [/INST]"
|
| 80 |
return prompt
|
| 81 |
+
|
| 82 |
|
| 83 |
#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
|
| 84 |
@app.post("/Immagine")
|
|
|
|
| 112 |
return {"error": "Errore interno del server persistente"}
|
| 113 |
return {"error": "Numero massimo di tentativi raggiunto"}
|
| 114 |
|
| 115 |
+
|
| 116 |
+
#--------------------------------------------------- API PostSpazio ------------------------------------------------------
|
| 117 |
+
@app.post("/PostSpazio")
|
| 118 |
+
def generate_image(request: Request, input_data: PostSpazio):
|
| 119 |
client = Client(input_data.nomeSpazio)
|
| 120 |
result = client.predict(
|
| 121 |
input_data.input,
|
| 122 |
api_name=input_data.api_name
|
| 123 |
)
|
| 124 |
+
return {"response": result}
|
| 125 |
|
| 126 |
@app.get("/")
|
| 127 |
def read_general():
|