Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -10,13 +10,6 @@ app = FastAPI() # Create FastAPI instance
|
|
| 10 |
primary = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 11 |
fallbacks = ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x7B-Instruct-v0.1"]
|
| 12 |
|
| 13 |
-
# Load Hugging Face API Key
|
| 14 |
-
HF_API_KEY = os.getenv("HF_API_TOKEN") # Get API key from environment variables
|
| 15 |
-
|
| 16 |
-
# If no env variable is set, manually define it (not recommended)
|
| 17 |
-
if not HF_API_KEY:
|
| 18 |
-
HF_API_KEY = "your_huggingface_api_key"
|
| 19 |
-
|
| 20 |
# Define the data model for the request body
|
| 21 |
class Item(BaseModel):
|
| 22 |
input: str = None # User input message
|
|
@@ -46,7 +39,7 @@ class Item(BaseModel):
|
|
| 46 |
max_new_tokens: int = 1048 # Maximum response length
|
| 47 |
top_p: float = 0.9 # Sampling parameter for diverse responses
|
| 48 |
repetition_penalty: float = 1.1 # Prevents repetition
|
| 49 |
-
key: str =
|
| 50 |
|
| 51 |
# Define rejection responses
|
| 52 |
rejection_responses = [
|
|
|
|
| 10 |
primary = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 11 |
fallbacks = ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x7B-Instruct-v0.1"]
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Define the data model for the request body
|
| 14 |
class Item(BaseModel):
|
| 15 |
input: str = None # User input message
|
|
|
|
| 39 |
max_new_tokens: int = 1048 # Maximum response length
|
| 40 |
top_p: float = 0.9 # Sampling parameter for diverse responses
|
| 41 |
repetition_penalty: float = 1.1 # Prevents repetition
|
| 42 |
+
key: str = ("HF_API_TOKEN") # API key if needed
|
| 43 |
|
| 44 |
# Define rejection responses
|
| 45 |
rejection_responses = [
|