Skip to content

Commit

Permalink
fix: add variants for box ai (box/box-openapi#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Aug 19, 2024
1 parent 508e27e commit f97fd14
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "4ca165c", "specHash": "871a814", "version": "1.2.0" }
{ "engineHash": "4ca165c", "specHash": "8d1ca31", "version": "1.2.0" }
6 changes: 3 additions & 3 deletions box_sdk_gen/managers/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from box_sdk_gen.schemas.ai_dialogue_history import AiDialogueHistory

from box_sdk_gen.schemas.ai_ask_response import AiAskResponse
from box_sdk_gen.schemas.ai_response_full import AiResponseFull

from box_sdk_gen.schemas.client_error import ClientError

Expand Down Expand Up @@ -143,7 +143,7 @@ def create_ai_ask(
include_citations: Optional[bool] = None,
ai_agent: Optional[AiAgentAsk] = None,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> AiAskResponse:
) -> AiResponseFull:
"""
Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context.
:param mode: The mode specifies if this request is for a single or multiple items. If you select `single_item_qa` the `items` array can have one element only. Selecting `multiple_item_qa` allows you to provide up to 25 items.
Expand Down Expand Up @@ -186,7 +186,7 @@ def create_ai_ask(
network_session=self.network_session,
),
)
return deserialize(response.data, AiAskResponse)
return deserialize(response.data, AiResponseFull)

def create_ai_text_gen(
self,
Expand Down
2 changes: 1 addition & 1 deletion box_sdk_gen/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@

from box_sdk_gen.schemas.ai_citation import *

from box_sdk_gen.schemas.ai_ask_response import *
from box_sdk_gen.schemas.ai_response_full import *

from box_sdk_gen.schemas.ai_dialogue_history import *

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@

from typing import List

from box_sdk_gen.internal.base_object import BaseObject
from box_sdk_gen.internal.utils import DateTime

from box_sdk_gen.schemas.ai_citation import AiCitation
from box_sdk_gen.schemas.ai_response import AiResponse

from box_sdk_gen.internal.utils import DateTime
from box_sdk_gen.schemas.ai_citation import AiCitation


class AiAskResponse(BaseObject):
class AiResponseFull(AiResponse):
def __init__(
self,
answer: str,
created_at: DateTime,
*,
completion_reason: Optional[str] = None,
citations: Optional[List[AiCitation]] = None,
completion_reason: Optional[str] = None,
**kwargs
):
"""
:param answer: The answer provided by the LLM.
:type answer: str
:param created_at: The ISO date formatted timestamp of when the answer to the prompt was created.
:type created_at: DateTime
:param completion_reason: The reason the response finishes., defaults to None
:type completion_reason: Optional[str], optional
:param citations: The citations of the LLM's answer reference., defaults to None
:type citations: Optional[List[AiCitation]], optional
:param completion_reason: The reason the response finishes., defaults to None
:type completion_reason: Optional[str], optional
"""
super().__init__(**kwargs)
self.answer = answer
self.created_at = created_at
self.completion_reason = completion_reason
super().__init__(
answer=answer,
created_at=created_at,
completion_reason=completion_reason,
**kwargs
)
self.citations = citations
2 changes: 1 addition & 1 deletion docs/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ client.ai.create_ai_ask(

### Returns

This function returns a value of type `AiAskResponse`.
This function returns a value of type `AiResponseFull`.

A successful response including the answer from the LLM.

Expand Down
4 changes: 2 additions & 2 deletions docs/integration_mappings.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# IntegrationMappingsManager

- [List Slack integration mappings](#list-slack-integration-mappings)
- [Create Slack integration mapping](#create-slack-integration-mapping)
- [Create integration mapping](#create-integration-mapping)
- [Update Slack integration mapping](#update-slack-integration-mapping)
- [Delete Slack integration mapping](#delete-slack-integration-mapping)

Expand Down Expand Up @@ -48,7 +48,7 @@ This function returns a value of type `IntegrationMappings`.

Returns a collection of integration mappings

## Create Slack integration mapping
## Create integration mapping

Creates a [Slack integration mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack)
by mapping a Slack channel to a Box item.
Expand Down
6 changes: 3 additions & 3 deletions test/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from box_sdk_gen.schemas.file_full import FileFull

from box_sdk_gen.schemas.ai_ask_response import AiAskResponse
from box_sdk_gen.schemas.ai_response_full import AiResponseFull

from box_sdk_gen.managers.ai import CreateAiAskMode

Expand Down Expand Up @@ -46,7 +46,7 @@ def testAskAISingleItem():
GetAiAgentDefaultConfigMode.ASK.value, language='en-US'
)
file_to_ask: FileFull = upload_new_file()
response: AiAskResponse = client.ai.create_ai_ask(
response: AiResponseFull = client.ai.create_ai_ask(
CreateAiAskMode.SINGLE_ITEM_QA.value,
'which direction sun rises',
[
Expand All @@ -66,7 +66,7 @@ def testAskAISingleItem():
def testAskAIMultipleItems():
file_to_ask_1: FileFull = upload_new_file()
file_to_ask_2: FileFull = upload_new_file()
response: AiAskResponse = client.ai.create_ai_ask(
response: AiResponseFull = client.ai.create_ai_ask(
CreateAiAskMode.MULTIPLE_ITEM_QA.value,
'Which direction sun rises?',
[
Expand Down

0 comments on commit f97fd14

Please sign in to comment.