on1onmangoes commited on
Commit
c03dabe
·
verified ·
1 Parent(s): afd1e4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -6,12 +6,8 @@ import os
6
  HF_TOKEN = os.getenv("HF_TOKEN") # Replace with your actual token if not using an environment variable
7
 
8
  # Initialize the Gradio Client for the specified API
9
- client = Client("on1onmangoes/CNIHUB101324v10", hf_token=HF_TOKEN)
10
 
11
- #client = Client("on1onmangoes/CNIHUB101524v11", hf_token=HF_TOKEN)
12
-
13
- # Update the conversation history within the function.
14
- # Return the updated history along with any other required outputs.
15
 
16
  client_name = ['rosariarossi','bianchifiordaliso','lorenzoverdi','lucia', 'quarto4', 'quinto5', 'secondo6', 'sesto6', 'settimo7','ottavo8','nono9']
17
 
@@ -45,7 +41,7 @@ def stream_chat_with_rag(
45
 
46
  # Call the API with the user's message
47
  question = message
48
- answer = client.predict(question=question, api_name="/answer_with_rag")
49
 
50
  # Debugging: Print the raw response
51
  print("Raw answer from API:")
@@ -119,17 +115,17 @@ def format_relevant_documents(relevant_docs: list):
119
  def process_pdf(pdf_file, client_name):
120
  return client.predict(
121
  pdf_file=handle_file(pdf_file),
122
- client_name=client_name, # Hardcoded client name
123
- api_name="/process_pdf2"
124
  )[1] # Return only the result string
125
 
126
- # Function to handle search API call
127
- def search_api(query):
128
- return client.predict(query=query, api_name="/search_with_confidence")
129
 
130
  # Function to handle RAG API call
131
  def rag_api(question):
132
- return client.predict(question=question, api_name="/answer_with_rag")
133
 
134
  # CSS for custom styling
135
  CSS = """
@@ -139,7 +135,7 @@ CSS = """
139
  """
140
 
141
  # Title for the application
142
- TITLE = "<h1 style='text-align:center;'>CNI RAG QA v0</h1>"
143
 
144
  # Create the Gradio Blocks interface
145
  with gr.Blocks(css=CSS) as demo:
 
6
  HF_TOKEN = os.getenv("HF_TOKEN") # Replace with your actual token if not using an environment variable
7
 
8
  # Initialize the Gradio Client for the specified API
9
+ client = Client("on1onmangoes/cnianswer101724v3", hf_token=HF_TOKEN)
10
 
 
 
 
 
11
 
12
  client_name = ['rosariarossi','bianchifiordaliso','lorenzoverdi','lucia', 'quarto4', 'quinto5', 'secondo6', 'sesto6', 'settimo7','ottavo8','nono9']
13
 
 
41
 
42
  # Call the API with the user's message
43
  question = message
44
+ answer = client.predict(question=question, api_name="/run_graph")
45
 
46
  # Debugging: Print the raw response
47
  print("Raw answer from API:")
 
115
  def process_pdf(pdf_file, client_name):
116
  return client.predict(
117
  pdf_file=handle_file(pdf_file),
118
+ #client_name=client_name, # Hardcoded client name
119
+ api_name="/process_pdf"
120
  )[1] # Return only the result string
121
 
122
+ # # Function to handle search API call
123
+ # def search_api(query):
124
+ # return client.predict(query=query, api_name="/search_with_confidence")
125
 
126
  # Function to handle RAG API call
127
  def rag_api(question):
128
+ return client.predict(question=question, api_name="/run_graph")
129
 
130
  # CSS for custom styling
131
  CSS = """
 
135
  """
136
 
137
  # Title for the application
138
+ TITLE = "<h1 style='text-align:center;'>CNI RAG AGENTIC v0.1</h1>"
139
 
140
  # Create the Gradio Blocks interface
141
  with gr.Blocks(css=CSS) as demo: