Skip to content

Commit d8d375a

Browse files
authored
ui changes after rebase (#6)
* parent 580d33b author Mustafa <[email protected]> 1739513513 -0800 committer Mustafa <[email protected]> 1743715605 -0700 parent 580d33b author Mustafa <[email protected]> 1739513513 -0800 committer Mustafa <[email protected]> 1743714982 -0700 update the compose file Signed-off-by: Mustafa <[email protected]> initial Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> update for codegen Signed-off-by: Mustafa <[email protected]> add agents Signed-off-by: Mustafa <[email protected]> env updates Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> merged to main Signed-off-by: Mustafa <[email protected]> updates Signed-off-by: Mustafa <[email protected]> update the env variables Signed-off-by: Mustafa <[email protected]> update compose.yaml Signed-off-by: Mustafa <[email protected]> compose.yaml updates Signed-off-by: Mustafa <[email protected]> update readme Signed-off-by: Mustafa <[email protected]> update the compose file Signed-off-by: Mustafa <[email protected]> initial Signed-off-by: Mustafa <[email protected]> added microservice ports Signed-off-by: okhleif-IL <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> update for codegen Signed-off-by: Mustafa <[email protected]> Initial commit for Gradio UI Signed-off-by: okhleif-IL <[email protected]> New UI Signed-off-by: okhleif-IL <[email protected]> prepare for merge Signed-off-by: okhleif-IL <[email protected]> add agents Signed-off-by: Mustafa <[email protected]> env updates Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> merged to main Signed-off-by: Mustafa <[email protected]> updates Signed-off-by: Mustafa <[email protected]> UI Updates Signed-off-by: okhleif-IL <[email protected]> added dockerfile Signed-off-by: okhleif-IL <[email protected]> removed files dataframe Signed-off-by: okhleif-IL <[email protected]> updated file upload Signed-off-by: okhleif-IL <[email protected]> added checkbox for agent Signed-off-by: okhleif-IL <[email protected]> key_index_name --> index_name Signed-off-by: okhleif-IL <[email protected]> added / removed print statements Signed-off-by: okhleif-IL <[email protected]> Support for data streaming (from Melanie) Signed-off-by: okhleif-IL <[email protected]> fixed file not supported bug Signed-off-by: okhleif-IL <[email protected]> added refresh button to index Signed-off-by: okhleif-IL <[email protected]> simplified README Signed-off-by: okhleif-IL <[email protected]> updated readme and fixed merge Signed-off-by: okhleif-IL <[email protected]> reverted changes Signed-off-by: okhleif-IL <[email protected]> bug fixes and ui updates Signed-off-by: okhleif-IL <[email protected]> add cpu xeon test Signed-off-by: Mustafa <[email protected]> add cpu xeon test Signed-off-by: Mustafa <[email protected]> fixed output for index uses Signed-off-by: okhleif-IL <[email protected]> added services for gaudi Signed-off-by: okhleif-IL <[email protected]> update gaudi test and compose Signed-off-by: Mustafa <[email protected]> added error handling for exceeded token size Signed-off-by: okhleif-IL <[email protected]> update the compose file Signed-off-by: Mustafa <[email protected]> initial Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> update for codegen Signed-off-by: Mustafa <[email protected]> add agents Signed-off-by: Mustafa <[email protected]> env updates Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> merged to main Signed-off-by: Mustafa <[email protected]> updates Signed-off-by: Mustafa <[email protected]> update the env variables Signed-off-by: Mustafa <[email protected]> update compose.yaml Signed-off-by: Mustafa <[email protected]> compose.yaml updates Signed-off-by: Mustafa <[email protected]> update readme file Signed-off-by: Mustafa <[email protected]> update readme Signed-off-by: Mustafa <[email protected]> Gradio UI for CodeGen (#4) * update the compose file Signed-off-by: Mustafa <[email protected]> initial Signed-off-by: Mustafa <[email protected]> added microservice ports Signed-off-by: okhleif-IL <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> update for codegen Signed-off-by: Mustafa <[email protected]> Initial commit for Gradio UI Signed-off-by: okhleif-IL <[email protected]> New UI Signed-off-by: okhleif-IL <[email protected]> prepare for merge Signed-off-by: okhleif-IL <[email protected]> add agents Signed-off-by: Mustafa <[email protected]> env updates Signed-off-by: Mustafa <[email protected]> update codegen Signed-off-by: Mustafa <[email protected]> merged to main Signed-off-by: Mustafa <[email protected]> updates Signed-off-by: Mustafa <[email protected]> UI Updates Signed-off-by: okhleif-IL <[email protected]> added dockerfile Signed-off-by: okhleif-IL <[email protected]> removed files dataframe Signed-off-by: okhleif-IL <[email protected]> updated file upload Signed-off-by: okhleif-IL <[email protected]> added checkbox for agent Signed-off-by: okhleif-IL <[email protected]> key_index_name --> index_name Signed-off-by: okhleif-IL <[email protected]> added / removed print statements Signed-off-by: okhleif-IL <[email protected]> Support for data streaming (from Melanie) Signed-off-by: okhleif-IL <[email protected]> fixed file not supported bug Signed-off-by: okhleif-IL <[email protected]> added refresh button to index Signed-off-by: okhleif-IL <[email protected]> simplified README Signed-off-by: okhleif-IL <[email protected]> * updated readme and fixed merge Signed-off-by: okhleif-IL <[email protected]> * reverted changes Signed-off-by: okhleif-IL <[email protected]> --------- Signed-off-by: okhleif-IL <[email protected]> Co-authored-by: Mustafa <[email protected]> add cpu xeon test Signed-off-by: Mustafa <[email protected]> add cpu xeon test Signed-off-by: Mustafa <[email protected]> codegen code cleaning Signed-off-by: Mustafa <[email protected]> xeon --> gaudi Signed-off-by: okhleif-IL <[email protected]> made tests like codegen ragagents branch Signed-off-by: okhleif-IL <[email protected]> added back \n Signed-off-by: okhleif-IL <[email protected]> * code updates Signed-off-by: Mustafa <[email protected]> --------- Signed-off-by: okhleif-IL <[email protected]> Signed-off-by: Mustafa <[email protected]>
1 parent 580d33b commit d8d375a

File tree

7 files changed

+55
-51
lines changed

7 files changed

+55
-51
lines changed

CodeGen/codegen.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,13 @@
2323
logflag = os.getenv("LOGFLAG", False)
2424

2525
MEGA_SERVICE_PORT = int(os.getenv("MEGA_SERVICE_PORT", 7778))
26-
2726
LLM_SERVICE_HOST_IP = os.getenv("LLM_SERVICE_HOST_IP", "0.0.0.0")
2827
LLM_SERVICE_PORT = int(os.getenv("LLM_SERVICE_PORT", 9000))
29-
3028
RETRIEVAL_SERVICE_HOST_IP = os.getenv("RETRIEVAL_SERVICE_HOST_IP", "0.0.0.0")
3129
REDIS_RETRIEVER_PORT = int(os.getenv("REDIS_RETRIEVER_PORT", 7000))
32-
3330
TEI_EMBEDDING_HOST_IP = os.getenv("TEI_EMBEDDING_HOST_IP", "0.0.0.0")
3431
EMBEDDER_PORT = int(os.getenv("EMBEDDER_PORT", 6000))
3532

36-
print(">>>>>> LLM_SERVICE_HOST_IP:", LLM_SERVICE_HOST_IP)
37-
print(">>>>>> LLM_SERVICE_PORT:", LLM_SERVICE_PORT)
38-
39-
print(">>>>>> RETRIEVAL_SERVICE_HOST_IP:", RETRIEVAL_SERVICE_HOST_IP)
40-
print(">>>>>> REDIS_RETRIEVER_PORT:", REDIS_RETRIEVER_PORT)
41-
42-
print(">>>>>> TEI_EMBEDDING_HOST_IP:", TEI_EMBEDDING_HOST_IP)
43-
print(">>>>>> EMBEDDER_PORT:", EMBEDDER_PORT)
44-
4533
grader_prompt = """You are a grader assessing relevance of a retrieved document to a user question. \n
4634
Here is the user question: {question} \n
4735
Here is the retrieved document: \n\n {document} \n\n

CodeGen/docker_compose/intel/cpu/xeon/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,6 @@ Then run the command `docker images`, you will have the following Docker Images:
330330
- `opea/llm-textgen:latest`
331331
- `opea/codegen:latest`
332332
- `opea/codegen-ui:latest`
333-
- `opea/codegen-react-ui:latest` (optional)
333+
- `opea/codegen-gradio-ui:latest`
334+
- `opea/codegen-react-ui:latest` (optional)
335+

CodeGen/docker_compose/intel/hpu/gaudi/compose.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ services:
112112
- REDIS_RETRIEVER_PORT=${REDIS_RETRIEVER_PORT}
113113
- TEI_EMBEDDING_HOST_IP=${TEI_EMBEDDING_HOST_IP}
114114
- EMBEDDER_PORT=${EMBEDDER_PORT}
115+
- host_ip=${host_ip}
115116
ipc: host
116117
restart: always
117-
codegen-xeon-ui-server:
118+
codegen-gaudi-ui-server:
118119
image: ${REGISTRY:-opea}/codegen-gradio-ui:${TAG:-latest}
119-
container_name: codegen-xeon-ui-server
120+
container_name: codegen-gaudi-ui-server
120121
depends_on:
121122
- codegen-gaudi-backend-server
122123
ports:
@@ -132,7 +133,6 @@ services:
132133
- DATAPREP_REDIS_PORT=${DATAPREP_REDIS_PORT}
133134
ipc: host
134135
restart: always
135-
136136
redis-vector-db:
137137
image: redis/redis-stack:7.2.0-v9
138138
container_name: redis-vector-db
@@ -214,7 +214,6 @@ services:
214214
LOGFLAG: ${LOGFLAG}
215215
RETRIEVER_COMPONENT_NAME: ${RETRIEVER_COMPONENT_NAME:-OPEA_RETRIEVER_REDIS}
216216
restart: unless-stopped
217-
218217
networks:
219218
default:
220-
driver: bridge
219+
driver: bridge

CodeGen/docker_compose/set_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ export DATAPREP_REDIS_PORT=6007
5050
export DATAPREP_ENDPOINT="http://${host_ip}:${DATAPREP_REDIS_PORT}/v1/dataprep"
5151
export LOGFLAG=false
5252
export MODEL_CACHE="./data"
53-
export NUM_CARDS=1
53+
export NUM_CARDS=1

CodeGen/ui/gradio/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This project provides a user interface for summarizing documents and text using
66

77
### Build UI Docker Image
88

9-
To build the frontend Docker image, navigate to the `GenAIExamples/DocSum/ui` directory and run the following command:
9+
To build the frontend Docker image, navigate to the `GenAIExamples/CodeGen/ui` directory and run the following command:
1010

1111
```bash
1212
cd GenAIExamples/CodeGen/ui

CodeGen/ui/gradio/codegen_ui_gradio.py

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,23 @@ def upload_media(media, index=None, chunk_size=1500, chunk_overlap=100):
8080
if is_valid_url(file):
8181
print(file, " is valid URL")
8282
print("Ingesting URL...")
83+
yield (
84+
gr.Textbox(
85+
visible=True,
86+
value="Ingesting URL...",
87+
)
88+
)
8389
value = ingest_url(file, index, chunk_size, chunk_overlap)
8490
requests.append(value)
8591
yield value
8692
elif file_ext in ['.pdf', '.txt']:
8793
print("Ingesting File...")
94+
yield (
95+
gr.Textbox(
96+
visible=True,
97+
value="Ingesting file...",
98+
)
99+
)
88100
value = ingest_file(file, index, chunk_size, chunk_overlap)
89101
requests.append(value)
90102
yield value
@@ -93,7 +105,7 @@ def upload_media(media, index=None, chunk_size=1500, chunk_overlap=100):
93105
yield (
94106
gr.Textbox(
95107
visible=True,
96-
value="Your file extension type is not supported.",
108+
value="Your media is either an invalid URL or the file extension type is not supported. (Supports .pdf, .txt, url)",
97109
)
98110
)
99111
return
@@ -128,24 +140,32 @@ def generate_code(query, index=None, use_agent=False):
128140
print("Query is ", input_dict)
129141
headers = {"Content-Type": "application/json"}
130142

131-
response = requests.post(url=backend_service_endpoint, headers=headers, data=json.dumps(input_dict), stream=True)
143+
response = requests.post(url=backend_service_endpoint, headers=headers, data=json.dumps(input_dict), stream=True)
132144

145+
line_count = 0
133146
for line in response.iter_lines():
147+
line_count += 1
134148
if line:
135149
line = line.decode('utf-8')
136150
if line.startswith("data: "): # Only process lines starting with "data: "
137151
json_part = line[len("data: "):] # Remove the "data: " prefix
138-
if json_part.strip() == "[DONE]": # Ignore the DONE marker
139-
continue
140-
try:
141-
json_obj = json.loads(json_part) # Convert to dictionary
142-
if "choices" in json_obj:
143-
for choice in json_obj["choices"]:
144-
if "text" in choice:
145-
# Yield each token individually
146-
yield choice["text"]
147-
except json.JSONDecodeError:
148-
print("Error parsing JSON:", json_part)
152+
else:
153+
json_part = line
154+
if json_part.strip() == "[DONE]": # Ignore the DONE marker
155+
continue
156+
try:
157+
json_obj = json.loads(json_part) # Convert to dictionary
158+
if "choices" in json_obj:
159+
for choice in json_obj["choices"]:
160+
if "text" in choice:
161+
# Yield each token individually
162+
yield choice["text"]
163+
except json.JSONDecodeError:
164+
print("Error parsing JSON:", json_part)
165+
166+
if line_count == 0:
167+
yield f"Something went wrong, No Response Generated! \nIf you are using an Index, try uploading your media again with a smaller chunk size to avoid exceeding the token max. \
168+
\nOr, check the Use Agent box and try again."
149169

150170

151171
def ingest_file(file, index=None, chunk_size=100, chunk_overlap=150):
@@ -172,14 +192,8 @@ def ingest_url(url, index=None, chunk_size=100, chunk_overlap=150):
172192
print("URL is ", url)
173193
url = str(url)
174194
if not is_valid_url(url):
175-
print("Invalid URL")
176-
# yield (
177-
# gr.Textbox(
178-
# visible=True,
179-
# value="Invalid URL entered. Please enter a valid URL",
180-
# )
181-
# )
182-
return
195+
return "Invalid URL entered. Please enter a valid URL"
196+
183197
headers = {
184198
# "Content-Type: multipart/form-data"
185199
}
@@ -248,7 +262,7 @@ def update_table(index=None):
248262

249263
def update_indices():
250264
indices = get_indices()
251-
df = pd.DataFrame(indices, columns=["File Databases"])
265+
df = pd.DataFrame(indices, columns=["File Indices"])
252266
return df
253267

254268
def delete_file(file, index=None):
@@ -275,20 +289,20 @@ def delete_all_files(index=None):
275289
print("Delete all files ", response)
276290
table = update_table()
277291

278-
return response.text
292+
return "Delete All status: " + response.text
279293

280294
def get_indices():
281295
headers = {
282296
# "Content-Type: application/json"
283297
}
284298
response = requests.post(url=dataprep_get_indices_endpoint, headers=headers)
299+
indices = ["None"]
285300
print("Get Indices", response)
286-
indices = response.json()
301+
indices += response.json()
287302
return indices
288303

289304
def update_indices_dropdown():
290-
indices = ["None"] + get_indices()
291-
new_dd = gr.update(choices=indices, value="None")
305+
new_dd = gr.update(choices=get_indices(), value="None")
292306
return new_dd
293307

294308

@@ -310,13 +324,14 @@ def get_file_names(files):
310324
chatbot = gr.Chatbot(label="Chat History")
311325
prompt_input = gr.Textbox(label="Enter your query")
312326
with gr.Column():
313-
with gr.Row(scale=8):
327+
with gr.Row(equal_height=True):
314328
# indices = ["None"] + get_indices()
315-
database_dropdown = gr.Dropdown(choices=get_indices(), label="Select Index", value="None")
316-
with gr.Row(scale=1):
317-
db_refresh_button = gr.Button("Refresh", variant="primary")
329+
database_dropdown = gr.Dropdown(choices=get_indices(), label="Select Index", value="None", scale=10)
330+
db_refresh_button = gr.Button("Refresh Dropdown", scale=0.1)
318331
db_refresh_button.click(update_indices_dropdown, outputs=database_dropdown)
319332
use_agent = gr.Checkbox(label="Use Agent", container=False)
333+
# with gr.Row(scale=1):
334+
320335

321336
generate_button = gr.Button("Generate Code")
322337

CodeGen/ui/svelte/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BASIC_URL = 'http://backend_address:7778/v1/codegen'
1+
BASIC_URL = 'http://10.98.56.44:7778/v1/codegen'

0 commit comments

Comments
 (0)