Spaces:
sierrafr
/
Runtime error

hadadrjt commited on
Commit
991dd3b
·
1 Parent(s): 5c84f0d

ai: Allow interaction via APIs.

Browse files
Files changed (2) hide show
  1. API.md +41 -0
  2. jarvis.py +3 -2
API.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Installation
2
+
3
+ ```
4
+ pip show gradio_client > /dev/null 2>&1
5
+
6
+ if [ $? -ne 0 ]; then
7
+ pip install gradio_client
8
+ else
9
+ pip install gradio_client --upgrade
10
+ fi
11
+ ```
12
+
13
+ #### Script
14
+
15
+ ```
16
+ nano jarvis.py
17
+ ```
18
+
19
+ ```
20
+ #!/usr/bin/env python3
21
+ from gradio_client import Client
22
+
23
+ jarvis = Client("hadadrjt/ai")
24
+
25
+ # Your message here.
26
+ input = "Hi"
27
+
28
+ result = jarvis.predict(
29
+ multi_input={"text": input},
30
+ api_name="/api"
31
+ )
32
+ responses = result[0][0][1]
33
+ print(responses)
34
+ ```
35
+
36
+ #### Run
37
+
38
+ ```
39
+ chmod a+x jarvis.py
40
+ ./jarvis.py
41
+ ```
jarvis.py CHANGED
@@ -39,6 +39,7 @@ from pptx import Presentation
39
 
40
  os.system("apt-get update -q -y && apt-get install -q -y tesseract-ocr tesseract-ocr-eng tesseract-ocr-ind libleptonica-dev libtesseract-dev")
41
 
 
42
  INTERNAL_TRAINING_DATA = os.getenv("INTERNAL_TRAINING_DATA")
43
 
44
  LINUX_SERVER_HOSTS = [host for host in json.loads(os.getenv("LINUX_SERVER_HOST", "[]")) if host]
@@ -234,5 +235,5 @@ with gr.Blocks(fill_height=True, fill_width=True, title=AI_TYPES["AI_TYPE_4"], h
234
  with gr.Row():
235
  msg = gr.MultimodalTextbox(show_label=False, placeholder=RESPONSES["RESPONSE_5"], interactive=True, file_count="single", file_types=ALLOWED_EXTENSIONS)
236
  #model_dropdown.change(fn=change_model, inputs=[model_dropdown], outputs=[user_history, user_session, selected_model])
237
- msg.submit(fn=respond_async, inputs=[msg, user_history, selected_model, user_session], outputs=[chatbot, msg, user_session], concurrency_limit=None)
238
- jarvis.launch(show_api=False, max_file_size="1mb")
 
39
 
40
  os.system("apt-get update -q -y && apt-get install -q -y tesseract-ocr tesseract-ocr-eng tesseract-ocr-ind libleptonica-dev libtesseract-dev")
41
 
42
+ INTERNAL_AI_GET_SERVER = os.getenv("INTERNAL_AI_GET_SERVER")
43
  INTERNAL_TRAINING_DATA = os.getenv("INTERNAL_TRAINING_DATA")
44
 
45
  LINUX_SERVER_HOSTS = [host for host in json.loads(os.getenv("LINUX_SERVER_HOST", "[]")) if host]
 
235
  with gr.Row():
236
  msg = gr.MultimodalTextbox(show_label=False, placeholder=RESPONSES["RESPONSE_5"], interactive=True, file_count="single", file_types=ALLOWED_EXTENSIONS)
237
  #model_dropdown.change(fn=change_model, inputs=[model_dropdown], outputs=[user_history, user_session, selected_model])
238
+ msg.submit(fn=respond_async, inputs=[msg, user_history, selected_model, user_session], outputs=[chatbot, msg, user_session], concurrency_limit=None, api_name=INTERNAL_AI_GET_SERVER)
239
+ jarvis.launch(show_api=True, max_file_size="1mb")