Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,18 @@ from huggingface_hub import InferenceClient
|
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def respond(
|
|
@@ -25,19 +36,19 @@ def respond(
|
|
| 25 |
|
| 26 |
messages.append({"role": "user", "content": message})
|
| 27 |
|
| 28 |
-
response =
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
stream=True,
|
| 34 |
-
temperature=
|
| 35 |
-
top_p=
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
response += token
|
| 40 |
-
yield response
|
| 41 |
|
| 42 |
|
| 43 |
"""
|
|
|
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
"""
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
from openai import OpenAI
|
| 10 |
+
# 设置 OpenAI 的 API 密钥和 API 基础 URL 以使用 vLLM 的 API 服务器。
|
| 11 |
+
openai_api_key = "EMPTY"
|
| 12 |
+
openai_api_base = "http://47.117.17.202:12345/v1"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
client = OpenAI(
|
| 16 |
+
api_key=openai_api_key,
|
| 17 |
+
base_url=openai_api_base,
|
| 18 |
+
)
|
| 19 |
|
| 20 |
|
| 21 |
def respond(
|
|
|
|
| 36 |
|
| 37 |
messages.append({"role": "user", "content": message})
|
| 38 |
|
| 39 |
+
response = openai.chat.completions.create(
|
| 40 |
+
model="Qwen2_5VL",
|
| 41 |
+
messages=messages,
|
| 42 |
+
extra_body={},
|
| 43 |
+
extra_headers={
|
| 44 |
+
"apikey": "empty"
|
| 45 |
+
},
|
| 46 |
stream=True,
|
| 47 |
+
temperature=0.7,
|
| 48 |
+
top_p=1.0,
|
| 49 |
+
)
|
| 50 |
+
for chunk in response:
|
| 51 |
+
yield chunk.choices[0].delta.content
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
"""
|