Skip to content

Commit d89f788

Browse files
authored
Merge pull request #30 from togethercomputer/add-reranker
Add reranker API to spec
2 parents e989277 + 1d0dd8b commit d89f788

File tree

1 file changed

+178
-2
lines changed

1 file changed

+178
-2
lines changed

openapi.yaml

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,61 @@ paths:
509509
description: Invalid request parameters.
510510
'404':
511511
description: Fine-tune ID not found.
512-
512+
/rerank:
513+
post:
514+
tags: ['Rerank']
515+
summary: Create a rerank request
516+
description: Query a reranker model
517+
operationId: rerank
518+
requestBody:
519+
content:
520+
application/json:
521+
schema:
522+
$ref: '#/components/schemas/RerankRequest'
523+
responses:
524+
'200':
525+
description: '200'
526+
content:
527+
application/json:
528+
schema:
529+
$ref: '#/components/schemas/RerankResponse'
530+
'400':
531+
description: 'BadRequest'
532+
content:
533+
application/json:
534+
schema:
535+
$ref: '#/components/schemas/ErrorData'
536+
'401':
537+
description: 'Unauthorized'
538+
content:
539+
application/json:
540+
schema:
541+
$ref: '#/components/schemas/ErrorData'
542+
'404':
543+
description: 'NotFound'
544+
content:
545+
application/json:
546+
schema:
547+
$ref: '#/components/schemas/ErrorData'
548+
'429':
549+
description: 'RateLimit'
550+
content:
551+
application/json:
552+
schema:
553+
$ref: '#/components/schemas/ErrorData'
554+
'503':
555+
description: 'Overloaded'
556+
content:
557+
application/json:
558+
schema:
559+
$ref: '#/components/schemas/ErrorData'
560+
'504':
561+
description: 'Timeout'
562+
content:
563+
application/json:
564+
schema:
565+
$ref: '#/components/schemas/ErrorData'
566+
deprecated: false
513567
components:
514568
securitySchemes:
515569
bearerAuth:
@@ -519,6 +573,128 @@ components:
519573
x-default: default
520574

521575
schemas:
576+
RerankRequest:
577+
type: object
578+
properties:
579+
model:
580+
type: string
581+
description: The model to be used for the rerank request.
582+
example: Salesforce/Llama-Rank-V1
583+
query:
584+
type: string
585+
description: The search query to be used for ranking.
586+
example: 'What animals can I find near Peru?'
587+
documents:
588+
description: List of documents, which can be either strings or objects.
589+
oneOf:
590+
- type: array
591+
items:
592+
type: object
593+
additionalProperties: true
594+
- type: array
595+
items:
596+
type: string
597+
example: Our solar system orbits the Milky Way galaxy at about 515,000 mph
598+
example:
599+
- {
600+
'title': 'Llama',
601+
'text': 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.',
602+
}
603+
- {
604+
'title': 'Panda',
605+
'text': 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.',
606+
}
607+
- {
608+
'title': 'Guanaco',
609+
'text': 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.',
610+
}
611+
- {
612+
'title': 'Wild Bactrian camel',
613+
'text': 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.',
614+
}
615+
top_n:
616+
type: integer
617+
description: The number of top results to return.
618+
example: 2
619+
return_documents:
620+
type: boolean
621+
description: Whether to return supplied documents with the response.
622+
example: true
623+
rank_fields:
624+
type: array
625+
items:
626+
type: string
627+
description: List of keys in the JSON Object document to rank by. Defaults to use all supplied keys for ranking.
628+
example: ['title', 'text']
629+
required:
630+
- model
631+
- query
632+
- documents
633+
additionalProperties: false
634+
635+
RerankResponse:
636+
type: object
637+
required:
638+
- object
639+
- model
640+
- results
641+
properties:
642+
object:
643+
type: string
644+
description: Object type
645+
enum:
646+
- rerank
647+
example: rerank
648+
id:
649+
type: string
650+
description: Request ID
651+
example: 9dfa1a09-5ebc-4a40-970f-586cb8f4ae47
652+
model:
653+
type: string
654+
description: The model to be used for the rerank request.
655+
example: salesforce/turboranker-0.8-3778-6328
656+
results:
657+
type: array
658+
items:
659+
type: object
660+
required: [index, relevance_score, document]
661+
properties:
662+
index:
663+
type: integer
664+
relevance_score:
665+
type: number
666+
document:
667+
type: object
668+
properties:
669+
text:
670+
type: string
671+
nullable: true
672+
example:
673+
- {
674+
'index': 0,
675+
'relevance_score': 0.29980177813003117,
676+
'document':
677+
{
678+
'text': '{"title":"Llama","text":"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."}',
679+
},
680+
}
681+
- {
682+
'index': 2,
683+
'relevance_score': 0.2752447527354349,
684+
'document':
685+
{
686+
'text': '{"title":"Guanaco","text":"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."}',
687+
},
688+
}
689+
usage:
690+
$ref: '#/components/schemas/UsageData'
691+
example:
692+
{
693+
'prompt_tokens': 1837,
694+
'completion_tokens': 0,
695+
'total_tokens': 1837,
696+
}
697+
522698
ErrorData:
523699
type: object
524700
required:
@@ -1141,7 +1317,7 @@ components:
11411317
type: string
11421318
required:
11431319
- arguments
1144-
- name
1320+
- name
11451321
usage:
11461322
allOf:
11471323
- $ref: '#/components/schemas/UsageData'

0 commit comments

Comments
 (0)