Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
feat: Add Archetype AI connector (#113)
Browse files Browse the repository at this point in the history
![CleanShot 2024-01-24 at 15 30
05](https://github.com/instill-ai/connector/assets/3977183/53f54b07-99f1-4a0b-8d3e-de87562b62a2)


![CleanShot 2024-01-24 at 15 29
01](https://github.com/instill-ai/connector/assets/3977183/62b2604f-6499-4033-b2f0-355da50064b5)

![CleanShot 2024-01-24 at 15 27
29](https://github.com/instill-ai/connector/assets/3977183/3c161633-b0be-4761-bc0e-a080b81157ae)


Because

- We want to support Archetype AI API in VDP

This commit

- Adds Archetype AI connector with summarize, describe and upload tasks

## Notes 🗒️ 

In order to have a working prototype early, some parts were left out of
the feature:
- [ ] Connector should be documented in
[instill.tech](https://www.instill.tech/docs/latest/vdp/ai-connector) ->
Should be done as part of the auto-doc discussion.
- [ ] We're lacking an icon for the connector -> Design will take care
of that.
- [ ] API offers an "upload by S3 link" endpoint which isn't supported
here -> future implementation.
  • Loading branch information
jvallesm authored Jan 26, 2024
1 parent c1f68ef commit d12b6f8
Show file tree
Hide file tree
Showing 13 changed files with 946 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Currently, we support these AI vendors:

| Name | Vendor | Supported Tasks |
|--------------------|----------------------------------------------------------|-----------------|
| ai-archetype-ai | [Archetype AI](https://www.archetypeai.io/) | Image summarization, Video description |
| ai-instill-model | [Instill Model](https://instill.tech/) | Classification, Instance-Segmentation, Keypoint, Detection, OCR, Semantic-Segmentation, Text-Generation, Text-to-Image|
| ai-openai | [OpenAI](https://openai.com) | Text-Generation, Speech-Recognition, Text-Embedding
| ai-openai | [OpenAI](https://openai.com) | Text-Generation, Speech-Recognition, Text-Embedding |
| ai-stability-ai | [Stability AI](https://stability.ai/) | Text-to-Image, Image-to-Image |
| airbyte-* | [Aiybyte](https://airbyte.com/) | WriteDestination |
| data-pinecone | [Pinecone](https://www.pinecone.io/) | Upsert, Query |
Expand Down
33 changes: 33 additions & 0 deletions pkg/archetypeai/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package archetypeai

import (
"github.com/instill-ai/connector/pkg/util/httpclient"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/structpb"
)

const (
host = "https://api.archetypeai.dev"
describePath = "/v0.3/describe"
summarizePath = "/v0.3/summarize"
uploadFilePath = "/v0.3/files"
)

func newClient(config *structpb.Struct, logger *zap.Logger) *httpclient.Client {
c := httpclient.New("Archetype AI", getBasePath(config),
httpclient.WithLogger(logger),
httpclient.WithEndUserError(new(errBody)),
)

c.SetAuthToken(getAPIKey(config))

return c
}

type errBody struct {
Error string `json:"error"`
}

func (e errBody) Message() string {
return e.Error
}
42 changes: 42 additions & 0 deletions pkg/archetypeai/config/definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"available_tasks": [
"TASK_DESCRIBE",
"TASK_SUMMARIZE",
"TASK_UPLOAD_FILE"
],
"custom": false,
"documentation_url": "",
"icon": "Instill AI/website.svg",
"icon": "Archetype AI/archetypeai.svg",
"icon_url": "",
"id": "archetype-ai",
"public": true,
"spec": {
"resource_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"api_key": {
"description": "Fill your Archetype AI API key",
"instillCredentialField": true,
"instillUIOrder": 0,
"title": "API Key",
"type": "string"
}
},
"required": [
"api_key"
],
"title": "Archetype AI Connector Specification",
"type": "object"
}
},
"title": "Archetype AI",
"tombstone": false,
"type": "CONNECTOR_TYPE_AI",
"uid": "e414a1f8-5fdf-4292-b050-9f9176254a4b",
"vendor": "Archetype AI",
"vendor_attributes": {}
}
]
201 changes: 201 additions & 0 deletions pkg/archetypeai/config/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"TASK_DESCRIBE": {
"input": {
"instillUIOrder": 0,
"properties": {
"query": {
"description": "A guide to describe the video",
"instillAcceptFormats": [
"string"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"title": "Query",
"type": "string"
},
"file_ids": {
"description": "The IDs of the videos to describe. These must have been previously uploaded via TASK_UPLOAD_FILE.",
"instillAcceptFormats": [
"array:string"
],
"instillUIOrder": 1,
"instillUpstreamTypes": [
"value",
"reference"
],
"items": {
"instillUIMultiline": false,
"type": "string"
},
"minItems": 1,
"title": "File IDs",
"type": "array"
}
},
"required": [
"query",
"file_ids"
],
"title": "Input",
"type": "object"
},
"output": {
"instillUIOrder": 0,
"properties": {
"descriptions": {
"description": "A set of descriptions corresponding to different moments in the video",
"instillUIOrder": 0,
"title": "Descriptions",
"type": "array",
"items": {
"title": "Frame description",
"type": "object",
"properties": {
"frame_id": {
"description": "The frame number in the video that is being described",
"instillFormat": "integer",
"instillUIOrder": 3,
"required": [],
"title": "Frame ID",
"type": "integer"
},
"timestamp": {
"description": "The moment of the video (in seconds since the start) that is being described",
"instillFormat": "number",
"instillUIOrder": 1,
"title": "Timestamp",
"type": "number"
},
"description": {
"description": "The description of the frame",
"instillFormat": "string",
"instillUIOrder": 2,
"title": "Description",
"type": "string"
}
},
"required": [
"description",
"timestamp",
"frame_id"
]
}
}
},
"required": [
"descriptions"
],
"title": "Output",
"type": "object"
}
},
"TASK_SUMMARIZE": {
"input": {
"instillUIOrder": 0,
"properties": {
"query": {
"description": "A guide to summarize the image",
"instillAcceptFormats": [
"string"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"title": "Query",
"type": "string"
},
"file_ids": {
"description": "The IDs of the images to summarize. These must have been previously uploaded via TASK_UPLOAD_FILE.",
"instillAcceptFormats": [
"array:string"
],
"instillUIOrder": 1,
"instillUpstreamTypes": [
"value",
"reference"
],
"items": {
"instillUIMultiline": false,
"type": "string"
},
"minItems": 1,
"title": "File IDs",
"type": "array"
}
},
"required": [
"query",
"file_ids"
],
"title": "Input",
"type": "object"
},
"output": {
"instillUIOrder": 0,
"properties": {
"response": {
"description": "A text responding to the query",
"instillFormat": "string",
"instillUIOrder": 0,
"title": "Response",
"type": "string"
}
},
"required": [
"response"
],
"title": "Output",
"type": "object"
}
},
"TASK_UPLOAD_FILE": {
"input": {
"instillUIOrder": 0,
"properties": {
"file": {
"title": "File",
"description": "The file to upload. Accepted formats are JPEG and PNG for images or MP4 for videos",
"type": "string",
"instillAcceptFormats": [
"image/*"
],
"instillUIOrder": 0,
"instillUpstreamTypes": [
"reference"
]
}
},
"required": [
"file"
],
"title": "Input",
"type": "object"
},
"output": {
"instillUIOrder": 0,
"properties": {
"file_id": {
"instillFormat": "string",
"instillUIOrder": 0,
"title": "File ID",
"description": "The ID to reference the file in queries",
"type": "string"
}
},
"required": [
"file_id"
],
"title": "Output",
"type": "object"
}
}
}
Loading

0 comments on commit d12b6f8

Please sign in to comment.