Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,45 @@
|
|
| 1 |
import argparse
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
|
|
|
| 4 |
|
| 5 |
# Argument parser setup
|
| 6 |
-
parser = argparse.ArgumentParser(
|
| 7 |
-
description='Chatbot Interface with Customizable Parameters')
|
| 8 |
-
parser.add_argument('--model-url',
|
| 9 |
-
type=str,
|
| 10 |
-
default='http://134.28.190.100:8000/v1',
|
| 11 |
-
help='Model URL')
|
| 12 |
-
parser.add_argument('-m',
|
| 13 |
-
'--model',
|
| 14 |
-
type=str,
|
| 15 |
-
required=True,
|
| 16 |
-
default='TheBloke/Mistral-7B-Instruct-v0.2-AWQ',
|
| 17 |
-
help='Model name for the chatbot')
|
| 18 |
-
parser.add_argument('--temp',
|
| 19 |
-
type=float,
|
| 20 |
-
default=0.8,
|
| 21 |
-
help='Temperature for text generation')
|
| 22 |
-
parser.add_argument('--stop-token-ids',
|
| 23 |
-
type=str,
|
| 24 |
-
default='',
|
| 25 |
-
help='Comma-separated stop token IDs')
|
| 26 |
-
parser.add_argument("--host", type=str, default=None)
|
| 27 |
-
parser.add_argument("--port", type=int, default=8001)
|
| 28 |
|
| 29 |
# Parse the arguments
|
| 30 |
-
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Set OpenAI's API key and API base to use vLLM's API server.
|
| 33 |
openai_api_key = "EMPTY"
|
| 34 |
-
openai_api_base =
|
| 35 |
|
| 36 |
# Create an OpenAI client to interact with the API server
|
| 37 |
client = OpenAI(
|
|
|
|
| 1 |
import argparse
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
# Argument parser setup
|
| 7 |
+
#parser = argparse.ArgumentParser(
|
| 8 |
+
#description='Chatbot Interface with Customizable Parameters')
|
| 9 |
+
#parser.add_argument('--model-url',
|
| 10 |
+
#type=str,
|
| 11 |
+
#default='http://134.28.190.100:8000/v1',
|
| 12 |
+
#help='Model URL')
|
| 13 |
+
#parser.add_argument('-m',
|
| 14 |
+
#'--model',
|
| 15 |
+
#type=str,
|
| 16 |
+
#required=True,
|
| 17 |
+
#default='TheBloke/Mistral-7B-Instruct-v0.2-AWQ',
|
| 18 |
+
#help='Model name for the chatbot')
|
| 19 |
+
#parser.add_argument('--temp',
|
| 20 |
+
#type=float,
|
| 21 |
+
#default=0.8,
|
| 22 |
+
#help='Temperature for text generation')
|
| 23 |
+
##parser.add_argument('--stop-token-ids',
|
| 24 |
+
#type=str,
|
| 25 |
+
#default='',
|
| 26 |
+
#help='Comma-separated stop token IDs')
|
| 27 |
+
#parser.add_argument("--host", type=str, default=None)
|
| 28 |
+
#parser.add_argument("--port", type=int, default=8001)
|
| 29 |
|
| 30 |
# Parse the arguments
|
| 31 |
+
#args = parser.parse_args()
|
| 32 |
+
|
| 33 |
+
model_url = os.getenv('MODEL_URL', 'http://localhost:8000/v1')
|
| 34 |
+
model_name = os.getenv('MODEL_NAME', 'default-model-name') # Make sure to set this in the environment
|
| 35 |
+
temperature = float(os.getenv('TEMPERATURE', 0.8))
|
| 36 |
+
stop_token_ids = os.getenv('STOP_TOKEN_IDS', '')
|
| 37 |
+
host = os.getenv('HOST', '0.0.0.0')
|
| 38 |
+
port = int(os.getenv('PORT', 8001))
|
| 39 |
|
| 40 |
# Set OpenAI's API key and API base to use vLLM's API server.
|
| 41 |
openai_api_key = "EMPTY"
|
| 42 |
+
openai_api_base = model_url
|
| 43 |
|
| 44 |
# Create an OpenAI client to interact with the API server
|
| 45 |
client = OpenAI(
|