Skip to content

Commit

Permalink
Align OpenAI API for FaqGen, DocSum
Browse files Browse the repository at this point in the history
Algin all the inputs to OpenAI API format for FaqGen, DocSum, related with GenAIComps PR opea-project/GenAIComps#1161

Signed-off-by: Xinyao Wang <[email protected]>
  • Loading branch information
XinyaoWa committed Jan 16, 2025
1 parent b4269d6 commit 8250733
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/_run-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ jobs:
SERVING_TOKEN: ${{ secrets.SERVING_TOKEN }}
IMAGE_REPO: ${{ inputs.registry }}
IMAGE_TAG: ${{ inputs.tag }}
opea_branch: "llm_openai_api"
example: ${{ inputs.example }}
hardware: ${{ inputs.hardware }}
test_case: ${{ matrix.test_case }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-docker-compose-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: E2E test with docker compose

on:
pull_request_target:
pull_request:
branches: ["main", "*rc"]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
cd ..
git clone https://github.com/opea-project/GenAIComps.git
cd GenAIComps && git checkout llm_openai_api
- name: Check for Missing Dockerfile Paths in GenAIComps
run: |
Expand Down
12 changes: 6 additions & 6 deletions DocSum/docsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ChatMessage,
UsageInfo,
)
from comps.cores.proto.docarray import DocSumLLMParams
from comps.cores.proto.api_protocol import DocSumChatCompletionRequest
from fastapi import File, Request, UploadFile
from fastapi.responses import StreamingResponse

Expand All @@ -34,13 +34,13 @@ def align_inputs(self, inputs, cur_node, runtime_graph, llm_parameters_dict, **k
if self.services[cur_node].service_type == ServiceType.LLM:
for key_to_replace in ["text", "asr_result"]:
if key_to_replace in inputs:
inputs["query"] = inputs[key_to_replace]
inputs["messages"] = inputs[key_to_replace]
del inputs[key_to_replace]

docsum_parameters = kwargs.get("docsum_parameters", None)
if docsum_parameters:
docsum_parameters = docsum_parameters.model_dump()
del docsum_parameters["query"]
del docsum_parameters["messages"]
inputs.update(docsum_parameters)
elif self.services[cur_node].service_type == ServiceType.ASR:
if "video" in inputs:
Expand Down Expand Up @@ -217,13 +217,13 @@ async def handle_request(self, request: Request, files: List[UploadFile] = File(
initial_inputs_data = {}
initial_inputs_data[data_type] = prompt
else:
initial_inputs_data = {"query": prompt}
initial_inputs_data = {"messages": prompt}

else:
raise ValueError(f"Unknown request type: {request.headers.get('content-type')}")

docsum_parameters = DocSumLLMParams(
query="",
docsum_parameters = DocSumChatCompletionRequest(
messages="",
max_tokens=chat_request.max_tokens if chat_request.max_tokens else 1024,
top_k=chat_request.top_k if chat_request.top_k else 10,
top_p=chat_request.top_p if chat_request.top_p else 0.95,
Expand Down
2 changes: 1 addition & 1 deletion DocSum/tests/test_compose_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function validate_microservices() {
"data: " \
"llm-docsum-tgi" \
"llm-docsum-gaudi-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'

# whisper microservice
ulimit -s 65536
Expand Down
2 changes: 1 addition & 1 deletion DocSum/tests/test_compose_on_rocm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function validate_microservices() {
"data: " \
"docsum-llm-server" \
"docsum-llm-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'

}

Expand Down
2 changes: 1 addition & 1 deletion DocSum/tests/test_compose_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function validate_microservices() {
"data: " \
"llm-docsum-tgi" \
"llm-docsum-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'

# whisper microservice
ulimit -s 65536
Expand Down
2 changes: 1 addition & 1 deletion FaqGen/faqgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def handle_request(self, request: Request, files: List[UploadFile] = File(
model=chat_request.model if chat_request.model else None,
)
result_dict, runtime_graph = await self.megaservice.schedule(
initial_inputs={"query": prompt}, llm_parameters=parameters
initial_inputs={"messages": prompt}, llm_parameters=parameters
)
for node, response in result_dict.items():
# Here it suppose the last microservice in the megaservice is LLM.
Expand Down
2 changes: 1 addition & 1 deletion FaqGen/tests/test_compose_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function validate_microservices() {
"data: " \
"llm" \
"llm-faqgen-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
}

function validate_megaservice() {
Expand Down
2 changes: 1 addition & 1 deletion FaqGen/tests/test_compose_on_rocm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function validate_microservices() {
"data: " \
"llm" \
"faqgen-llm-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
}

function validate_megaservice() {
Expand Down
2 changes: 1 addition & 1 deletion FaqGen/tests/test_compose_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function validate_microservices() {
"data: " \
"llm" \
"llm-faqgen-server" \
'{"query":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
'{"messages":"Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
}

function validate_megaservice() {
Expand Down

0 comments on commit 8250733

Please sign in to comment.