Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -2,6 +2,7 @@ from fastapi import FastAPI, HTTPException
|
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
from pydantic import BaseModel
|
4 |
from huggingface_hub import InferenceClient
|
|
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
@@ -53,4 +54,16 @@ def generate(item: Item):
|
|
53 |
|
54 |
@app.post("/generate/")
|
55 |
async def generate_text(item: Item):
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
from pydantic import BaseModel
|
4 |
from huggingface_hub import InferenceClient
|
5 |
+
import streamlit as st
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
54 |
|
55 |
@app.post("/generate/")
|
56 |
async def generate_text(item: Item):
|
57 |
+
# reject if key not the same
|
58 |
+
apiKey = st.secrets["API_KEY"]
|
59 |
+
# if apiKey != key:
|
60 |
+
# return jsonify({
|
61 |
+
# "image_url": image_url,
|
62 |
+
# "model": model,
|
63 |
+
# "result": "Invalid API Key",
|
64 |
+
# }), 400
|
65 |
+
|
66 |
+
return {
|
67 |
+
"response": generate(item),
|
68 |
+
"key": apiKey
|
69 |
+
}
|