Skip to content

Commit 5354087

Browse files
committed
Addressed comments
1 parent ee2e8ba commit 5354087

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed

azure/functions/decorators/function_app.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,10 @@ def decorator():
14451445

14461446
def assistant_skill_trigger(self,
14471447
arg_name: str,
1448-
task_description: str,
1448+
function_description: str,
1449+
function_name : Optional[str] = None,
1450+
parameter_description_json: Optional[str] = None, # NoQA
1451+
model: Optional[OpenAIModels] = OpenAIModels.DefaultChatModel, # NoQA
14491452
data_type: Optional[
14501453
Union[DataType, str]] = None,
14511454
**kwargs: Any) -> Callable[..., Any]:
@@ -1459,16 +1462,22 @@ def assistant_skill_trigger(self,
14591462
You can define functions that can be triggered by assistants by using
14601463
14611464
the `assistantSkillTrigger` trigger binding. These functions are
1462-
invoked by the extension when a assistant signals that it would like
1465+
invoked by the extension when an assistant signals that it would like
14631466
to invoke a function in response to a user prompt.
14641467
14651468
The name of the function, the description provided by the trigger,
14661469
and the parameter name are all hints that the underlying language model
14671470
use to determine when and how to invoke an assistant function.
14681471
1469-
:param arg_name: The name of the variable that represents
1472+
:param arg_name: The name of trigger parameter in the function code.
14701473
:param function_description: The description of the assistant function,
14711474
which is provided to the model.
1475+
:param function_name: The assistant function, which is provided to the
1476+
LLM.
1477+
:param parameter_description_json: A JSON description of the function
1478+
parameter, which is provided to the LLM.
1479+
If no description is provided, the description will be autogenerated.
1480+
:param model: The OpenAI chat model to use.
14721481
:param data_type: Defines how Functions runtime should treat the
14731482
parameter value.
14741483
:param kwargs: Keyword arguments for specifying additional binding
@@ -1483,7 +1492,7 @@ def decorator():
14831492
fb.add_trigger(
14841493
trigger=AssistantSkillTrigger(
14851494
name=arg_name,
1486-
function_description=task_description,
1495+
function_description=function_description,
14871496
data_type=parse_singular_param_to_enum(data_type,
14881497
DataType),
14891498
**kwargs))
@@ -2813,8 +2822,7 @@ def text_completion_input(self,
28132822
the function, which then returns the result text as the response
28142823
content.
28152824
2816-
:param arg_name: The name of the variable that represents DaprState
2817-
output object in function code.
2825+
:param arg_name: The name of binding parameter in the function code.
28182826
:param prompt: The prompt to generate completions for, encoded as a
28192827
string.
28202828
:param model: the ID of the model to use.
@@ -2867,8 +2875,7 @@ def assistant_create_output(self, arg_name: str,
28672875
The assistantCreate output binding creates a new assistant with a
28682876
specified system prompt.
28692877
2870-
:param arg_name: The name of the variable that represents DaprState
2871-
output object in function code.
2878+
:param arg_name: The name of binding parameter in the function code.
28722879
:param data_type: Defines how Functions runtime should treat the
28732880
parameter value
28742881
:param kwargs: Keyword arguments for specifying additional binding
@@ -2904,8 +2911,7 @@ def assistant_query_input(self,
29042911
The assistantQuery input binding fetches the assistant history and
29052912
passes it to the function.
29062913
2907-
:param arg_name: The name of the variable that represents DaprState
2908-
output object in function code.
2914+
:param arg_name: The name of binding parameter in the function code.
29092915
:param timestamp_utc: the timestamp of the earliest message in the chat
29102916
history to fetch. The timestamp should be in ISO 8601 format - for
29112917
example, 2023-08-01T00:00:00Z.
@@ -2947,8 +2953,7 @@ def assistant_post_input(self, arg_name: str,
29472953
The assistantPost output binding sends a message to the assistant and
29482954
saves the response in its internal state.
29492955
2950-
:param arg_name: The name of the variable that represents DaprState
2951-
output object in function code.
2956+
:param arg_name: The name of binding parameter in the function code.
29522957
:param id: The ID of the assistant to update.
29532958
:param user_message: The user message that user has entered for
29542959
assistant to respond to.
@@ -2992,12 +2997,11 @@ def embeddings_input(self,
29922997
-> Callable[..., Any]:
29932998
"""
29942999
The embeddings input decorator creates embeddings which will be used to
2995-
measure the readiness of text strings.
3000+
measure the relatedness of text strings.
29963001
29973002
Ref: https://platform.openai.com/docs/guides/embeddings
29983003
2999-
:param arg_name: The name of the variable that represents DaprState
3000-
output object in function code.
3004+
:param arg_name: The name of binding parameter in the function code.
30013005
:param input: The input source containing the data to generate
30023006
embeddings for.
30033007
:param input_type: The type of the input.
@@ -3048,13 +3052,17 @@ def semantic_search_input(self,
30483052
**kwargs) \
30493053
-> Callable[..., Any]:
30503054
"""
3051-
The embeddings input decorator creates embeddings which will be used to
3052-
measure the readiness of text strings.
3055+
The semantic search feature allows you to import documents into a
3056+
vector database using an output binding and query the documents in that
3057+
database using an input binding. For example, you can have a function
3058+
that imports documents into a vector database and another function that
3059+
issues queries to OpenAI using content stored in the vector database as
3060+
context (also known as the Retrieval Augmented Generation, or RAG
3061+
technique).
30533062
30543063
Ref: https://platform.openai.com/docs/guides/embeddings
30553064
3056-
:param arg_name: The name of the variable that represents DaprState
3057-
output object in function code.
3065+
:param arg_name: The name of binding parameter in the function code.
30583066
:param connection_name: app setting or environment variable which
30593067
contains a connection string value.
30603068
:param collection: The name of the collection or table to search or
@@ -3064,7 +3072,7 @@ def semantic_search_input(self,
30643072
The default value is "text-embedding-ada-002".
30653073
:param chat_model: The name of the Large Language Model to invoke for
30663074
chat responses. The default value is "gpt-3.5-turbo".
3067-
:param system_prompt: Optional The system prompt to use for prompting
3075+
:param system_prompt: Optional. The system prompt to use for prompting
30683076
the large language model.
30693077
:param max_knowledge_count: Optional. The number of knowledge items to
30703078
inject into the SystemPrompt. Default value: 1
@@ -3121,8 +3129,7 @@ def embeddings_store_output(self,
31213129
- Azure Data Explorer
31223130
- Azure Cosmos DB using MongoDB
31233131
3124-
:param arg_name: The name of the variable that represents DaprState
3125-
output object in function code.
3132+
:param arg_name: The name of binding parameter in the function code.
31263133
:param input: The input to generate embeddings for.
31273134
:param input_type: The type of the input.
31283135
:param connection_name: The name of an app setting or environment

azure/functions/decorators/openai.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ def get_binding_name() -> str:
3232
def __init__(self,
3333
name: str,
3434
function_description: str,
35+
function_name: Optional[str] = None,
36+
parameter_description_json: Optional[str] = None,
37+
model: Optional[OpenAIModels] = OpenAIModels.DefaultChatModel,
3538
data_type: Optional[DataType] = None,
3639
**kwargs):
3740
self.function_description = function_description
41+
self.function_name = function_name
42+
self.parameter_description_json = parameter_description_json
43+
self.model = model
3844
super().__init__(name=name, data_type=data_type)
3945

4046

tests/decorators/test_openai.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ class TestOpenAI(unittest.TestCase):
1313
def test_assistant_skills_trigger_valid_creation(self):
1414
trigger = AssistantSkillTrigger(name="test",
1515
function_description="description",
16+
function_name="test_function_name",
17+
parameter_description_json="test_json",
18+
model=OpenAIModels.DefaultChatModel,
1619
data_type=DataType.UNDEFINED,
1720
dummy_field="dummy")
1821
self.assertEqual(trigger.get_binding_name(),
1922
"assistantSkillsTrigger")
2023
self.assertEqual(
2124
trigger.get_dict_repr(), {"name": "test",
2225
"functionDescription": "description",
26+
"functionName": "test_function_name",
27+
"parameterDescriptionJson": "test_json",
28+
"model": OpenAIModels.DefaultChatModel,
2329
"dataType": DataType.UNDEFINED,
2430
'type': 'assistantSkillsTrigger',
2531
'dummyField': 'dummy',

0 commit comments

Comments
 (0)