Skip to content

Commit 351a5b8

Browse files
feat: Add ai_agent info to AiResponse (box/box-openapi#485) (#402)
1 parent 1c54bf5 commit 351a5b8

File tree

7 files changed

+76
-9
lines changed

7 files changed

+76
-9
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "f073ce3", "specHash": "544d370", "version": "1.8.0" }
1+
{ "engineHash": "a839036", "specHash": "d7dfe68", "version": "1.8.0" }

box_sdk_gen/managers/ai.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,10 @@ def create_ai_extract(
373373
"""
374374
Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
375375
376-
Freeform metadata extraction does not require any metadata template setup before sending the request.
376+
In this request, both the prompt and the output can be freeform.
377+
378+
379+
Metadata template setup before sending the request is not required.
377380
378381
:param prompt: The prompt provided to a Large Language Model (LLM) in the request. The prompt can be up to 10000 characters long and it can be an XML or a JSON schema.
379382
:type prompt: str
@@ -414,7 +417,10 @@ def create_ai_extract_structured(
414417
"""
415418
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
416419
417-
For this request, you need to use an already defined metadata template or a define a schema yourself.
420+
For this request, you either need a metadata template or a list of fields you want to extract.
421+
422+
423+
Input is **either** a metadata template or a list of fields to ensure the structure.
418424
419425
420426
To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates)

box_sdk_gen/schemas/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
from box_sdk_gen.schemas.ai_agent_info import *
2+
3+
from box_sdk_gen.schemas.ai_response import *
4+
15
from box_sdk_gen.schemas.ai_citation import *
26

7+
from box_sdk_gen.schemas.ai_response_full import *
8+
39
from box_sdk_gen.schemas.ai_dialogue_history import *
410

511
from box_sdk_gen.schemas.ai_extract_response import *
@@ -40,10 +46,6 @@
4046

4147
from box_sdk_gen.schemas.ai_ask import *
4248

43-
from box_sdk_gen.schemas.ai_response import *
44-
45-
from box_sdk_gen.schemas.ai_response_full import *
46-
4749
from box_sdk_gen.schemas.app_item import *
4850

4951
from box_sdk_gen.schemas.classification import *
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from typing import Optional
2+
3+
from box_sdk_gen.internal.base_object import BaseObject
4+
5+
from typing import List
6+
7+
from box_sdk_gen.box.errors import BoxSDKError
8+
9+
10+
class AiAgentInfoModelsField(BaseObject):
11+
def __init__(
12+
self,
13+
*,
14+
name: Optional[str] = None,
15+
provider: Optional[str] = None,
16+
supported_purpose: Optional[str] = None,
17+
**kwargs
18+
):
19+
"""
20+
:param name: The name of the model used for the request, defaults to None
21+
:type name: Optional[str], optional
22+
:param provider: The provider that owns the model used for the request, defaults to None
23+
:type provider: Optional[str], optional
24+
:param supported_purpose: The supported purpose utilized by the model used for the request, defaults to None
25+
:type supported_purpose: Optional[str], optional
26+
"""
27+
super().__init__(**kwargs)
28+
self.name = name
29+
self.provider = provider
30+
self.supported_purpose = supported_purpose
31+
32+
33+
class AiAgentInfo(BaseObject):
34+
def __init__(
35+
self,
36+
*,
37+
models: Optional[List[AiAgentInfoModelsField]] = None,
38+
processor: Optional[str] = None,
39+
**kwargs
40+
):
41+
"""
42+
:param models: The models used for the request, defaults to None
43+
:type models: Optional[List[AiAgentInfoModelsField]], optional
44+
:param processor: The processor used for the request, defaults to None
45+
:type processor: Optional[str], optional
46+
"""
47+
super().__init__(**kwargs)
48+
self.models = models
49+
self.processor = processor

box_sdk_gen/schemas/ai_response.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from box_sdk_gen.internal.base_object import BaseObject
44

5+
from box_sdk_gen.schemas.ai_agent_info import AiAgentInfo
6+
57
from box_sdk_gen.box.errors import BoxSDKError
68

79
from box_sdk_gen.internal.utils import DateTime
@@ -14,6 +16,7 @@ def __init__(
1416
created_at: DateTime,
1517
*,
1618
completion_reason: Optional[str] = None,
19+
ai_agent_info: Optional[AiAgentInfo] = None,
1720
**kwargs
1821
):
1922
"""
@@ -28,3 +31,4 @@ def __init__(
2831
self.answer = answer
2932
self.created_at = created_at
3033
self.completion_reason = completion_reason
34+
self.ai_agent_info = ai_agent_info

box_sdk_gen/schemas/ai_response_full.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from box_sdk_gen.internal.utils import DateTime
66

7+
from box_sdk_gen.schemas.ai_agent_info import AiAgentInfo
8+
79
from box_sdk_gen.schemas.ai_response import AiResponse
810

911
from box_sdk_gen.schemas.ai_citation import AiCitation
@@ -19,6 +21,7 @@ def __init__(
1921
*,
2022
citations: Optional[List[AiCitation]] = None,
2123
completion_reason: Optional[str] = None,
24+
ai_agent_info: Optional[AiAgentInfo] = None,
2225
**kwargs
2326
):
2427
"""
@@ -35,6 +38,7 @@ def __init__(
3538
answer=answer,
3639
created_at=created_at,
3740
completion_reason=completion_reason,
41+
ai_agent_info=ai_agent_info,
3842
**kwargs
3943
)
4044
self.citations = citations

docs/ai.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ This response can be one of the following four objects:
159159
## Extract metadata (freeform)
160160

161161
Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
162-
Freeform metadata extraction does not require any metadata template setup before sending the request.
162+
In this request, both the prompt and the output can be freeform.
163+
Metadata template setup before sending the request is not required.
163164

164165
This operation is performed by calling function `create_ai_extract`.
165166

@@ -196,7 +197,8 @@ A response including the answer from the LLM.
196197
## Extract metadata (structured)
197198

198199
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
199-
For this request, you need to use an already defined metadata template or a define a schema yourself.
200+
For this request, you either need a metadata template or a list of fields you want to extract.
201+
Input is **either** a metadata template or a list of fields to ensure the structure.
200202
To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates)
201203
or use the [metadata template API](g://metadata/templates/create).
202204

0 commit comments

Comments
 (0)