Skip to content

Commit d23b333

Browse files
Make the schema compatible with azure's gpt
1 parent 6b63f85 commit d23b333

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • python/LlmSpeechSummarization/llm_speech_summarization_component

python/LlmSpeechSummarization/llm_speech_summarization_component/schema.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,43 @@
2424
# limitations under the License. #
2525
#############################################################################
2626

27-
from pydantic import BaseModel, Field
27+
from pydantic import BaseModel, Field, ConfigDict
2828
from typing import List
2929

3030
class EntitiesObject(BaseModel):
3131
"""
3232
An object containing lists of entities of interest that are present in your input.
3333
3434
COMBINATION_INSTRUCTION: In your output, lists of strings (entities, topics, etc.) should each be the union of the corresponding fields in your input objects.
35+
COMBINATION_INSTRUCTION: when combining multiple EntitiesObject objects, treat each field on it as a set of unique strings")
3536
"""
37+
model_config = ConfigDict(extra='forbid')
3638
names_of_people: List[str] = Field(
37-
default=[],
3839
title="Unique names of people referred to in your input",
3940
description="CLARIFICATION: only include people referred to in the conversation. Unless the speakers use each others' names or refer to each other somehow in an utterance, do not include the speakers."
4041
)
41-
places: List[str] = Field(default=[], title="Unique places referred to in your input")
42-
companies: List[str] = Field(default=[], title="Unique names of companies, businesses, and/or institutions in your input")
43-
body_parts: List[str] = Field(default=[], title="Unique parts of the human body named in your input")
44-
emotions: List[str] = Field(default=[], title="Unique emotions, feelings, and/or sentiments referred to in your input")
42+
places: List[str] = Field(title="Unique places referred to in your input")
43+
companies: List[str] = Field(title="Unique names of companies, businesses, and/or institutions in your input")
44+
body_parts: List[str] = Field(title="Unique parts of the human body named in your input")
45+
emotions: List[str] = Field(title="Unique emotions, feelings, and/or sentiments referred to in your input")
4546

4647
class Classifier(BaseModel):
4748
"""
4849
One classifier object
4950
5051
COMBINATION_INSTRUCTION: You must combine classifiers with the same name, such that classifier names are unique in your output. Combine confidences and reasonings, with higher confidence inputs (and the corresponding reasonings) receiving precedence.
5152
"""
53+
model_config = ConfigDict(extra='forbid')
5254
classifier: str = Field(title='name', description="the name of this classifier")
5355
confidence: float = Field(title='confidence', description='How confident you are in the presence or absence of this classifier in the input you are summarizing', ge=0, le=1)
5456
reasoning: str = Field(title='reasoning', description="INSTRUCTION: If the definition of this classifier included a 'Specific Items of Interest' appendage, please make sure to note the presence of any of those specific items of interest in this field, independent of their inclusion or exclusion in any entities category. COMBINATION INSTRUCTION: include the union of your inputs' items of interest in your output's reasoning.")
5557

5658
class StructuredResponse(BaseModel):
59+
model_config = ConfigDict(extra='forbid')
5760
summary: str = Field(title='summary of conversation', description="INSTRUCTION: summarize the conversation with one or more precise, declarative statements about the gestalt of the conversation. COMBINATION_INSTRUCTION: only combine the summaries of your input. Do not cross-contaminate your summary with any other pieces of your input objects.")
5861
primary_topic: str = Field(title='The primary topic of conversation')
5962
other_topics: List[str] = Field(title='Other topics of conversation', description="INSTRUCTION: do not include the primary_topic in this list")
6063
classifiers: List[Classifier] = Field(title='A list of classifier results', description="INSTRUCTION: produce based on the Classifiers between <classifiers></classifiers>. Do not create or infer new classifier categories that are not specified below. Include all classifier categories in your response, even those that have very low confidence.")
61-
entities: EntitiesObject = Field(title='Entities identified in your input', description="COMBINATION_INSTRUCTION: when combining multiple json objects, treat each field on the entities object as a set of unique strings")
64+
entities: EntitiesObject
6265

6366
response_format_json_schema = StructuredResponse.model_json_schema()

0 commit comments

Comments
 (0)