Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
feat(instill): adopt latest Instill Model protobufs
Browse files Browse the repository at this point in the history
  • Loading branch information
donch1989 committed Sep 4, 2024
1 parent ff0eb06 commit 739cc04
Show file tree
Hide file tree
Showing 36 changed files with 1,873 additions and 1,250 deletions.
39 changes: 3 additions & 36 deletions ai/instill/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ It can carry out the following tasks:
- [Text Generation Chat](#text-generation-chat)
- [Text To Image](#text-to-image)
- [Visual Question Answering](#visual-question-answering)
- [Image To Image](#image-to-image)



Expand Down Expand Up @@ -182,11 +181,8 @@ Generate texts from input text prompts.
| Model Name (required) | `model-name` | string | The Instill Model model to be used. |
| Prompt (required) | `prompt` | string | The prompt text |
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Prompt Images | `prompt-images` | array[string] | The prompt images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
| Max new tokens | `max-new-tokens` | integer | The maximum number of tokens for model to generate |


Expand Down Expand Up @@ -215,7 +211,6 @@ Generate texts from input text prompts and chat history.
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
| Max new tokens | `max-new-tokens` | integer | The maximum number of tokens for model to generate |


Expand All @@ -239,10 +234,10 @@ Generate images from input text prompts.
| Task ID (required) | `task` | string | `TASK_TEXT_TO_IMAGE` |
| Model Name (required) | `model-name` | string | The Instill Model model to be used. |
| Prompt (required) | `prompt` | string | The prompt text |
| CFG Scale | `cfg-scale` | number | The guidance scale, default is 7.5 |
| Samples | `samples` | integer | The number of generated samples, default is 1 |
| Seed | `seed` | integer | The seed, default is 0 |
| Steps | `steps` | integer | The steps, default is 5 |
| Aspect ratio | `negative-prompt` | string | Keywords of what you do not wish to see in the output image. |
| Aspect ratio | `aspect-ratio` | string | Controls the aspect ratio of the generated image. Defaults to 1:1. |



Expand All @@ -266,11 +261,10 @@ Answer questions based on a prompt and an image.
| Model Name (required) | `model-name` | string | The Instill Model model to be used. |
| Prompt (required) | `prompt` | string | The prompt text |
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Prompt Images (required) | `prompt-images` | array[string] | The prompt images |
| Prompt Images | `prompt-images` | array[string] | The prompt images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
| Max new tokens | `max-new-tokens` | integer | The maximum number of tokens for model to generate |


Expand All @@ -284,31 +278,4 @@ Answer questions based on a prompt and an image.



### Image To Image

Generate image from input text prompt and image.


| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_IMAGE_TO_IMAGE` |
| Model Name (required) | `model-name` | string | The Instill Model model to be used. |
| Prompt (required) | `prompt` | string | The prompt text |
| Prompt Image (required) | `image-base64` | string | The prompt image |
| CFG Scale | `cfg-scale` | number | The guidance scale, default is 7.5 |
| Seed | `seed` | integer | The seed |
| Samples | `samples` | integer | The number of generated samples, default is 1 |
| Top K | `top-k` | integer | Top k for sampling |



| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Images | `images` | array[string] | Images |







3 changes: 2 additions & 1 deletion ai/instill/v0/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/structpb"

"github.com/instill-ai/component/internal/util"
modelPB "github.com/instill-ai/protogen-go/model/model/v1alpha"
Expand All @@ -36,7 +37,7 @@ func initModelPublicServiceClient(serverURL string) (modelPB.ModelPublicServiceC
return modelPB.NewModelPublicServiceClient(clientConn), clientConn
}

func trigger(gRPCClient modelPB.ModelPublicServiceClient, vars map[string]any, nsID string, modelID string, version string, taskInputs []*modelPB.TaskInput) ([]*modelPB.TaskOutput, error) {
func trigger(gRPCClient modelPB.ModelPublicServiceClient, vars map[string]any, nsID string, modelID string, version string, taskInputs []*structpb.Struct) ([]*structpb.Struct, error) {

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
Expand Down
3 changes: 1 addition & 2 deletions ai/instill/v0/config/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"TASK_TEXT_GENERATION",
"TASK_TEXT_GENERATION_CHAT",
"TASK_TEXT_TO_IMAGE",
"TASK_VISUAL_QUESTION_ANSWERING",
"TASK_IMAGE_TO_IMAGE"
"TASK_VISUAL_QUESTION_ANSWERING"
],
"custom": false,
"documentationUrl": "https://www.instill.tech/docs/component/ai/instill",
Expand Down
Loading

0 comments on commit 739cc04

Please sign in to comment.