fix(spec): Update assistant spec
This commit is contained in:
parent
20a5c79c8a
commit
a1a4294dd4
@ -25,34 +25,84 @@ _Users can configure assistant settings_
|
||||
- `assistant.json`
|
||||
> OpenAI Equivalen: https://platform.openai.com/docs/api-reference/assistants/object
|
||||
|
||||
// KIV
|
||||
```shell=
|
||||
/$JANROOT
|
||||
/models
|
||||
/assistants
|
||||
/jarvis # git push http://github.com/abentlen/jarvis
|
||||
# TODO: n assistant to multiple assistants
|
||||
/threads # Package threads with your Assistant
|
||||
/threads
|
||||
```
|
||||
|
||||
- Packaging
|
||||
- An Assistant folder
|
||||
|
||||
```json
|
||||
{
|
||||
// Jan specific properties
|
||||
"avatar": "https://lala.png",
|
||||
"thread_location": "ROOT/threads", // Default to root (optional field)
|
||||
// TODO: add moar
|
||||
|
||||
// OpenAI compatible properties: https://platform.openai.com/docs/api-reference/assistants
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant",
|
||||
"version": 1,
|
||||
"created_at": 1698984975,
|
||||
"name": "Math Tutor",
|
||||
"name": "Math Tutor", // required
|
||||
"description": null,
|
||||
"instructions": "...",
|
||||
"tools": [
|
||||
{
|
||||
"type": "retrieval"
|
||||
},
|
||||
{
|
||||
"type": "web_browsing"
|
||||
}
|
||||
// This one omitted from assistant.json but will be covered in API
|
||||
// "instructions": "", // This is openAI compatible. But it should be passed to model[i] as LLM model
|
||||
// "tools": [
|
||||
// {
|
||||
// "type": "retrieval"
|
||||
// },
|
||||
// {
|
||||
// "type": "web_browsing"
|
||||
// }
|
||||
// ],
|
||||
// "file_ids": [],
|
||||
// "memory": true,
|
||||
// Persistent Memory (remembers all threads, files)
|
||||
// if False, then files, etc are stored at /thread level
|
||||
"models": "*", // Jan - model picker (Default)
|
||||
// v2
|
||||
// If model is specified, then use the below
|
||||
// omitted means default
|
||||
"models": [
|
||||
{ "model_id": "", ..., "parameters": {} }
|
||||
// v2 { "model_id": "", ... }
|
||||
],
|
||||
"file_ids": ["file_id"],
|
||||
"models": ["<model_id>"],
|
||||
// The idea here is for explicitly subscribing to event stream
|
||||
// v3
|
||||
"events"*: {
|
||||
"in": ["assistant:asst_abc123", "jan:*"],
|
||||
"out": ["assistant:asst_abc123", "jan:*"]
|
||||
},
|
||||
// Alternate: Simplified version?
|
||||
"events": "*",
|
||||
"events": [
|
||||
"onMessage",
|
||||
"onThread",
|
||||
{ id: "onMessage", type: "out" } // Event configs
|
||||
]
|
||||
// "threads": [<thread_folder_id>] // Helpful for look up under ~/jan/thread/*
|
||||
"metadata": {}
|
||||
}
|
||||
```
|
||||
|
||||
### Assistant example src/index.ts
|
||||
```typescript
|
||||
import {events, models} from "@janhq/core"
|
||||
import {retrieval} from "@hiro/best-rag-ever" // This can be featured on Jan hub but install from npm
|
||||
|
||||
events.on('assistant:asst_abc123', (event) => async {
|
||||
const result = models[0].process(event)
|
||||
events.emit("assistant:asst_abc123", result)
|
||||
resolve()
|
||||
})
|
||||
```
|
||||
|
||||
### Assistant lifecycle
|
||||
Assistant has 4 states (enum)
|
||||
- `to_download`
|
||||
@ -68,173 +118,126 @@ Assistant has 4 states (enum)
|
||||
|
||||
### Get list assistants
|
||||
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/listAssistants
|
||||
- Example request
|
||||
```shell
|
||||
curl {JAN_URL}/v1/assistants?order=desc&limit=20 \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant",
|
||||
"created_at": 1698982736,
|
||||
"name": "Coding Tutor",
|
||||
"description": null,
|
||||
"models": ["model_zephyr_7b", "azure-openai-gpt4-turbo"],
|
||||
"instructions": "You are a helpful assistant designed to make me better at coding!",
|
||||
"tools": [],
|
||||
"file_ids": [],
|
||||
"metadata": {},
|
||||
"state": "ready"
|
||||
},
|
||||
],
|
||||
"first_id": "asst_abc123",
|
||||
"last_id": "asst_abc789",
|
||||
"has_more": false
|
||||
}
|
||||
```
|
||||
|
||||
### Get assistant
|
||||
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/getAssistant
|
||||
- Example request
|
||||
```shell
|
||||
curl {JAN_URL}/v1/assistants/{assistant_id} \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
{
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant",
|
||||
"created_at": 1699009709,
|
||||
"name": "HR Helper",
|
||||
"description": null,
|
||||
"models": ["model_zephyr_7b", "azure-openai-gpt4-turbo"],
|
||||
"instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
|
||||
"tools": [
|
||||
{
|
||||
"type": "retrieval"
|
||||
}
|
||||
],
|
||||
"file_ids": [
|
||||
"file-abc123"
|
||||
],
|
||||
"metadata": {},
|
||||
"state": "ready"
|
||||
}
|
||||
```
|
||||
|
||||
### Create an assistant
|
||||
Create an assistant with models and instructions.
|
||||
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/createAssistant
|
||||
- Example request
|
||||
```shell
|
||||
curl -X POST {JAN_URL}/v1/assistants \
|
||||
-H "Content-Type: application/json" \
|
||||
-d {
|
||||
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
|
||||
"name": "Math Tutor",
|
||||
"tools": [{"type": "retrieval"}],
|
||||
"model": ["model_zephyr_7b", "azure-openai-gpt4-turbo"]
|
||||
}
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
{
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant",
|
||||
"created_at": 1698984975,
|
||||
"name": "Math Tutor",
|
||||
"description": null,
|
||||
"model": ["model_zephyr_7b", "azure-openai-gpt4-turbo"]
|
||||
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
|
||||
"tools": [
|
||||
{
|
||||
"type": "retrieval"
|
||||
}
|
||||
],
|
||||
"file_ids": [],
|
||||
"metadata": {},
|
||||
"state": "ready"
|
||||
}
|
||||
```
|
||||
|
||||
### Modify an assistant
|
||||
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/modifyAssistant
|
||||
- Example request
|
||||
```shell
|
||||
curl -X POST {JAN_URL}/v1/assistants/{assistant_id} \
|
||||
-H "Content-Type: application/json" \
|
||||
-d {
|
||||
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
|
||||
"name": "Math Tutor",
|
||||
"tools": [{"type": "retrieval"}],
|
||||
"model": ["model_zephyr_7b", "azure-openai-gpt4-turbo"]
|
||||
}
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
{
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant",
|
||||
"created_at": 1698984975,
|
||||
"name": "Math Tutor",
|
||||
"description": null,
|
||||
"model": ["model_zephyr_7b", "azure-openai-gpt4-turbo"]
|
||||
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
|
||||
"tools": [
|
||||
{
|
||||
"type": "retrieval"
|
||||
}
|
||||
],
|
||||
"file_ids": [],
|
||||
"metadata": {},
|
||||
"state": "ready"
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Assistant
|
||||
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/deleteAssistant
|
||||
`- Example request
|
||||
```shell
|
||||
curl -X DELETE {JAN_URL}/v1/assistant/model-zephyr-7B
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
{
|
||||
"id": "asst_abc123",
|
||||
"object": "assistant.deleted",
|
||||
"deleted": true,
|
||||
"state": "to_download"
|
||||
}
|
||||
```
|
||||
|
||||
## Assistants Filesystem
|
||||
|
||||
```sh
|
||||
/assistants
|
||||
/jan
|
||||
assistant.json # Assistant configs (see below)
|
||||
```shell
|
||||
/jan
|
||||
/models/
|
||||
/threads/
|
||||
threads-1/ # jan
|
||||
thread-<>/ # chicken
|
||||
thread-2/ # multi-assistant (v22)
|
||||
/assistants
|
||||
/jan
|
||||
assistant.json # Assistant configs (see below)
|
||||
|
||||
# For any custom code
|
||||
package.json # Import npm modules
|
||||
# e.g. Langchain, Llamaindex
|
||||
/src # Supporting files (needs better name)
|
||||
index.js # Entrypoint
|
||||
process.js # For electron IPC processes (needs better name)
|
||||
# For any custom code
|
||||
package.json # Import npm modules
|
||||
# e.g. Langchain, Llamaindex
|
||||
/src # Supporting files (needs better name)
|
||||
index.js # Entrypoint
|
||||
process.js # For electron IPC processes (needs better name)
|
||||
|
||||
# `/threads` at root level
|
||||
# `/models` at root level
|
||||
/shakespeare
|
||||
assistant.json
|
||||
package.json
|
||||
/src
|
||||
index.js
|
||||
process.js
|
||||
|
||||
/threads # Assistants remember conversations in the future
|
||||
/models # Users can upload custom models
|
||||
/finetuned-model
|
||||
# `/threads` at root level
|
||||
# `/models` at root level
|
||||
/shakespeare
|
||||
assistant.json
|
||||
package.json
|
||||
/src
|
||||
index.js
|
||||
process.js
|
||||
/threads # if developer specifies
|
||||
/chicken
|
||||
```
|
||||
|
||||
### Example
|
||||
- Jan Assistant json
|
||||
TBU
|
||||
- Custom assistant json
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Swagger file
|
||||
|
||||
```yaml
|
||||
AssistantObject:
|
||||
type: object
|
||||
properties:
|
||||
avatar:
|
||||
type: string
|
||||
description: "URL of the assistant's avatar. Jan-specific property."
|
||||
example: "https://lala.png"
|
||||
id:
|
||||
type: string
|
||||
description: "The identifier of the assistant."
|
||||
example: "asst_abc123"
|
||||
object:
|
||||
type: string
|
||||
description: "Type of the object, indicating it's an assistant."
|
||||
default: "assistant"
|
||||
version:
|
||||
type: integer
|
||||
description: "Version number of the assistant."
|
||||
example: 1
|
||||
created_at:
|
||||
type: integer
|
||||
format: int64
|
||||
description: "Unix timestamp representing the creation time of the assistant."
|
||||
name:
|
||||
type: string
|
||||
description: "Name of the assistant."
|
||||
example: "Math Tutor"
|
||||
description:
|
||||
type: string
|
||||
description: "Description of the assistant. Can be null."
|
||||
models:
|
||||
type: array
|
||||
description: "List of models associated with the assistant. Jan-specific property."
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
model_id:
|
||||
type: string
|
||||
# Additional properties for models can be added here
|
||||
events:
|
||||
type: object
|
||||
description: "Event subscription settings for the assistant."
|
||||
properties:
|
||||
in:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
out:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
# If there are specific event types, they can be detailed here
|
||||
metadata:
|
||||
type: object
|
||||
description: "Metadata associated with the assistant."
|
||||
required:
|
||||
- name
|
||||
- models
|
||||
- events
|
||||
```
|
||||
@ -69,7 +69,7 @@ const sidebars = {
|
||||
"specs/models",
|
||||
"specs/threads",
|
||||
"specs/messages",
|
||||
// "specs/assistants",
|
||||
"specs/assistants",
|
||||
// "specs/files",
|
||||
// "specs/jan",
|
||||
// "specs/fine-tuning",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user