-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopenapi.yaml
More file actions
158 lines (149 loc) · 5.62 KB
/
Copy pathopenapi.yaml
File metadata and controls
158 lines (149 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
openapi: 3.0.3
info:
title: Chat API
description: |
REST API for chat interactions with an AI agent.
## WebSocket Endpoint
In addition to the REST API, a WebSocket endpoint is available for real-time bidirectional communication:
**Endpoint:** `ws://localhost:8080/ws/chat`
**Headers:**
- `X-Session-ID` (optional): Session identifier for maintaining conversation context. If not provided, a new session will be created.
**Message Format:**
- **Send (Client → Server):** JSON matching the `ChatRequest` schema (without sessionId field)
- **Receive (Server → Client):** JSON matching the `Answer` schema (without sessionId field)
**Example:**
```javascript
const ws = new WebSocket('ws://localhost:8080/ws/chat', {
headers: {
'X-Session-ID': '550e8400-e29b-41d4-a716-446655440000' // Optional
}
});
ws.onopen = () => {
ws.send(JSON.stringify({
message: "Hello!"
}));
};
ws.onmessage = (event) => {
const answer = JSON.parse(event.data);
console.log(answer.message);
};
```
**Note:** Session ID is managed via the `X-Session-ID` header during the WebSocket handshake, not in the message payload.
version: 1.0.0
servers:
- url: http://localhost:8080
description: Local development server
paths:
/api/version:
get:
summary: Get API version
description: Returns the current version of the API
operationId: getVersion
tags:
- chat
responses:
'200':
description: API version
content:
text/plain:
schema:
type: string
example: "1.0"
/api/chat:
post:
summary: Send a chat message
description: Sends a message to the AI agent and receives a response
operationId: chat
tags:
- chat
parameters:
- $ref: '#/components/parameters/SessionIdParam'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatRequest'
responses:
'200':
description: Chat response
headers:
X-Session-ID:
$ref: '#/components/headers/SessionIdHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/Answer'
/api/koog/strategy/graph:
get:
summary: Get strategy graph diagram
description: Returns a Mermaid diagram text representation of the strategy graph
operationId: getStrategyGraph
tags:
- koog
responses:
'200':
description: Mermaid diagram text for strategy graph
content:
text/plain:
schema:
type: string
example: "graph TD\n A[Strategy] --> B[Implementation]\n B --> C[Results]"
components:
parameters:
SessionIdParam:
name: X-Session-ID
in: header
description: Optional session identifier for maintaining conversation context. If not provided, a new session will be created.
required: false
schema:
$ref: '#/components/schemas/ChatSessionId'
headers:
SessionIdHeader:
description: Session identifier for the conversation
schema:
$ref: '#/components/schemas/ChatSessionId'
schemas:
ChatSessionId:
description: Chat Session identifier for the conversation
type: string
pattern: '^[_0-9a-zA-Z-]{1,64}$'
example: "550e8400-e29b-41d4-a716-446655440000"
ChatRequestId:
description: Chat Request identifier
pattern: '^[_0-9a-zA-Z-]{1,64}$'
type: string
ChatRequest:
type: object
required:
- message
properties:
chatRequestId:
$ref: '#/components/schemas/ChatRequestId'
chatSessionId:
$ref: '#/components/schemas/ChatSessionId'
message:
type: string
description: The message to send to the AI agent
example: "How do I implement a REST API in Spring Boot?"
streaming:
type: boolean
default: false
Answer:
type: object
required:
- message
- chatSessionId
- completed
properties:
message:
type: string
description: The AI agent's response
example: "To implement a REST API in Spring Boot, you can use @RestController..."
chatSessionId:
$ref: '#/components/schemas/ChatSessionId'
chatRequestId:
$ref: '#/components/schemas/ChatRequestId'
completed:
type: boolean
description: Is response complete