xulh
commited on
Commit
·
9a0053e
1
Parent(s):
adf9187
代码初始化
Browse files- inference/inference.py +2 -2
- picture/generalImg.py +1 -2
inference/inference.py
CHANGED
@@ -60,7 +60,7 @@ async def chat_completion(token: str = Body(...), messages: list = Body(...)):
|
|
60 |
client = InferenceClient(api_key=token)
|
61 |
print("问题:", messages)
|
62 |
messages.append({
|
63 |
-
"role": "
|
64 |
"content": "You are a multilingual chatbot capable of understanding questions in various languages and "
|
65 |
"providing accurate responses in the appropriate language. However, all questions must be "
|
66 |
"answered in Chinese."
|
@@ -68,7 +68,7 @@ async def chat_completion(token: str = Body(...), messages: list = Body(...)):
|
|
68 |
|
69 |
# 使用 chat API 请求生成模型的回答 备选模型 google/gemma-2-2b-it
|
70 |
completion = client.chat.completions.create(
|
71 |
-
model="
|
72 |
messages=messages,
|
73 |
max_tokens=500
|
74 |
)
|
|
|
60 |
client = InferenceClient(api_key=token)
|
61 |
print("问题:", messages)
|
62 |
messages.append({
|
63 |
+
"role": "system",
|
64 |
"content": "You are a multilingual chatbot capable of understanding questions in various languages and "
|
65 |
"providing accurate responses in the appropriate language. However, all questions must be "
|
66 |
"answered in Chinese."
|
|
|
68 |
|
69 |
# 使用 chat API 请求生成模型的回答 备选模型 google/gemma-2-2b-it
|
70 |
completion = client.chat.completions.create(
|
71 |
+
model="google/gemma-2-2b-it",
|
72 |
messages=messages,
|
73 |
max_tokens=500
|
74 |
)
|
picture/generalImg.py
CHANGED
@@ -13,8 +13,7 @@ async def generate_image(token: str = Body(...), prompt: str = Body(...)):
|
|
13 |
# 创建InferenceClient
|
14 |
client = InferenceClient("stabilityai/stable-diffusion-3-medium-diffusers", token=token)
|
15 |
# 使用text_to_image方法生成图片
|
16 |
-
image = client.text_to_image(prompt=prompt, height=256, width=256
|
17 |
-
negative_prompt="low quality, blurry, bad anatomy")
|
18 |
|
19 |
# 将PIL.Image对象转换为byte数据
|
20 |
buffered = BytesIO()
|
|
|
13 |
# 创建InferenceClient
|
14 |
client = InferenceClient("stabilityai/stable-diffusion-3-medium-diffusers", token=token)
|
15 |
# 使用text_to_image方法生成图片
|
16 |
+
image = client.text_to_image(prompt=prompt, height=256, width=256)
|
|
|
17 |
|
18 |
# 将PIL.Image对象转换为byte数据
|
19 |
buffered = BytesIO()
|