This repository has been archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Archetype AI connector (#113)
![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
Showing
13 changed files
with
946 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": {} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
Oops, something went wrong.