Giter Site home page Giter Site logo

simple-api-aoai-formrecog-sample's Introduction

simple-api-aoai-formrecog-sample

Prepare AML Compute instance

  • Clone the repo in your home directory on AML compute instance
  • Run : !pip install -r requirements.txt
  • Run : az upgrade
  • Run : az login

Modify values in app.py

STORAGE_ACCOUNT_CONNECTION_STRING = "XXXXXXXXXXXXXXXXXXXXX"
container_name_documents = 'XXXXXXXXXXXXXXXX' #raw pdf files
OPENAI_API_KEY = "XXXXXXXXXXXXXXXXXXXXXX" # SET YOUR OWN API KEY HERE
AZURE_OPENAI_RESOURCE_ENDPOINT = "https://XXXXXXXXXX.openai.azure.com/" # SET A LINK TO YOUR RESOURCE ENDPOINT
FORM_RECOGNIZER_ENDPOINT = "https://XXXXXXXXXXX.cognitiveservices.azure.com/"
FORM_RECOGNIZER_KEY = "XXXXXXXXXXXXXXXXXXXXXX"
PROMPT= [XXXXXXXXXXXXX]

Deploy Azure App Services

  • In the directory where app.py and requirements.txt reside, run :

    • Replace myappname, mylocation and mysub bu the desired values

    az webapp up --runtime PYTHON:3.9 --sku B1 --name myappname --location mylocation --subscription mysub

It will create and deploy an App Services Instance with the python code and the associated requirements. You can use the same command to update the app service in you make some modifications in your code

Testing

You can test with POSTMAN or curl command. You need to use a "file" field to upload the document.
Replace myfile.pdf and myapp with the desired values.

For curl with the App Service Deployment :
curl -k -X POST -F [email protected] https://myapp.azurewebsites.net/upload

Or to test locally in the AML Compute Instance :
curl -k -X POST -F [email protected] http://localhost:5000/upload

Overwrite is enabled for the blob, so you can upload a file with the same name and it will be overwritten.

If you have some HTTP 413 errors (Entity too large), you can increase this variable : app.config['MAX_CONTENT_LENGTH'] = 327680000

Best practices

  • It's better and safer to use Managed Identities instead of key or access keys

simple-api-aoai-formrecog-sample's People

Contributors

deuch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.