File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 19
19
).token
20
20
21
21
22
- @app .function_name (name = ' ask' )
23
- @app .route (route = ' ask' , auth_level = 'anonymous' , methods = [' POST' ])
22
+ @app .function_name (name = " ask" )
23
+ @app .route (route = " ask" , auth_level = "function" , methods = [" POST" ])
24
24
def main (req ):
25
25
26
- prompt = req .params .get ('prompt' )
27
- if not prompt :
28
- try :
29
- req_body = req .get_json ()
30
- except ValueError :
26
+ try :
27
+ req_body = req .get_json ()
28
+ prompt = req_body .get ("prompt" )
29
+ except ValueError :
30
+ raise RuntimeError ("prompt data must be set in POST." )
31
+ else :
32
+ if not prompt :
31
33
raise RuntimeError ("prompt data must be set in POST." )
32
- else :
33
- prompt = req_body .get ('prompt' )
34
- if not prompt :
35
- raise RuntimeError ("prompt data must be set in POST." )
36
34
37
35
# Init OpenAI: configure these using Env Variables
38
36
AZURE_OPENAI_ENDPOINT = os .environ .get ("AZURE_OPENAI_ENDPOINT" )
@@ -47,7 +45,7 @@ def main(req):
47
45
# configure azure openai for langchain and/or llm
48
46
openai .api_key = AZURE_OPENAI_KEY
49
47
openai .api_base = AZURE_OPENAI_ENDPOINT
50
- openai .api_type = ' azure'
48
+ openai .api_type = " azure"
51
49
52
50
# this may change in the future
53
51
openai .api_version = OPENAI_API_VERSION
You can’t perform that action at this time.
0 commit comments