-
Notifications
You must be signed in to change notification settings - Fork 18
ResponseType
This ResponseType is a link in the Chain since many can be related to a project.
They get passed in a Project
and a ResponseDto
and return a ResponseDto
The output might be the final output to a "ChatUI" or an "Api"
For example it could go from "User Request in UI -> Embed Question Response Type -> Search Vectors Response Type -> Chat OpenAI RepsonseType (which streams the results)"
Simple way to get started is to run
php artisan larachain:response_type:create
Then you will be asked a few things
Just the name of the ResponseType in my example it is a "StringReplacer"
Let the person know what is does
This will [COMING SOON] generate a update/edit route so you can then update the needed fields on the model.
The two fields are meta_data
and prompt_token
in my example my meta_data
might look like this
{
"search": [
"foo",
"bar"
],
"replace": [
"baz",
"boo"
]
}
You can then make sure the generated Controller does the updates and validation and the generated Vuejs files will handle the UI
app/ResponseType/Types/VectorSearch.php
This will take the Embedding in the Message model and search, it will return the results in the ResponseDto
app/ResponseType/Types/EmbedQuestion.php
This will take the Message model content
and use that for make an embed out of it and save it back to embedding
app/ResponseType/Types/CombineContent.php
This will take the ResponseDto content
and iterate over it to shorten it for token usage. This is good to use after search results of VectorSearch
app/ResponseType/Types/ChatUi.php
This will take the ResponseDto content
and do a few things
- See if there is a System message
- If not it will make one with the prompt related to the ResponseType (see below PromptToken explained)
- Create assistant message before and after if needed
app/ResponseType/Types/ChatApi.php
You can quickly create a Fortify based api endpoint for applications to talk to your data. You can see it in action here
We are using this library https://github.com/alnutile/larachain-prompt-templates
I will show how it is attached to the ResposeType
form shortly