Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openai chatapi docs and bug fixes #581

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions chatapi.rest
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
POST http://localhost:5080/chatapi/v1/chat
POST http://localhost:5080/chatapi/v1/chats
Content-Type: application/json

{
"title" : "Hello",
"_experient_id": "63f6e4987c5f93004a3e3ca8",
"title" : "Another Chat with experiment id",
"_experiment_id": "63f6e4987c5f93004a3e3ca8",
"_dataset_id": "63f6e4947c5f93004a3e3ca7"
}

###

POST http://localhost:5080/chatapi/v1/chatlog/
GET http://localhost:5080/chatapi/v1/chats

###

GET http://localhost:5080/chatapi/v1/chats/63ffb16342f8d8282acbcc8d

###

PATCH http://localhost:5080/chatapi/v1/chats/63ffb16342f8d8282acbcc6d
Content-Type: application/json

{
"_chat_id" : "63f6e54fc76ccd8396386d03",
"message" : "Hello there from cyberspace!",
"message_type" : "text",
"who" : "openai"
"title" : "Chat with no experiment id",
"_experiment_id": "63f6e4987c5f93004a3e3ca8",
"_dataset_id": "63f6e4947c5f93004a3e3ca7"
}

###

GET http://localhost:5080/chatapi/v1/chat
DELETE http://localhost:5080/chatapi/v1/chats/63ffb16342f8d8282acbcc8d

###
POST http://localhost:5080/chatapi/v1/chatlogs
Content-Type: application/json

GET http://localhost:5080/chatapi/v1/chat/63f6e54fc76ccd8396386d03
{
"_chat_id" : "63ffb16342f8d8282acbcc8d",
"message" : "Hello there from cyberspace!",
"message_type" : "text",
"who" : "openai"
}

###

PATCH http://localhost:5080/chatapi/v1/chatlogs/63ffc80142f8d8282acbccb6
Content-Type: application/json

{
"message" : "Hello from cyberspace!",
"message_type" : "text",
"who" : "openai"
}
6 changes: 4 additions & 2 deletions docker-compose-doc-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ services:

doc_api_builder:
image: "node:18.13.0-slim"
command: bash -c "npm i -g raml2html && raml2html /appsrc/lab/api.raml >
/appsrc/target/ai_docs/html/lab_api_source.html"
command: bash -c "npm i -g raml2html &&
raml2html /appsrc/lab/api.raml > /appsrc/target/ai_docs/html/lab_api_source.html &&
raml2html /appsrc/docs/APIs/openai.raml > /appsrc/target/ai_docs/html/openai_source.html &&
raml2html /appsrc/docs/APIs/chatapi.raml > /appsrc/target/ai_docs/html/chatapi_source.html"
volumes:
- "./:/appsrc"
12 changes: 12 additions & 0 deletions docs/APIs/DataTypes/chat.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#%RAML 1.0 DataType

type: object
properties:
title:
type: string
_dataset_id:
type: string
_experiment_id?:
type: string
date:
type: datetime
16 changes: 16 additions & 0 deletions docs/APIs/DataTypes/chatlog.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%RAML 1.0 DataType

type: object
properties:
_chat_id:
type: string
message:
type: string
message_type:
type: string
source_code?:
type: string
who:
type: string
date:
type: datetime
8 changes: 8 additions & 0 deletions docs/APIs/DataTypes/config.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#%RAML 1.0 DataType

type: object
properties:
api_key:
type: string
org_id?:
type: string
6 changes: 6 additions & 0 deletions docs/APIs/Examples/Chatlogs/CreateText.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#%RAML 1.0 NamedExample
_chat_id: "63f7bc2da70e99abe4e83b9c"
message: "Hello"
message_type: "text"
who: "TestUser"
date: "2023-02-28T17:30:00.000Z"
6 changes: 6 additions & 0 deletions docs/APIs/Examples/Chatlogs/GetOneSource.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#%RAML 1.0 NamedExample
_chat_id: "63f7bc2da70e99abe4e83b9c"
message_type: "code"
source_code: "import pandas as pd"
who: "openai"
date: "2023-02-28T17:30:10.000Z"
8 changes: 8 additions & 0 deletions docs/APIs/Examples/Chatlogs/GetOneText.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#%RAML 1.0 NamedExample
_id: "6144c03406a0c0a9d9f9d91c"
_chat_id: "63f7bc2da70e99abe4e83b9c"
message: "Hello"
message_type: "text"
who: "TestUser"
date: "2023-02-28T17:30:03.000Z"
__v: 0
4 changes: 4 additions & 0 deletions docs/APIs/Examples/Chats/Create.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#%RAML 1.0 NamedExample
title: "Fist Chat"
_dataset_id: "5f92cbf10cf217478ba93561"
_experiment_id: "6143e3e906a0c0a9d9f9d91a"
15 changes: 15 additions & 0 deletions docs/APIs/Examples/Chats/GetAll.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#%RAML 1.0 NamedExample
-
_id: "63f7bc2da70e99abe4e83b9c"
title: "Fist Chat"
_dataset_id: "5f92cbf10cf217478ba93561"
_experiment_id: "6143e3e906a0c0a9d9f9d91a"
date: "2023-02-28T17:30:00.000Z"
__v: 0
-
_id: "6143e6f506a0c0a9d9f9d91b"
title: "Second Chat"
_dataset_id: "5f92cbf10cf217478ba93561"
_experiment_id: "6143e3e906a0c0a9d9f9d91a"
date: "2023-02-28T17:30:10.000Z"
__v: 0
7 changes: 7 additions & 0 deletions docs/APIs/Examples/Chats/GetOne.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#%RAML 1.0 NamedExample
_id: "63f7bc2da70e99abe4e83b9c"
title: "Fist Chat"
_dataset_id: "5f92cbf10cf217478ba93561"
_experiment_id: "6143e3e906a0c0a9d9f9d91a"
date: "2023-02-28T17:30:00.000Z"
__v: 0
7 changes: 7 additions & 0 deletions docs/APIs/Examples/Chats/GetOneChat.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#%RAML 1.0 NamedExample
chat: !include GetOne.raml
chatlogs:
-
!include ../Chatlogs/GetOneText.raml
-
!include ../Chatlogs/GetOneSource.raml
3 changes: 3 additions & 0 deletions docs/APIs/Examples/Configs/Create.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#%RAML 1.0 NamedExample
api_key: "1a2b3c4d5e6f7g8h9i0j"
org_id: "Personal"
6 changes: 6 additions & 0 deletions docs/APIs/Examples/Configs/GetAll.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#%RAML 1.0 NamedExample
-
_id: "63f7bc2da70e99abe4e83b9c"
api_key: "1a2b3c4d5e6f7g8h9i0j"
org_id: "Personal"
__v: 0
5 changes: 5 additions & 0 deletions docs/APIs/Examples/Configs/GetOne.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#%RAML 1.0 NamedExample
_id: "63f7bc2da70e99abe4e83b9c"
api_key: "1a2b3c4d5e6f7g8h9i0j"
org_id: "Personal"
__v: 0
141 changes: 141 additions & 0 deletions docs/APIs/chatapi.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#%RAML 1.0
---
title: Chat API
version: v1
baseUri: http://localhost:5080/chatapi/{version}
mediaType: application/json
types:
Chat: !include DataTypes/chat.raml
Chatlog: !include DataTypes/chatlog.raml

/chats:
get:
description: Retrieve all chats
responses:
200:
body:
application/json:
type: Chat[]
example: !include Examples/Chats/GetAll.raml
500:
body:
application/json:
type: object
example: { message: 'Failed to connect to database' }
post:
description: Create a chat
body:
application/json:
type: Chat
example: !include Examples/Chats/Create.raml
responses:
201:
body:
application/json:
type: Chat
example: !include Examples/Chats/GetOne.raml
400:
body:
application/json:
type: object
example: { message: 'Must provide a _dataset_id' }
/{id}:
get:
description: Retrieve a specific chat and all it's associated chatlogs
responses:
200:
body:
application/json:
type: object
example: !include Examples/Chats/GetOneChat.raml
404:
body:
application/json:
type: object
example: { message: 'Cannot find chat: 63f7bc2da70e99abe4e83b9c' }
500:
body:
application/json:
type: object
example: { message: 'Failed to connect to database' }
patch:
description: Update a specific chat
body:
application/json:
type: Chat
example: !include Examples/Chats/Create.raml
responses:
200:
body:
application/json:
type: Chat
example: !include Examples/Chats/GetOne.raml
400:
body:
application/json:
type: object
example: { message: 'Error message' }
404:
body:
application/json:
type: object
example: { message: 'Cannot find chat: 63f7bc2da70e99abe4e83b9c' }
delete:
description: Delete a specific chat and all it's associated chatlogs
responses:
200:
body:
application/json:
type: object
example: { message: 'Deleted chat 63f7bc2da70e99abe4e83b9c'}
404:
body:
application/json:
type: object
example: { message: 'Cannot find chat: 63f7bc2da70e99abe4e83b9c' }
500:
body:
application/json:
type: object
example: { message: 'Failed to connect to database' }
/chatlogs:
post:
description: Create a chat log entry
body:
application/json:
type: Chatlog
example: !include Examples/Chatlogs/CreateText.raml
responses:
201:
body:
application/json:
type: Chatlog
example: !include Examples/Chatlogs/GetOneText.raml
400:
body:
application/json:
type: object
example: { message: 'Must provide a _chat_id' }
/{id}:
patch:
description: Update a specific chatlog entry
body:
application/json:
type: Chatlog
example: !include Examples/Chatlogs/CreateText.raml
responses:
200:
body:
application/json:
type: Chatlog
example: !include Examples/Chatlogs/GetOneText.raml
400:
body:
application/json:
type: object
example: { message: 'Cannot update _chat_id' }
404:
body:
application/json:
type: object
example: { message: 'Cannot find chatlog: 6144c03406a0c0a9d9f9d91c' }
Loading