Skip to content

Commit 434d11b

Browse files
feat(docs): add the reference guide for the ai engine sdk (#1163)
Co-authored-by: Joshua Croft <[email protected]>
1 parent 90f3164 commit 434d11b

File tree

5 files changed

+695
-2
lines changed

5 files changed

+695
-2
lines changed

.github/spelling/known_words_corpus.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,4 +769,24 @@ chatbot
769769
vectara
770770
premai
771771
prem
772-
runtype
772+
agentmessage
773+
apibasemessage
774+
knownmodelid
775+
custommodel
776+
taskoption
777+
taskselectionmessage
778+
apimessagepayload
779+
confirmationmessage
780+
submitmessage
781+
agentmessage
782+
getcredits
783+
getmodelcredits
784+
knownmodelid
785+
custommodel
786+
taskoption
787+
taskselectionmessage
788+
apimessagepayload
789+
confirmationmessage
790+
apimessage
791+
getmodels
792+
runtype

pages/references/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"uagents": "Agents: uAgents Framework",
44
"agentverse": "Agentverse",
55
"ledger": "Ledger",
6-
"cosmpy": "CosmPy API"
6+
"cosmpy": "CosmPy API",
7+
"ai-engine-sdk": { "title": "Ai Engine SDk", "timestamp": true }
78
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python": { "title": "Python", "timestamp": true },
3+
"javascript": { "title": "Javascript", "timestamp": true }
4+
}
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# src.index
2+
3+
session
4+
5+
## Session Objects [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L82)
6+
7+
```python
8+
class Session()
9+
```
10+
The `Session` class represents an interaction session with the AI engine API, managing messages and function executions within a function group.
11+
12+
**Attributes**
13+
14+
- `_apiBaseUrl` _string_ - The base URL for the AI engine API.
15+
- `_apiKey` _string_ - The API key used for authentication.
16+
- `sessionId` _string_ - The unique identifier for the session.
17+
- `functionGroup` _string_ - The function group associated with the session.
18+
- `_messages` _ApiMessage[]_ - A list of messages associated with the session.
19+
- `_messageIds` _Set of string_ - A set to store unique message IDs to prevent duplication.
20+
21+
**Methods**:
22+
23+
#### Constructor [↗](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L90)
24+
25+
```javascript
26+
constructor(apiBaseUrl: string, apiKey: string, sessionId: string, functionGroup: string)
27+
```
28+
29+
**Parameters**:
30+
- `apiBaseUrl` _string_ - The base URL for the API.
31+
- `apiKey` _string_ - The API key for authentication.
32+
- `sessionId` _string_ - The unique identifier for the session.
33+
- `functionGroup` _string_ - The function group associated with the session.
34+
35+
#### _submitMessage [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L102)
36+
37+
```javascript
38+
async _submitMessage(payload: ApiMessagePayload)
39+
```
40+
Submits a message to the API.
41+
42+
**Parameters**:
43+
- `payload` _ApiMessagePayload_ - The message payload to be submitted.
44+
45+
---
46+
47+
#### start [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L114)
48+
49+
```javascript
50+
async start(objective: string, context?: string)
51+
```
52+
Starts a new session by submitting an initial message.
53+
54+
**Parameters**:
55+
- `objective` _string_ - The primary objective of the session.
56+
- `context` _string, optional_ - Additional context for the session.
57+
58+
---
59+
60+
#### submitTaskSelection [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L125)
61+
62+
```javascript
63+
async submitTaskSelection(selection: TaskSelectionMessage, options: TaskOption[])
64+
```
65+
Submits a message with the selected task.
66+
67+
**Parameters**:
68+
- `selection` _TaskSelectionMessage_ - The selected task message.
69+
- `options` _TaskOption[]_ - List of selected tasks.
70+
71+
---
72+
73+
#### submitResponse [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L141)
74+
75+
```javascript
76+
async submitResponse(query: AgentMessage, response: string)
77+
```
78+
Sends a response to an agent's message.
79+
80+
**Parameters**:
81+
- `query` _AgentMessage_ - The agent's message being responded to.
82+
- `response` _string_ - The user's response.
83+
84+
---
85+
86+
#### submitConfirmation [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L151)
87+
88+
```javascript
89+
async submitConfirmation(confirmation: ConfirmationMessage): Promise<void>
90+
```
91+
Submits a confirmation message.
92+
93+
**Parameters**:
94+
- `confirmation` _(ConfirmationMessage)_ - The confirmation message to be submitted.
95+
96+
---
97+
98+
#### rejectConfirmation [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L161)
99+
100+
```javascript
101+
async rejectConfirmation(confirmation: ConfirmationMessage, reason: string): Promise<void>
102+
```
103+
Rejects a confirmation with a reason.
104+
105+
**Parameters**:
106+
- `confirmation` _(ConfirmationMessage)_ - The confirmation message to be rejected.
107+
- `reason` _(string)_ - The reason for rejection.
108+
109+
---
110+
111+
#### getMessages [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L174)
112+
113+
```javascript
114+
async getMessages(): Promise<Message[]>
115+
```
116+
Retrieves new messages from the chat session.
117+
118+
**Returns**:
119+
- `Message[]` - A list of new messages.
120+
121+
122+
#### delete [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L254)
123+
124+
```javascript
125+
async delete()
126+
```
127+
Deletes the session from the AI engine API.
128+
129+
---
130+
131+
#### execute_function [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L264)
132+
133+
```javascript
134+
async execute_function(functionIds: string[], objective: string, context: string): Promise<void>
135+
```
136+
Executes a set of functions within the AI engine.
137+
138+
**Parameters**:
139+
- `functionIds` _string[]_ - A list of function IDs to execute.
140+
- `objective` _string_ - The objective or goal of executing these functions.
141+
- `context` _string_ - Additional context for execution.
142+
143+
---
144+
145+
## AiEngine Objects [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L278)
146+
147+
```python
148+
class AiEngine()
149+
```
150+
151+
The `AiEngine` class provides methods to interact with the AI engine API, such as retrieving function groups, credits, and models.
152+
153+
**Methods**:
154+
155+
#### Constructor [↗](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L282)
156+
157+
```javascript
158+
constructor(apiKey: string, options?: { apiBaseUrl?: string })
159+
```
160+
161+
**Parameters**:
162+
- `apiKey` _string_ - The API key for authentication.
163+
- `options.apiBaseUrl` _string, optional_ - The base URL for the API (defaults to `https://agentverse.ai`).
164+
165+
---
166+
167+
#### getFunctionGroups [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L287)
168+
169+
```javascript
170+
async getFunctionGroups(): Promise<FunctionGroup[]>
171+
```
172+
Retrieves a list of available function groups.
173+
174+
**Returns**:
175+
- `FunctionGroup[]` - A list of function groups.
176+
177+
---
178+
179+
#### createSession [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L378)
180+
181+
```javascript
182+
async createSession(functionGroup: string, opts?: { email?: string; model?: KnownModelId | string }): Promise<Session>
183+
```
184+
Creates a new session.
185+
186+
**Parameters**:
187+
- `functionGroup` _string_ - The function group to use.
188+
- `opts.email` _string, optional_ - User email.
189+
- `opts.model` _KnownModelId | string, optional_ - The model identifier.
190+
191+
**Returns**:
192+
- `Session` - The created session instance.
193+
194+
195+
#### getCredits [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L316)
196+
197+
```javascript
198+
async getCredits(): Promise<CreditBalance>
199+
```
200+
Retrieves the credit balance information.
201+
202+
**Returns**:
203+
- `CreditBalance` - The total, used, and available credits.
204+
205+
---
206+
207+
#### getModels [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L336)
208+
209+
```javascript
210+
async getModels(): Promise<Model[]>
211+
```
212+
Retrieves a list of models and their associated credits.
213+
214+
**Returns**:
215+
- `Model[]` - A list of available models with their credit balance.
216+
217+
---
218+
219+
#### getModelCredits [](https://github.com/fetchai/ai-engine-sdk-js/blob/main/src/index.ts#L364)
220+
221+
```javascript
222+
async getModelCredits(model: KnownModelId | CustomModel): Promise<number>
223+
```
224+
Retrieves the remaining token balance for a specific model.
225+
226+
**Parameters**:
227+
- `model` _(KnownModelId | CustomModel)_ - The model to retrieve credits for.
228+
229+
**Returns**:
230+
- `number` - The remaining token balance for the model.

0 commit comments

Comments
 (0)