Update app.py
Browse filesChanged the model to "TheBloke/Qwen-7B-Chat-GPTQ"
app.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
|
2 |
-
from fastapi import FastAPI
|
3 |
-
from transformers import pipeline
|
4 |
-
|
5 |
-
|
6 |
-
## create a new FASTAPI app instance
|
7 |
-
|
8 |
-
app = FastAPI()
|
9 |
-
|
10 |
-
## Initiate the text generation pipeline
|
11 |
-
pipe = pipeline("text-generation", model="TheBloke/Qwen-7B-Chat-
|
12 |
-
|
13 |
-
|
14 |
-
@app.get("/")
|
15 |
-
def home():
|
16 |
-
return {"message": "Hello World"}
|
17 |
-
|
18 |
-
# Define a function to handle the GET request at '/generate'
|
19 |
-
|
20 |
-
@app.get("/generate")
|
21 |
-
def generate(text:str):
|
22 |
-
## use the pipeline to generate text from given input test
|
23 |
-
output = pipe(text, max_length=100, clean_up_tokenization_spaces=True)
|
24 |
-
##return the generate text in JSON response
|
25 |
return{"output":output[0]['generated_text']}
|
|
|
1 |
+
|
2 |
+
from fastapi import FastAPI
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
|
6 |
+
## create a new FASTAPI app instance
|
7 |
+
|
8 |
+
app = FastAPI()
|
9 |
+
|
10 |
+
## Initiate the text generation pipeline
|
11 |
+
pipe = pipeline("text-generation", model="TheBloke/Qwen-7B-Chat-GPTQ", trust_remote_code=True)
|
12 |
+
|
13 |
+
|
14 |
+
@app.get("/")
|
15 |
+
def home():
|
16 |
+
return {"message": "Hello World"}
|
17 |
+
|
18 |
+
# Define a function to handle the GET request at '/generate'
|
19 |
+
|
20 |
+
@app.get("/generate")
|
21 |
+
def generate(text:str):
|
22 |
+
## use the pipeline to generate text from given input test
|
23 |
+
output = pipe(text, max_length=100, clean_up_tokenization_spaces=True)
|
24 |
+
##return the generate text in JSON response
|
25 |
return{"output":output[0]['generated_text']}
|