Skip to content

Commit ad7aa08

Browse files
authored
feat: migrate Conversations API to FastAPI router (#4342)
# What does this PR do? Convert the Conversations API from the legacy @webmethod decorator system to FastAPI routers, following the established pattern from the Batches API. The only notable difference is that now the conversations API is properly listed when inspecting routes. Fixes: #4341 ## Test Plan Unit and integration tests: ``` export OPENAI_API_KEY=****** ./scripts/integration-tests.sh --stack-config http://localhost:8321 --subdirs conversations --setup gpt ``` Also, inspect endpoint: ``` curl http://localhost:8321/v1/inspect/routes | jq '.data[] | select(.route | contains("conversa"))' % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 10382 100 10382 0 0 611k 0 --:--:-- --:--:-- --:--:-- 633k { "route": "/v1/conversations", "method": "POST", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}", "method": "GET", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}", "method": "POST", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}", "method": "DELETE", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}/items", "method": "POST", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}/items/{item_id}", "method": "GET", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}/items", "method": "GET", "provider_types": [] } { "route": "/v1/conversations/{conversation_id}/items/{item_id}", "method": "DELETE", "provider_types": [] } ``` Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent 574ce38 commit ad7aa08

File tree

16 files changed

+1683
-612
lines changed

16 files changed

+1683
-612
lines changed

client-sdks/stainless/openapi.yml

Lines changed: 207 additions & 89 deletions
Large diffs are not rendered by default.

docs/static/deprecated-llama-stack-spec.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,14 +2774,17 @@ components:
27742774
title: OpenAIResponseMessage-Input | ... (9 variants)
27752775
type: array
27762776
- type: 'null'
2777+
description: Initial items to include in the conversation context.
27772778
metadata:
27782779
anyOf:
27792780
- additionalProperties:
27802781
type: string
27812782
type: object
27822783
- type: 'null'
2784+
description: Set of key-value pairs that can be attached to an object.
27832785
type: object
27842786
title: CreateConversationRequest
2787+
description: Request model for creating a conversation.
27852788
Conversation:
27862789
properties:
27872790
id:
@@ -2826,10 +2829,12 @@ components:
28262829
type: string
28272830
type: object
28282831
title: Metadata
2832+
description: Set of key-value pairs that can be attached to an object.
28292833
type: object
28302834
required:
28312835
- metadata
28322836
title: UpdateConversationRequest
2837+
description: Request model for updating a conversation's metadata.
28332838
ConversationDeletedResource:
28342839
properties:
28352840
id:
@@ -2952,11 +2957,14 @@ components:
29522957
web_search_call: '#/components/schemas/OpenAIResponseOutputMessageWebSearchToolCall'
29532958
title: OpenAIResponseMessage-Input | ... (9 variants)
29542959
type: array
2960+
maxItems: 20
29552961
title: Items
2962+
description: Items to include in the conversation context. You may add up to 20 items at a time.
29562963
type: object
29572964
required:
29582965
- items
29592966
title: AddItemsRequest
2967+
description: Request model for adding items to a conversation.
29602968
ConversationItemDeletedResource:
29612969
properties:
29622970
id:
@@ -10790,6 +10798,100 @@ components:
1079010798
- items
1079110799
title: ConversationItemCreateRequest
1079210800
type: object
10801+
GetConversationRequest:
10802+
description: Request model for getting a conversation by ID.
10803+
properties:
10804+
conversation_id:
10805+
description: The conversation identifier.
10806+
title: Conversation Id
10807+
type: string
10808+
required:
10809+
- conversation_id
10810+
title: GetConversationRequest
10811+
type: object
10812+
DeleteConversationRequest:
10813+
description: Request model for deleting a conversation.
10814+
properties:
10815+
conversation_id:
10816+
description: The conversation identifier.
10817+
title: Conversation Id
10818+
type: string
10819+
required:
10820+
- conversation_id
10821+
title: DeleteConversationRequest
10822+
type: object
10823+
RetrieveItemRequest:
10824+
description: Request model for retrieving a conversation item.
10825+
properties:
10826+
conversation_id:
10827+
description: The conversation identifier.
10828+
title: Conversation Id
10829+
type: string
10830+
item_id:
10831+
description: The item identifier.
10832+
title: Item Id
10833+
type: string
10834+
required:
10835+
- conversation_id
10836+
- item_id
10837+
title: RetrieveItemRequest
10838+
type: object
10839+
ListItemsRequest:
10840+
description: Request model for listing items in a conversation.
10841+
properties:
10842+
conversation_id:
10843+
description: The conversation identifier.
10844+
title: Conversation Id
10845+
type: string
10846+
after:
10847+
anyOf:
10848+
- type: string
10849+
- type: 'null'
10850+
description: An item ID to list items after, used in pagination.
10851+
nullable: true
10852+
include:
10853+
anyOf:
10854+
- items:
10855+
$ref: '#/components/schemas/ConversationItemInclude'
10856+
type: array
10857+
- type: 'null'
10858+
description: Specify additional output data to include in the response.
10859+
nullable: true
10860+
limit:
10861+
anyOf:
10862+
- type: integer
10863+
- type: 'null'
10864+
description: A limit on the number of objects to be returned (1-100, default 20).
10865+
nullable: true
10866+
order:
10867+
anyOf:
10868+
- enum:
10869+
- asc
10870+
- desc
10871+
type: string
10872+
- type: 'null'
10873+
description: The order to return items in (asc or desc, default desc).
10874+
nullable: true
10875+
required:
10876+
- conversation_id
10877+
title: ListItemsRequest
10878+
type: object
10879+
DeleteItemRequest:
10880+
description: Request model for deleting a conversation item.
10881+
properties:
10882+
conversation_id:
10883+
description: The conversation identifier.
10884+
title: Conversation Id
10885+
type: string
10886+
item_id:
10887+
description: The item identifier.
10888+
title: Item Id
10889+
type: string
10890+
required:
10891+
- conversation_id
10892+
- item_id
10893+
title: DeleteItemRequest
10894+
type: object
1079310895
ProcessFileResponse:
1079410896
description: |-
1079510897
Response model for file processing operation.

0 commit comments

Comments
 (0)