ChatPremAI
langchain
and premai-sdk
. You can type the following command to install:
project_id
is 8
. But make sure you use your project-id, otherwise it will throw error.
To use langchain with prem, you do not need to pass any model name or set any parameters with our chat-client. By default it will use the model name and parameters used in the LaunchPad.
Note: If you change themodel
or any other parameters liketemperature
ormax_tokens
while setting the client, it will override existing default configurations, that was used in LaunchPad.
ChatPremAI
supports two methods: invoke
(which is the same as generate
) and stream
.
The first one will give us a static result. Whereas the second one will stream tokens one by one. Here’s how you can generate chat-like completions.
Always sound like a pirate
You can also, override the default system prompt if you need to. Here’s how you can do it.
If you are going to place system prompt here, then it will override your system prompt that was fixed while deploying the application from the platform.
Please note: Similar likeNow, we connect the repository with our chat object to invoke RAG based generations.model_name
when you invoke the argumentrepositories
, then you are potentially overriding the repositories connected in the launchpad.
Ideally, you do not need to connect Repository IDs here to get Retrieval Augmented Generations. You can still get the same result if you have connected the repositories in prem platform.
HumanMessage
. This id should be the name the variable of your prompt template. the content
in HumanMessage
should be the value of that variable.
let’s say for example, if your prompt template was this:
human_messages
to ChatPremAI Client. Please note: Do not forget to
pass the additional template_id
to invoke generation with Prem Templates. If you are not aware of template_id
you can learn more about that in our docs. Here is an example:
bind_tools
method to convert our above functions to a “tool” and binding it with the model. This means we are going to pass these tool informations everytime we invoke the model.
tool
decorator, however we can equivalently define the schema using Pydantic. Pydantic is useful when your tool inputs are more complex: