Skip to content

Commit

Permalink
Update to latest API release.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirk-marple committed Dec 7, 2024
1 parent ae1b3c3 commit 558f51c
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 2 deletions.
1 change: 1 addition & 0 deletions documents/content/ExtractContents.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mutation ExtractContents($prompt: String!, $filter: ContentFilter, $specificatio
content {
id
}
name
value
startTime
endTime
Expand Down
16 changes: 16 additions & 0 deletions documents/content/ExtractText.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mutation ExtractText($prompt: String!, $text: String!, $textType: TextTypes, $specification: EntityReferenceInput!, $tools: [ToolDefinitionInput!]!, $correlationId: String) {
extractText(prompt: $prompt, text: $text, textType: $textType, specification: $specification, tools: $tools, correlationId: $correlationId) {
specification {
id
}
content {
id
}
name
value
startTime
endTime
pageNumber
error
}
}
12 changes: 12 additions & 0 deletions graphlit_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,12 @@
ExtractContentsExtractContentsContent,
ExtractContentsExtractContentsSpecification,
)
from .extract_text import (
ExtractText,
ExtractTextExtractText,
ExtractTextExtractTextContent,
ExtractTextExtractTextSpecification,
)
from .format_conversation import (
FormatConversation,
FormatConversationFormatConversation,
Expand Down Expand Up @@ -1325,6 +1331,7 @@
ENABLE_ALERT_GQL,
ENABLE_FEED_GQL,
EXTRACT_CONTENTS_GQL,
EXTRACT_TEXT_GQL,
FORMAT_CONVERSATION_GQL,
GET_ALERT_GQL,
GET_CATEGORY_GQL,
Expand Down Expand Up @@ -2705,6 +2712,7 @@
"ENABLE_ALERT_GQL",
"ENABLE_FEED_GQL",
"EXTRACT_CONTENTS_GQL",
"EXTRACT_TEXT_GQL",
"ElevenLabsModels",
"ElevenLabsPublishingPropertiesInput",
"EmailFeedPropertiesInput",
Expand Down Expand Up @@ -2737,6 +2745,10 @@
"ExtractContentsExtractContents",
"ExtractContentsExtractContentsContent",
"ExtractContentsExtractContentsSpecification",
"ExtractText",
"ExtractTextExtractText",
"ExtractTextExtractTextContent",
"ExtractTextExtractTextSpecification",
"ExtractionWorkflowJobInput",
"ExtractionWorkflowStageInput",
"FHIREnrichmentPropertiesInput",
Expand Down
29 changes: 29 additions & 0 deletions graphlit_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
from .enable_feed import EnableFeed
from .enums import SearchServiceTypes, TextTypes
from .extract_contents import ExtractContents
from .extract_text import ExtractText
from .format_conversation import FormatConversation
from .get_alert import GetAlert
from .get_category import GetCategory
Expand Down Expand Up @@ -442,6 +443,7 @@
ENABLE_ALERT_GQL,
ENABLE_FEED_GQL,
EXTRACT_CONTENTS_GQL,
EXTRACT_TEXT_GQL,
FORMAT_CONVERSATION_GQL,
GET_ALERT_GQL,
GET_CATEGORY_GQL,
Expand Down Expand Up @@ -1181,6 +1183,33 @@ async def extract_contents(
data = self.get_data(response)
return ExtractContents.model_validate(data)

async def extract_text(
self,
prompt: str,
text: str,
specification: EntityReferenceInput,
tools: List[ToolDefinitionInput],
text_type: Union[Optional[TextTypes], UnsetType] = UNSET,
correlation_id: Union[Optional[str], UnsetType] = UNSET,
**kwargs: Any
) -> ExtractText:
variables: Dict[str, object] = {
"prompt": prompt,
"text": text,
"textType": text_type,
"specification": specification,
"tools": tools,
"correlationId": correlation_id,
}
response = await self.execute(
query=EXTRACT_TEXT_GQL,
operation_name="ExtractText",
variables=variables,
**kwargs
)
data = self.get_data(response)
return ExtractText.model_validate(data)

async def get_content(self, id: str, **kwargs: Any) -> GetContent:
variables: Dict[str, object] = {"id": id}
response = await self.execute(
Expand Down
5 changes: 3 additions & 2 deletions graphlit_api/extract_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class ExtractContents(BaseModel):


class ExtractContentsExtractContents(BaseModel):
specification: Optional["ExtractContentsExtractContentsSpecification"]
specification: "ExtractContentsExtractContentsSpecification"
content: Optional["ExtractContentsExtractContentsContent"]
value: Optional[str]
name: str
value: str
start_time: Optional[Any] = Field(alias="startTime")
end_time: Optional[Any] = Field(alias="endTime")
page_number: Optional[int] = Field(alias="pageNumber")
Expand Down
37 changes: 37 additions & 0 deletions graphlit_api/extract_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by ariadne-codegen
# Source: ./documents

from typing import Any, List, Optional

from pydantic import Field

from .base_model import BaseModel


class ExtractText(BaseModel):
extract_text: Optional[List[Optional["ExtractTextExtractText"]]] = Field(
alias="extractText"
)


class ExtractTextExtractText(BaseModel):
specification: "ExtractTextExtractTextSpecification"
content: Optional["ExtractTextExtractTextContent"]
name: str
value: str
start_time: Optional[Any] = Field(alias="startTime")
end_time: Optional[Any] = Field(alias="endTime")
page_number: Optional[int] = Field(alias="pageNumber")
error: Optional[str]


class ExtractTextExtractTextSpecification(BaseModel):
id: str


class ExtractTextExtractTextContent(BaseModel):
id: str


ExtractText.model_rebuild()
ExtractTextExtractText.model_rebuild()
28 changes: 28 additions & 0 deletions graphlit_api/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"ENABLE_ALERT_GQL",
"ENABLE_FEED_GQL",
"EXTRACT_CONTENTS_GQL",
"EXTRACT_TEXT_GQL",
"FORMAT_CONVERSATION_GQL",
"GET_ALERT_GQL",
"GET_CATEGORY_GQL",
Expand Down Expand Up @@ -1103,6 +1104,33 @@
content {
id
}
name
value
startTime
endTime
pageNumber
error
}
}
"""

EXTRACT_TEXT_GQL = """
mutation ExtractText($prompt: String!, $text: String!, $textType: TextTypes, $specification: EntityReferenceInput!, $tools: [ToolDefinitionInput!]!, $correlationId: String) {
extractText(
prompt: $prompt
text: $text
textType: $textType
specification: $specification
tools: $tools
correlationId: $correlationId
) {
specification {
id
}
content {
id
}
name
value
startTime
endTime
Expand Down

0 comments on commit 558f51c

Please sign in to comment.