@@ -37,10 +37,10 @@ public static async Task<Assistant> CreateFunctionAssistant()
3737 new CreateAssistantRequest (
3838 null ,
3939 GenerateName ( ) ,
40- "FileSearch Demo Assistant" ,
41- "You are a helpful assistant with the ability to call functions. " )
40+ "Function Demo Assistant" ,
41+ "You are a helpful assistant with the ability to call functions related to weather " )
4242 {
43- Tools = new List < AssistantTool > ( )
43+ Tools = new List < AssistantTool >
4444 {
4545 new AssistantToolFunction ( new ToolFunctionConfig (
4646 "get_weather" ,
@@ -59,6 +59,24 @@ public static async Task<Assistant> CreateFunctionAssistant()
5959 required = new List < string > { "location" } ,
6060 additionalProperties = false
6161 }
62+ ) ) ,
63+ new AssistantToolFunction ( new ToolFunctionConfig (
64+ "get_humidity" ,
65+ "Get current humidity for a given city" ,
66+ new
67+ {
68+ type = "object" ,
69+ properties = new
70+ {
71+ location = new
72+ {
73+ type = "string" ,
74+ description = "City and Country"
75+ }
76+ } ,
77+ required = new List < string > { "location" } ,
78+ additionalProperties = false
79+ }
6280 ) )
6381 }
6482 } ) ;
@@ -68,26 +86,35 @@ public static async Task<Assistant> CreateFunctionAssistant()
6886 }
6987
7088 [ TornadoTest ]
71- public static async Task < Assistant > CreateFileSearchAssistant ( )
89+ public static async Task < Assistant > CreateFileSearchAssistant ( string ? filePath = null )
7290 {
73- VectorStoreFile vectorStoreFile = await VectorStoreDemo . CreateVectorStoreFile ( ) ;
91+ VectorStoreFile vectorStoreFile = null ! ;
92+
93+ if ( string . IsNullOrWhiteSpace ( filePath ) )
94+ {
95+ vectorStoreFile = await VectorStoreDemo . CreateVectorStoreFile ( ) ;
96+ }
97+ else
98+ {
99+ vectorStoreFile = await VectorStoreDemo . CreateVectorStoreFile ( filePath ) ;
100+ }
74101
75102 HttpCallResult < Assistant > response = await Program . Connect ( ) . Assistants . CreateAssistantAsync (
76103 new CreateAssistantRequest (
77104 null ,
78105 GenerateName ( ) ,
79106 "FileSearch Demo Assistant" ,
80- "You are a helpful assistant with the ability to search files. " )
107+ "You are a helpful assistant with the ability to search info in files" )
81108 {
82- Tools = new List < AssistantTool > ( )
109+ Tools = new List < AssistantTool >
83110 {
84111 new AssistantToolFileSearch ( )
85112 } ,
86- ToolResources = new ToolResources ( )
113+ ToolResources = new ToolResources
87114 {
88- FileSearch = new FileSearchConfig ( )
115+ FileSearch = new FileSearchConfig
89116 {
90- FileSearchFileIds = new List < string > ( ) { vectorStoreFile . VectorStoreId }
117+ FileSearchFileIds = new List < string > { vectorStoreFile . VectorStoreId }
91118 }
92119 }
93120 } ) ;
@@ -99,25 +126,16 @@ public static async Task<Assistant> CreateFileSearchAssistant()
99126 [ TornadoTest ]
100127 public static async Task < Assistant > CreateWithCodeInterpreter ( )
101128 {
102- VectorStoreFile vectorStoreFile = await VectorStoreDemo . CreateVectorStoreFile ( ) ;
103-
104129 HttpCallResult < Assistant > response = await Program . Connect ( ) . Assistants . CreateAssistantAsync (
105130 new CreateAssistantRequest (
106131 null ,
107132 GenerateName ( ) ,
108133 "Code Interpreter Demo Assistant" ,
109- "You are a helpful assistant with code interpretation capabilities ." )
134+ "You are a personal math tutor. When asked a math question, write and run code to answer the question ." )
110135 {
111- Tools = new List < AssistantTool > ( )
136+ Tools = new List < AssistantTool >
112137 {
113138 AssistantToolCodeInterpreter . Inst
114- } ,
115- ToolResources = new ToolResources ( )
116- {
117- CodeInterpreter = new CodeInterpreterConfig ( )
118- {
119- CodeInterpreterFileIds = new List < string > ( ) { vectorStoreFile . Id }
120- }
121139 }
122140 } ) ;
123141
@@ -128,10 +146,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
128146 [ TornadoTest ]
129147 public static async Task < Assistant ? > Retrieve ( )
130148 {
131- if ( generatedAssistant is null )
132- {
133- await Create ( ) ;
134- }
149+ generatedAssistant ??= await Create ( ) ;
135150
136151 HttpCallResult < Assistant > response =
137152 await Program . Connect ( ) . Assistants . RetrieveAssistantAsync ( generatedAssistant ! . Id ) ;
@@ -142,10 +157,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
142157 [ TornadoTest ]
143158 public static async Task < Assistant ? > Modify ( )
144159 {
145- if ( generatedAssistant is null )
146- {
147- await Create ( ) ;
148- }
160+ generatedAssistant ??= await Create ( ) ;
149161
150162 CreateAssistantRequest modifyRequest = new CreateAssistantRequest ( generatedAssistant ! )
151163 {
@@ -161,13 +173,11 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
161173 [ TornadoTest ]
162174 public static async Task < bool > Delete ( )
163175 {
164- if ( generatedAssistant is null )
165- {
166- await Create ( ) ;
167- }
176+ generatedAssistant ??= await Create ( ) ;
168177
169178 HttpCallResult < bool > response = await Program . Connect ( ) . Assistants . DeleteAssistantAsync ( generatedAssistant ! ) ;
170179 Console . WriteLine ( response . Response ) ;
180+ generatedAssistant = null ;
171181 return response . Data ;
172182 }
173183
@@ -179,6 +189,7 @@ public static async Task DeleteAllDemoAssistants()
179189 where assistant . Name . StartsWith ( "demo_assistant" )
180190 select Program . Connect ( ) . Assistants . DeleteAssistantAsync ( assistant . Id ) ) . ToList ( ) ;
181191 Console . WriteLine ( $ "Deleting { tasks . Count } assistants...") ;
192+ generatedAssistant = null ;
182193 await Task . WhenAll ( tasks ) ;
183194 }
184195}
0 commit comments