Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,27 +21,29 @@ def http_bot(messages, argsbox):
|
|
| 21 |
print(messages)
|
| 22 |
print(argsbox)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
return chat_completion.choices[0].message.content
|
| 46 |
|
| 47 |
|
|
@@ -49,8 +51,8 @@ def http_bot(messages, argsbox):
|
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
gr.Markdown("# vLLM text completion demo\n")
|
| 51 |
inputbox = gr.Textbox(label="Input",
|
| 52 |
-
placeholder="
|
| 53 |
-
argsbox = gr.Textbox(label="Args", placeholder="a dict of {api_key, base_url, model, temperature, max_tokens}")
|
| 54 |
outputbox = gr.Textbox(label="Output",
|
| 55 |
placeholder="Generated result from the model")
|
| 56 |
submit = gr.Button("Submit")
|
|
|
|
| 21 |
print(messages)
|
| 22 |
print(argsbox)
|
| 23 |
|
| 24 |
+
if args["model"]=="gpt-35-turbo":
|
| 25 |
+
baseurl="https://hkust.azure-api.net"
|
| 26 |
+
client = AzureOpenAI(
|
| 27 |
+
api_version="2023-07-01-preview",
|
| 28 |
+
azure_endpoint=baseurl,
|
| 29 |
+
api_key=args["api_key"],
|
| 30 |
+
)
|
| 31 |
+
chat_completion = client.chat.completions.create(
|
| 32 |
+
messages=messages["messages"],
|
| 33 |
+
model=args["model"],
|
| 34 |
+
temperature=float(args["temperature"]),
|
| 35 |
+
max_tokens=int(args["max_tokens"])
|
| 36 |
+
)
|
| 37 |
+
print(chat_completion)
|
| 38 |
+
else:
|
| 39 |
+
client = OpenAI(api_key=args["api_key"], base_url = args["base_url"])
|
| 40 |
+
chat_completion = client.chat.completions.create(
|
| 41 |
+
messages=messages,
|
| 42 |
+
model=args["model"],
|
| 43 |
+
temperature=float(args["temperature"]),
|
| 44 |
+
max_tokens=int(args["max_tokens"])
|
| 45 |
+
)
|
| 46 |
+
print(chat_completion)
|
| 47 |
return chat_completion.choices[0].message.content
|
| 48 |
|
| 49 |
|
|
|
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
gr.Markdown("# vLLM text completion demo\n")
|
| 53 |
inputbox = gr.Textbox(label="Input",
|
| 54 |
+
placeholder="Dict of infos")
|
| 55 |
+
argsbox = gr.Textbox(label="Args", placeholder="a dict of {api_key, base_url, model, temperature, max_tokens,....}")
|
| 56 |
outputbox = gr.Textbox(label="Output",
|
| 57 |
placeholder="Generated result from the model")
|
| 58 |
submit = gr.Button("Submit")
|