Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -20,7 +20,7 @@ def format_prompt(message, history):
|
|
20 |
|
21 |
|
22 |
@app.post("/api/v1/generate_text")
|
23 |
-
|
24 |
history = [] # You might need to handle this based on your actual usage
|
25 |
print(f"prompt + {prompt}")
|
26 |
temperature = request.headers.get("temperature", 0.9)
|
@@ -40,16 +40,16 @@ async def generate_text(request: Request, prompt: str = Body()):
|
|
40 |
repetition_penalty=repetition_penalty,
|
41 |
do_sample=True,
|
42 |
seed=random.randint(0, 10**7),
|
43 |
-
stream=
|
44 |
details=True,
|
45 |
-
return_full_text=
|
46 |
)
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
return stream
|
|
|
20 |
|
21 |
|
22 |
@app.post("/api/v1/generate_text")
|
23 |
+
def generate_text(request: Request, prompt: str = Body()):
|
24 |
history = [] # You might need to handle this based on your actual usage
|
25 |
print(f"prompt + {prompt}")
|
26 |
temperature = request.headers.get("temperature", 0.9)
|
|
|
40 |
repetition_penalty=repetition_penalty,
|
41 |
do_sample=True,
|
42 |
seed=random.randint(0, 10**7),
|
43 |
+
stream=True,
|
44 |
details=True,
|
45 |
+
return_full_text=False
|
46 |
)
|
47 |
+
output = ""
|
48 |
|
49 |
+
for response in stream:
|
50 |
+
output += response.token.text
|
51 |
+
yield output
|
52 |
+
print(f"output + {output}")
|
53 |
+
return output
|
54 |
|
55 |
+
# return stream
|