Spaces:
Runtime error
Runtime error
Commit
·
92d35c2
1
Parent(s):
9296336
Test 2
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from pydantic import BaseModel
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
-
from typing import List
|
5 |
import torch
|
6 |
|
7 |
app = FastAPI(title="Language Model API")
|
@@ -50,8 +50,7 @@ async def generate_response(request: ChatRequest):
|
|
50 |
response_text = tokenizer.decode(outputs[0])
|
51 |
|
52 |
return {
|
53 |
-
"generated_text": response_text
|
54 |
-
"input_text": input_text
|
55 |
}
|
56 |
|
57 |
except Exception as e:
|
@@ -59,4 +58,4 @@ async def generate_response(request: ChatRequest):
|
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
import uvicorn
|
62 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from pydantic import BaseModel
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
+
from typing import List
|
5 |
import torch
|
6 |
|
7 |
app = FastAPI(title="Language Model API")
|
|
|
50 |
response_text = tokenizer.decode(outputs[0])
|
51 |
|
52 |
return {
|
53 |
+
"generated_text": response_text
|
|
|
54 |
}
|
55 |
|
56 |
except Exception as e:
|
|
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
import uvicorn
|
61 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|