File size: 1,281 Bytes
222fae0
90d393b
 
 
 
 
7033453
90d393b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from langserve import RemoteRunnable
from pprint import pprint

def get_response(input_text):
    app = RemoteRunnable("https://sop-api-server.onrender.com/speckle_chat/")

    for output in app.stream({"input": input_text}):
        for key, value in output.items():
            # Node
            pprint(f"Node '{key}':")
            # Optional: print full state at each node
            # pprint.pprint(value["keys"], indent=2, width=80, depth=None)
        pprint("\n---\n")
    output = value['generation']
    return output   

# Create the UI In Gradio
iface = gr.Interface(fn=get_response, 
          inputs=gr.Textbox(
          value="Enter your question"), 
          outputs="textbox",  
          title="Q&A over SOP docs",
          description="Ask a question about SOP docs and get an answer from the AI assistant. This assistant looks up relevant documents and answers your code-related question.",
          examples=[["How to fill out Form 3602A?"], 
                  ["Give out cases for VR-based surgical procedures."],["Elaborate cases or indications for VR-based rehabiliations."]
                  ],
          theme=gr.themes.Soft(),
          allow_flagging="never",)

iface.launch(share=True) # put share equal to True for public URL