Spaces:
Runtime error
Runtime error
Commit
·
d8445c7
1
Parent(s):
c104447
Update app.py
Browse files
app.py
CHANGED
@@ -2,46 +2,10 @@ import gradio as gr
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
access_token = "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"
|
5 |
-
|
6 |
-
# Function to call the Gradio API
|
7 |
-
def call_gradio_api(user_input):
|
8 |
-
|
9 |
-
client = Client("https://traversaal-internal-rag-faiss-gpt3-5.hf.space/", hf_token=access_token)
|
10 |
-
result = client.predict(user_input, api_name="/predict")
|
11 |
-
return result[0], result[1], result[2], result[3], result[4]
|
12 |
-
|
13 |
-
# Interface for the Gradio app
|
14 |
-
|
15 |
-
new_prompt = gr.Textbox(
|
16 |
-
label="Augmented Prompt", placeholder="Augmented Prompt will appear here"
|
17 |
-
)
|
18 |
-
|
19 |
-
chat_response_1 = gr.Textbox(
|
20 |
-
label="Response based on augmented prompt", placeholder="Response of the prompt will appear here"
|
21 |
-
)
|
22 |
-
|
23 |
-
chat_response_2 = gr.Textbox(
|
24 |
-
label="Response based on original prompt", placeholder="Response of the prompt will appear here"
|
25 |
-
)
|
26 |
-
|
27 |
-
source_list = gr.JSON(
|
28 |
-
label="Sources", placeholder="Document source title and doi will appear here"
|
29 |
-
)
|
30 |
-
|
31 |
-
questions = gr.JSON(
|
32 |
-
label="Questions", placeholder="Related questions"
|
33 |
-
)
|
34 |
-
|
35 |
-
iface = gr.Interface(
|
36 |
-
fn=call_gradio_api,
|
37 |
-
inputs="text",
|
38 |
-
outputs = [new_prompt, chat_response_1, chat_response_2, source_list, questions],
|
39 |
-
examples=["Make me a 4-hour workshop agenda for handling conflict", "Tell me about the different skills from middle management to executive leadership", "What are some of the major debates among scholars regarding the trait versus process theories of leadership? How have these perspectives evolved over time?"],
|
40 |
-
layout="horizontal",
|
41 |
-
title="CCL Playground",
|
42 |
-
description="Enter a query to get response using RAG"
|
43 |
-
)
|
44 |
-
|
45 |
# Launch the Gradio app
|
46 |
-
|
|
|
|
|
47 |
|
|
|
|
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
access_token = "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"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Launch the Gradio app
|
6 |
+
import gradio as gr
|
7 |
+
import os
|
8 |
+
# HF_token = os.environ.get('HF_token')
|
9 |
|
10 |
+
iface = gr.load('traversaal-internal/rag-faiss-gpt3.5', src='spaces', api_key=access_token )
|
11 |
+
iface.launch()
|