-
Notifications
You must be signed in to change notification settings - Fork 32
Set up api #1662
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
Merged
Merged
Set up api #1662
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
855f70f
Set up api
reakaleek 2610741
Fix Dockerfile path
reakaleek c9d67b0
Refactor naming
reakaleek e9ed083
Fix editorconfig path
reakaleek 9217ac0
Refactor editorconfig
reakaleek 39dee99
Revert "Refactor editorconfig"
reakaleek 1a3317e
Fix path
reakaleek 9eb6ac7
Fix editorconfig glob
reakaleek 6a3727b
Adjust folder structure
reakaleek de24b8a
Refactor how DocumentationWebhost is reusing the proxy
reakaleek 1d6fc4a
Revert changes to stepper
reakaleek 90efcac
Remove empty file
reakaleek 46676a9
Refactor dependency resolution
reakaleek 2d42283
Refactor mapping
reakaleek b4dfc60
Fix logging
reakaleek 591ac71
Fix AOT build
reakaleek 7fd8de6
Add services necessary for aws lambda
reakaleek 2b671cd
Revert "Add services necessary for aws lambda"
reakaleek 2717351
Add system prompt to business logic
reakaleek 45d895e
Remove dead code
reakaleek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,41 @@ | ||
| --- | ||
| # This workflow is used to build the API lambda | ||
| # lambda function bootstrap binary that can be deployed to AWS Lambda. | ||
| name: Build API Lambda | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| inputs: | ||
| ref: | ||
| required: false | ||
| type: string | ||
| default: ${{ github.ref }} | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| BINARY_PATH: .artifacts/Elastic.Documentation.Api.Lambda/release_linux-x64/bootstrap | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.ref }} | ||
| - name: Amazon Linux 2023 build | ||
| run: | | ||
| docker build . -t api-lambda:latest -f src/api/Elastic.Documentation.Api.Lambda/Dockerfile | ||
| - name: Get bootstrap binary | ||
| run: | | ||
| docker cp $(docker create --name tc api-lambda:latest):/app/.artifacts/publish ./.artifacts && docker rm tc | ||
| - name: Inspect bootstrap binary | ||
| run: | | ||
| tree .artifacts | ||
| stat "${BINARY_PATH}" | ||
| - name: Archive artifact | ||
| id: upload-artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: api-lambda-binary | ||
| retention-days: 1 | ||
| if-no-files-found: error | ||
| path: ${{ env.BINARY_PATH }} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
src/api/Elastic.Documentation.Api.Core/AskAi/AskAiUsecase.cs
This file contains hidden or 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,18 @@ | ||
| // Licensed to Elasticsearch B.V under one or more agreements. | ||
| // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
| // See the LICENSE file in the project root for more information | ||
|
|
||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Elastic.Documentation.Api.Core.AskAi; | ||
|
|
||
| public class AskAiUsecase(IAskAiGateway<Stream> askAiGateway, ILogger<AskAiUsecase> logger) | ||
| { | ||
| public async Task<Stream> AskAi(AskAiRequest askAiRequest, Cancel ctx) | ||
| { | ||
| logger.LogDebug("Processing AskAiRequest: {Request}", askAiRequest); | ||
| return await askAiGateway.AskAi(askAiRequest, ctx); | ||
| } | ||
| } | ||
|
|
||
| public record AskAiRequest(string Message, string? ThreadId); |
10 changes: 10 additions & 0 deletions
10
src/api/Elastic.Documentation.Api.Core/AskAi/IAskAiGateway.cs
This file contains hidden or 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,10 @@ | ||
| // Licensed to Elasticsearch B.V under one or more agreements. | ||
| // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
| // See the LICENSE file in the project root for more information | ||
|
|
||
| namespace Elastic.Documentation.Api.Core.AskAi; | ||
|
|
||
| public interface IAskAiGateway<T> | ||
| { | ||
| Task<T> AskAi(AskAiRequest askAiRequest, Cancel ctx = default); | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/api/Elastic.Documentation.Api.Core/Elastic.Documentation.Api.Core.csproj
This file contains hidden or 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,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <AssemblyName>Elastic.Documentation.Api.Core</AssemblyName> | ||
| <RootNamespace>Elastic.Documentation.Api.Core</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.Logging" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
13 changes: 13 additions & 0 deletions
13
src/api/Elastic.Documentation.Api.Core/SerializationContext.cs
This file contains hidden or 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,13 @@ | ||
| // Licensed to Elasticsearch B.V under one or more agreements. | ||
| // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
| // See the LICENSE file in the project root for more information | ||
|
|
||
| using System.Text.Json.Serialization; | ||
| using Elastic.Documentation.Api.Core.AskAi; | ||
|
|
||
| namespace Elastic.Documentation.Api.Core; | ||
|
|
||
|
|
||
| [JsonSerializable(typeof(AskAiRequest))] | ||
| [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] | ||
| public partial class ApiJsonContext : JsonSerializerContext; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code still necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 45d895e