Readme
Files and versions
Updated 10 months ago
akcio
Zhipu AI
author: Jael
Description 描述
This operator is implemented with ChatGLM services from Zhipu AI. It directly returns the original response in dictionary without parsing. Please note you will need API Key to access the service.
LLM/ZhipuAI 利用了来自智谱AI开放平台的大语言模型服务。该算子以字典的形式直接返回原始的模型回复。请注意,您需要API Key才能访问该服务。
Code Example 代码示例
Write a pipeline with explicit inputs/outputs name specifications:
from towhee import pipe, ops
p = (
pipe.input('messages')
.map('messages', 'response', ops.LLM.ZhipuAI(
api_key=ZHIPUAI_API_KEY,
model_name='chatglm_130b', # or 'chatglm_6b'
temperature=0.5,
max_tokens=50,
))
.output('response')
)
messages=[
{'system': '你是一个资深的软件工程师,善于回答关于科技项目的问题。'},
{'question': 'Zilliz Cloud 是什么?', 'answer': 'Zilliz Cloud 是一种全托管的向量检索服务。'},
{'question': '它和 Milvus 的关系是什么?'}
]
response = p(messages).get()[0]
answer = response['choices'][0]['content']
token_usage = response['usage']
Factory Constructor 接口说明
Create the operator via the following factory method:
LLM.ZhipuAI(api_key: str, model_name: str, **kwargs)
Parameters:
api_key: str=None
The Zhipu AI API key in string, defaults to None. If None, it will use the environment variable ZHIPUAI_API_KEY
.
model_name: str='chatglm_130b'
The model used in Zhipu AI service, defaults to 'chatglm_130b'. Visit Zhipu AI documentation for supported models.
**kwargs
Other ChatGLM parameters such as temperature, etc.
Interface 使用说明
The operator takes a piece of text in string as input. It returns answer in json.
__call__(txt)
Parameters:
messages: list
A list of messages to set up chat. Must be a list of dictionaries with key value from "system", "question", "answer". For example, [{"question": "a past question?", "answer": "a past answer."}, {"question": "current question?"}]. It also accepts the orignal ChatGLM message format like [{"role": "user", "content": "a question?"}, {"role": "assistant", "content": "an answer."}]
Returns:
response: dict
The original llm response in dictionary, including next answer and token usage.
More Resources
- Zilliz partnership with Arize AI: Together Arize AI and Zilliz help users better understand and fine tune their LLM, CV, and NLP models.
- Revolutionizing Search with Zilliz and Azure OpenAI - Zilliz blog: In AI development, a new integration emerged between Zilliz and Azure OpenAI. Together, they redefine the landscape of similarity and semantic search, infusing them with remarkable speed, intelligence, and safeguards. Let's explore this fusion of cutting-edge technologies.
- Careers | Zilliz: Build your AI career at Zilliz! We're building the world's best vector database for AI applications.
- ChatGPT+ Vector database + prompt-as-code - The CVP Stack - Zilliz blog: Extend the capability of ChatGPT with a Vector database and prompts-as-code
- About Zen Yui | Zilliz: Co-Founder & CTO, Troop
- TL;DR Milvus regression in LangChain v0.1.5 - Zilliz blog: If you're encountering a "KeyError: 'pk'" error when using Langchain v0.1.5 to connect to Milvus, here is the solution.
- LLama2 vs ChatGPT: How They Perform in Question Answering - Zilliz blog: What is Llama 2, and how does it perform in question answering compared to ChatGPT?
- Prof. Pan Yi joins Zilliz Research Asia as an AI Pharmaceutical Scientist - Zilliz Newsroom; Prof. Pan Yi joins Zilliz Research Asia as an AI Pharmaceutical Scientist: Zilliz, the company behind the worldâs most popular vector database Milvus, announced that Dr. Pan Yi joined Zilliz Research Asia (ZRA) as an AI pharmaceutical scientist.
| 4 Commits | ||
---|---|---|---|
|
2 years ago | ||
|
1.1 KiB
|
2 years ago | |
|
4.6 KiB
|
10 months ago | |
|
110 B
|
2 years ago | |
|
7 B
|
2 years ago | |
|
2.8 KiB
|
2 years ago |