Skip to content

Commit

Permalink
🔧 Update standalone chat detections API (foundation-model-stack#211)
Browse files Browse the repository at this point in the history
* 🔧 Update standalone chat detections API

Signed-off-by: Evaline Ju <[email protected]>

* 🔧 Update chat detector API

Signed-off-by: Evaline Ju <[email protected]>

* 🔥 Remove unused schemas

Signed-off-by: Evaline Ju <[email protected]>

* 🔧 Support only whole chat history

Signed-off-by: Evaline Ju <[email protected]>

---------

Signed-off-by: Evaline Ju <[email protected]>
  • Loading branch information
evaline-ju authored Sep 30, 2024
1 parent c03af66 commit 448b425
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 97 deletions.
80 changes: 11 additions & 69 deletions docs/api/openapi_detector_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ paths:
post:
summary: Chat Analysis Unary Handler
description: >-
Detectors that work on analysis chat history and provide detections <br>
Detectors that analyze chat messages and provide detections <br>
operationId: chat_analysis_unary_handler_api_v1_text_context_chat_post
parameters:
- name: detector-id
Expand Down Expand Up @@ -146,12 +146,9 @@ paths:
Response Chat Analysis Unary Handler Api V1 Text Context Chat
Post
example:
- detection: quantity_1
detection_type: dummy_detector_type
score: 0.68
- detection: quantity_2
detection_type: dummy_detector_type
score: 0.79
- detection: "detection_type"
detection_type: "dummy_detector_type"
score: 0.99
'404':
description: Resource Not Found
content:
Expand Down Expand Up @@ -229,23 +226,16 @@ components:
schemas:
ChatAnalysisHttpRequest:
properties:
chat_history:
items:
$ref: '#/components/schemas/Message'
messages:
title: Chat Messages
type: array
title: Chat History
example:
- content: You are a helpful assistant.
author: system
- content: Hi, is this powered by siri or alexa?
author: user
- content: Better, it's watsonx
author: assistant
- content: This is awesome!
author: user
items:
allOf:
- $ref: https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml#/components/schemas/ChatCompletionRequestMessage
- type: object
type: object
required:
- chat_history
- messages
title: ChatAnalysisHttpRequest
ChatAnalysisResponse:
properties:
Expand Down Expand Up @@ -459,54 +449,6 @@ components:
required:
- code
- message
Message:
properties:
author:
allOf:
- $ref: '#/components/schemas/AuthorEnum'
description: 'Who wrote the message: [<enum ''AuthorEnum''>]'
content:
type: string
title: Content
description: The text of the message
type: object
required:
- author
- content
title: Message
AuthorEnum:
type: string
enum:
- system
- assistant
- user
title: AuthorEnum
description: >-
A collection of name/value pairs.
Access them by:
- attribute access::
>>> AuthorEnum.system <AuthorEnum.system: 'system'>
- value lookup:
>>> AuthorEnum('system') <AuthorEnum.system: 'system'>
- name lookup:
>>> AuthorEnum['system'] <AuthorEnum.system: 'system'>
Enumerations can be iterated over, and know how many members they have:
>>> len(AuthorEnum) 3
>>> list(AuthorEnum) [<AuthorEnum.system: 'system'>, <AuthorEnum.assistant:
'assistant'>, <AuthorEnum.user: 'user'>]
Methods can be added to enumerations, and members can have their own
attributes -- see the documentation for details.
ContentAnalysisHttpRequest:
properties:
contents:
Expand Down
38 changes: 10 additions & 28 deletions docs/api/orchestrator_openapi_0_1_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ paths:
post:
tags:
- Task - Detection
summary: Detection task on input chat
summary: Detection task on entire history of chat messages
operationId: >-
api_v2_detection_text_chat_unary_handler
requestBody:
Expand Down Expand Up @@ -433,37 +433,18 @@ components:
default: {}
example:
chat-v1-model-en: {}
chat_history:
messages:
title: Chat Messages
type: array
title: Chat History
default: {}
minItems: 1
items:
$ref: '#/components/schemas/ChatHistoryObject'
example:
- content: "Hi, is this powered by siri or alexa?"
author: "user"
- content: "Better, it's watsonx"
author: "assistant"
- content: "You are a helpful assistant."
author: "system"
allOf:
- $ref: https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml#/components/schemas/ChatCompletionRequestMessage
- type: object
additionalProperties: false
required: ["detectors", "chat_history"]
required: ["detectors", "messages"]
type: object
title: Chat Detection Request
ChatHistoryObject:
properties:
content:
type: string
title: Content
default: ""
example: "Hi I am AI Agent"
author:
type: string
title: Author
default: ""
example: "assistant"
title: Chat History Object
required: ["content", "author"]
DetectionChatResponse:
properties:
detections:
Expand All @@ -481,7 +462,8 @@ components:
score:
type: number
title: Score
title: Detection Chat Response
title: Detections on entire history of chat messages
title: Chat Detection Response
required: ["detections"]

DetectionContextDocsRequest:
Expand Down

0 comments on commit 448b425

Please sign in to comment.