计算加速套件 TACO Kit 在线模式

TACO-LLM 提供了实现 OpenAI Completions 和 Chat API 的 HTTP 服务端,可以以按照以下流程进行使用。

相关产品
计算加速套件 TACO Kit 产品页,含版本规格、价格与购买入口。

一、启动服务

首先,执行以下命令启动服务:

taco_llm serve facebook/opt-125m –api-key taco-llm-test

二、发送请求

你可以使用 OpenAI 的 Python 客户端来发送请求:

from openai import OpenAIclient = OpenAI( base_url="http://localhost:8000/v1", api_key="taco-llm-test",)completion = client.chat.completions.create( model="facebook/opt-125m", messages=[ {"role": "user", "content": "Hello!"} ])print(completion.choices[0].message)

你也可以直接使用 HTTP 客户端来发送请求:

import requestsapi_key = "taco-llm-test"headers = { "Authorization": f"Bearer {api_key}"}pload = { "prompt": "Hello!", "stream": True, "max_tokens": 128,}response = requests.post("http://localhost:8000/v1/completions", headers=headers, json=pload, stream=True)for chunk in response.iter_lines(chunk_size=8192, decode_unicode=False, delimiter=b"\\0"): if chunk: data = json.loads(chunk.decode("utf-8")) output = data["text"][0] print(output)

三、完整服务端参数配置

执行 taco_llm serve -h 命令可以查看 TACO-LLM 完整的在线模式参数配置,详细内容请参见:在线模式 API。

四、完整客户端参数配置

除了少部分参数不支持外,TACO-LLM 完全支持 OpenAI 的参数配置。你可以参见 OpenAI API 产品文档查看完整的 API 参数配置。不支持的少部分参数配置如下:

·Chat: tools, and tool_choice。

·Completions: suffix。

赞 (0)
上一篇 4天前
下一篇 4天前