Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate response id field #127

Merged
merged 7 commits into from
Aug 2, 2023
4 changes: 3 additions & 1 deletion src/genai/extensions/localserver/local_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,7 @@ async def _route_generate(self, generate_request: GenerateRequestBody):
for input in generate_request.inputs
]
created_at = datetime.datetime.now().isoformat()
response = GenerateResponse(model_id=generate_request.model_id, created_at=created_at, results=results)
response = GenerateResponse(
id=str(uuid.uuid4()), model_id=generate_request.model_id, created_at=created_at, results=results
)
return response
1 change: 1 addition & 0 deletions src/genai/schemas/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class GenerateResult(GenAiResponseModel):


class GenerateResponse(GenAiResponseModel):
id: str
model_id: str
created_at: datetime
results: List[GenerateResult]
Expand Down
2 changes: 2 additions & 0 deletions tests/assets/response_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def generate(**kwargs):
SimpleResponse._check_for_errors("generate", **kwargs)

response = {}
response["id"] = "1cf9f510-5549-4ea5-a909-2cf9219c1bb5"
response["model_id"] = kwargs["model"]
response["created_at"] = "2023-03-15T18:28:12.007Z"
response["results"] = [
Expand All @@ -24,6 +25,7 @@ def generate_response_array_async(**kwargs):
arr = []
for i in range(len(kwargs["inputs"])):
response = {}
response["id"] = "1cf9f510-5549-4ea5-a909-2cf9219c1bb5"
response["model_id"] = kwargs["model"]
response["created_at"] = "2023-03-15T18:28:12.007Z"
response["results"] = [
Expand Down