eelang-sc commited on
Commit
144a47e
·
1 Parent(s): bc5ad26

Fix Spaces build and startup compatibility

Browse files
Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +10 -15
  3. requirements.txt +4 -3
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: purple
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.38.1
 
8
  app_file: app.py
9
  pinned: false
10
  ---
 
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.38.1
8
+ python_version: 3.12.3
9
  app_file: app.py
10
  pinned: false
11
  ---
app.py CHANGED
@@ -24,18 +24,11 @@ import pdfplumber
24
 
25
 
26
  pdf_examples_dir = './pdfexamples/'
 
27
 
28
- # model = dspy.LM(
29
- # model='gpt-3.5-turbo',
30
- # api_key=os.getenv('OPENAI_PROJECT_KEY'),
31
- # max_tokens=2000,
32
- # temperature=0.01)
33
-
34
- model = dspy.OpenAI(
35
- model='gpt-3.5-turbo-0125',
36
- api_key=os.getenv('OPENAI_PROJECT_KEY'),
37
- max_tokens=2000,
38
- temperature=0.01)
39
 
40
  dspy.settings.configure(lm=model)
41
 
@@ -357,7 +350,9 @@ def main():
357
  submit_button.click(
358
  poc_production_pipeline_with_verification_from_PDF,
359
  inputs=[pdf_input, verification_invoices, verification_total_amount],
360
- outputs=[retrieved_invoices, retrieved_amounts, validated_invoices, validated_total_amount]
 
 
361
  )
362
 
363
  gr.Examples(
@@ -365,12 +360,12 @@ def main():
365
  inputs=[pdf_input],
366
  outputs=[retrieved_invoices, retrieved_amounts, validated_invoices, validated_total_amount],
367
  fn=poc_production_pipeline_with_verification_from_PDF,
368
- cache_examples=True
369
  )
370
- remittance_demo.launch()
371
 
372
 
373
 
374
  # Run the main app if the file is executed directly
375
  if __name__ == "__main__":
376
- main()
 
24
 
25
 
26
  pdf_examples_dir = './pdfexamples/'
27
+ OPENAI_MODEL = "openai/gpt-5.4-nano"
28
 
29
+ model = dspy.LM(
30
+ OPENAI_MODEL,
31
+ api_key=os.getenv('OPENAI_PROJECT_KEY'))
 
 
 
 
 
 
 
 
32
 
33
  dspy.settings.configure(lm=model)
34
 
 
350
  submit_button.click(
351
  poc_production_pipeline_with_verification_from_PDF,
352
  inputs=[pdf_input, verification_invoices, verification_total_amount],
353
+ outputs=[retrieved_invoices, retrieved_amounts, validated_invoices, validated_total_amount],
354
+ # gradio-pdf's schema breaks Gradio API doc generation on this runtime.
355
+ show_api=False
356
  )
357
 
358
  gr.Examples(
 
360
  inputs=[pdf_input],
361
  outputs=[retrieved_invoices, retrieved_amounts, validated_invoices, validated_total_amount],
362
  fn=poc_production_pipeline_with_verification_from_PDF,
363
+ cache_examples=False
364
  )
365
+ remittance_demo.launch(server_name="0.0.0.0")
366
 
367
 
368
 
369
  # Run the main app if the file is executed directly
370
  if __name__ == "__main__":
371
+ main()
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
- dspy-ai
2
- gradio-pdf
3
- pdfplumber
 
 
1
+ dspy==3.1.3
2
+ gradio-pdf==0.0.22
3
+ pdfplumber==0.11.9
4
+ huggingface-hub<1.0