-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from . import main | ||
from fastapi.openapi.utils import get_openapi | ||
import yaml | ||
|
||
|
||
def get_openapi_specs(): | ||
openapi_json = get_openapi( | ||
title=main.app.title, | ||
version=main.app.version, | ||
description=main.app.description, | ||
contact=main.app.contact, | ||
routes=main.app.routes, | ||
) | ||
openapi_yaml = yaml.dump(openapi_json) | ||
return openapi_yaml | ||
|
||
|
||
def convert(): | ||
try: | ||
yaml_spec = get_openapi_specs() | ||
with open("server/intelligence-service/openapi.yaml", "w") as f: | ||
f.write(yaml_spec) | ||
print("OpenAPI YAML specification generated successfully.") | ||
except Exception as e: | ||
print(f"Error generating OpenAPI specs: {e}") | ||
exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
convert() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,13 @@ | |
from pydantic import BaseModel | ||
from .model import model | ||
|
||
app = FastAPI() | ||
|
||
app = FastAPI( | ||
title="Hephaestus Intelligence Service API", | ||
description="API documentation for the Hephaestus Intelligence Service.", | ||
version="0.0.1", | ||
contact={"name": "Felix T.J. Dietrich", "email": "[email protected]"}, | ||
) | ||
|
||
|
||
class ChatRequest(BaseModel): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,82 @@ | ||
openapi: 3.0.1 | ||
components: | ||
schemas: | ||
ChatRequest: | ||
properties: | ||
message: | ||
title: Message | ||
type: string | ||
required: | ||
- message | ||
title: ChatRequest | ||
type: object | ||
ChatResponse: | ||
properties: | ||
response: | ||
title: Response | ||
type: string | ||
required: | ||
- response | ||
title: ChatResponse | ||
type: object | ||
HTTPValidationError: | ||
properties: | ||
detail: | ||
items: | ||
$ref: '#/components/schemas/ValidationError' | ||
title: Detail | ||
type: array | ||
title: HTTPValidationError | ||
type: object | ||
ValidationError: | ||
properties: | ||
loc: | ||
items: | ||
anyOf: | ||
- type: string | ||
- type: integer | ||
title: Location | ||
type: array | ||
msg: | ||
title: Message | ||
type: string | ||
type: | ||
title: Error Type | ||
type: string | ||
required: | ||
- loc | ||
- msg | ||
- type | ||
title: ValidationError | ||
type: object | ||
info: | ||
title: Hephaestus Intelligence API | ||
description: API documentation for the Hephaestus intelligence service. | ||
contact: | ||
name: Felix T.J. Dietrich | ||
email: [email protected] | ||
license: | ||
name: MIT License | ||
url: https://github.com/ls1intum/Hephaestus/blob/develop/LICENSE | ||
name: Felix T.J. Dietrich | ||
description: API documentation for the Hephaestus Intelligence Service. | ||
title: Hephaestus Intelligence Service API | ||
version: 0.0.1 | ||
servers: | ||
- url: http://localhost:8080 | ||
description: Local development server | ||
openapi: 3.1.0 | ||
paths: | ||
/chat: | ||
post: | ||
summary: Chat with LLM | ||
operationId: chatWithLLM | ||
operationId: chat_chat_post | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ChatRequest' | ||
required: true | ||
responses: | ||
'200': | ||
description: Successful response from LLM | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ChatResponse' | ||
'500': | ||
description: Internal Server Error | ||
description: Successful Response | ||
'422': | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorResponse' | ||
components: | ||
schemas: | ||
ChatRequest: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
description: The message to be sent to the LLM | ||
required: | ||
- message | ||
ChatResponse: | ||
type: object | ||
properties: | ||
response: | ||
type: string | ||
description: The response generated by the LLM | ||
required: | ||
- response | ||
ErrorResponse: | ||
type: object | ||
properties: | ||
detail: | ||
type: string | ||
description: Error message in case of failure | ||
$ref: '#/components/schemas/HTTPValidationError' | ||
description: Validation Error | ||
summary: Chat with LLM |