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 9637c2a
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
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 9637c2a

Please sign in to comment.