BoxzDev commited on
Commit
78471b1
·
verified ·
1 Parent(s): d99c89e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -2
main.py CHANGED
@@ -10,6 +10,13 @@ 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
  # Define the data model for the request body
14
  class Item(BaseModel):
15
  input: str = None # User input message
@@ -39,7 +46,7 @@ class Item(BaseModel):
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 = [
@@ -163,4 +170,4 @@ def root():
163
  return {"status": "Sebari-chan is online!"}
164
 
165
  if __name__ == "__main__":
166
- uvicorn.run(app, host="0.0.0.0", port=8000)
 
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
  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 = None # API key if needed
50
 
51
  # Define rejection responses
52
  rejection_responses = [
 
170
  return {"status": "Sebari-chan is online!"}
171
 
172
  if __name__ == "__main__":
173
+ uvicorn.run(app, host="0.0.0.0", port=8000)