Skip to content

Commit

Permalink
Merge pull request #457 from solliancenet/cj-cache-agent-factory-resp…
Browse files Browse the repository at this point in the history
…onses

Cache agent factory responses
  • Loading branch information
joelhulen authored Jan 14, 2024
2 parents 2bb1fa9 + 9abd1e9 commit e6bb7fe
Show file tree
Hide file tree
Showing 52 changed files with 1,028 additions and 301 deletions.
77 changes: 37 additions & 40 deletions .github/workflows/release-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
contents: read
packages: write
steps:
- name: Fetching the Latest Release Tag number
id: releaseVersion
run: |
release_json=$(curl https://api.github.com/repos/${{ github.repository }}/releases)
release_tag=$(echo "$release_json" | jq -r '.[0].tag_name')
echo "release_tag: Latest Tag is : $release_tag"
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
# - name: Fetching the Latest Release Tag number
# id: releaseVersion
# run: |
# release_json=$(curl https://api.github.com/repos/${{ github.repository }}/releases)
# release_tag=$(echo "$release_json" | jq -r '.[0].tag_name')
# echo "release_tag: Latest Tag is : $release_tag"
# echo "release_tag=$release_tag" >> $GITHUB_OUTPUT

- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -46,14 +46,11 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ inputs.image }}
ghcr.io/solliancenet/fllm-exp02/${{ inputs.image }}
tags: |
type=raw,latest
type=raw,release
type=pep440,pattern={{version}},value=${{ steps.releaseVersion.outputs.release_tag }}
type=pep440,pattern={{major}}.{{minor}},value=${{ steps.releaseVersion.outputs.release_tag }}
type=pep440,pattern={{major}},value=${{ steps.releaseVersion.outputs.release_tag }}
type=sha,format=long
type=sha,format=short
- name: Build and push Docker images
uses: docker/build-push-action@v5
Expand All @@ -64,34 +61,34 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
push: true

helm_chart_package_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Fetching the Latest Release Tag number
id: releaseVersion
run: |
release_json=$(curl https://api.github.com/repos/${{ github.repository }}/releases)
release_tag=$(echo "$release_json" | jq -r '.[0].tag_name')
echo "release_tag: Latest Tag is : $release_tag"
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
# helm_chart_package_and_push:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# steps:
# - name: Fetching the Latest Release Tag number
# id: releaseVersion
# run: |
# release_json=$(curl https://api.github.com/repos/${{ github.repository }}/releases)
# release_tag=$(echo "$release_json" | jq -r '.[0].tag_name')
# echo "release_tag: Latest Tag is : $release_tag"
# echo "release_tag=$release_tag" >> $GITHUB_OUTPUT

- name: Checkout code
uses: actions/checkout@v2
# - name: Checkout code
# uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Log in to the Container registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Helm Chart Update, Package, and Push
run: |
cd ./deploy/helm/${{ inputs.image }}
sed -i "s/version\: 0\.0\.0/version\: ${{ steps.releaseVersion.outputs.release_tag }}/" Chart.yaml
sed -i "s/tag\: latest/tag\: ${{ steps.releaseVersion.outputs.release_tag }}/" values.yaml
helm package . --app-version ${{ steps.releaseVersion.outputs.release_tag }}
helm push ${{ inputs.image }}-${{ steps.releaseVersion.outputs.release_tag }}.tgz oci://ghcr.io/${{ github.repository }}/helm
# - name: Helm Chart Update, Package, and Push
# run: |
# cd ./deploy/helm/${{ inputs.image }}
# sed -i "s/version\: 0\.0\.0/version\: ${{ steps.releaseVersion.outputs.release_tag }}/" Chart.yaml
# sed -i "s/tag\: latest/tag\: ${{ steps.releaseVersion.outputs.release_tag }}/" values.yaml
# helm package . --app-version ${{ steps.releaseVersion.outputs.release_tag }}
# helm push ${{ inputs.image }}-${{ steps.releaseVersion.outputs.release_tag }}.tgz oci://ghcr.io/${{ github.repository }}/helm
60 changes: 30 additions & 30 deletions deploy/arm/azureAcaDeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,8 @@
"instances": [
{
"key": "agentfactory",
"image": "ghcr.io/solliancenet/foundationallm/agent-factory-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/agent-factory-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -805,8 +805,8 @@
},
{
"key": "core",
"image": "ghcr.io/solliancenet/foundationallm/core-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/core-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -816,8 +816,8 @@
},
{
"key": "management",
"image": "ghcr.io/solliancenet/foundationallm/management-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/management-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -827,8 +827,8 @@
},
{
"key": "gatekeeper",
"image": "ghcr.io/solliancenet/foundationallm/gatekeeper-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/gatekeeper-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -838,8 +838,8 @@
},
{
"key": "semantickernel",
"image": "ghcr.io/solliancenet/foundationallm/semantic-kernel-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/semantic-kernel-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -849,8 +849,8 @@
},
{
"key": "vectorization",
"image": "ghcr.io/solliancenet/foundationallm/vectorization-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/vectorization-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -865,8 +865,8 @@
"instances": [
{
"key": "corejob",
"image": "ghcr.io/solliancenet/foundationallm/core-job",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/core-job",
"tag": "latest",
"replicas": 1,
"resources": {
"cpu": 0.25,
Expand All @@ -875,8 +875,8 @@
},
{
"key": "vectorizationjob",
"image": "ghcr.io/solliancenet/foundationallm/vectorization-job",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/vectorization-job",
"tag": "latest",
"replicas": 1,
"resources": {
"cpu": 0.25,
Expand All @@ -893,8 +893,8 @@
"instances": [
{
"key": "chatui",
"image": "ghcr.io/solliancenet/foundationallm/chat-ui",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/chat-ui",
"tag": "latest",
"containerPort": 3000,
"replicas": 1,
"resources": {
Expand All @@ -904,8 +904,8 @@
},
{
"key": "managementui",
"image": "ghcr.io/solliancenet/foundationallm/management-ui",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/management-ui",
"tag": "latest",
"containerPort": 3000,
"replicas": 1,
"resources": {
Expand All @@ -920,8 +920,8 @@
"instances": [
{
"key": "agenthub",
"image": "ghcr.io/solliancenet/foundationallm/agent-hub-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/agent-hub-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -931,8 +931,8 @@
},
{
"key": "datasourcehub",
"image": "ghcr.io/solliancenet/foundationallm/data-source-hub-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/data-source-hub-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -942,8 +942,8 @@
},
{
"key": "gatekeeperint",
"image": "ghcr.io/solliancenet/foundationallm/gatekeeper-integration-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/gatekeeper-integration-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand All @@ -953,8 +953,8 @@
},
{
"key": "langchain",
"image": "ghcr.io/solliancenet/foundationallm/langchain-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/langchain-api",
"tag": "latest",
"containerPort": 80,
"replicas": 10,
"resources": {
Expand All @@ -964,8 +964,8 @@
},
{
"key": "prompthub",
"image": "ghcr.io/solliancenet/foundationallm/prompt-hub-api",
"tag": "0.1",
"image": "ghcr.io/solliancenet/fllm-exp02/prompt-hub-api",
"tag": "latest",
"containerPort": 80,
"replicas": 1,
"resources": {
Expand Down
Empty file modified deploy/scripts/Deploy-Arm-Azure.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Deploy-Images-Aks.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Deploy-OpenAi.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/DeployCertManager.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/DeployTlsSupport.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Generate-Config.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Join-Path-Recursively.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Token-Replace.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/Unified-Deploy.ps1
100755 → 100644
Empty file.
Empty file modified deploy/scripts/UploadSystemPrompts.ps1
100755 → 100644
Empty file.
25 changes: 21 additions & 4 deletions src/dotnet/AgentFactory/Agents/AgentBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using FoundationaLLM.AgentFactory.Core.Interfaces;
using FoundationaLLM.AgentFactory.Core.Models.Messages;
using FoundationaLLM.AgentFactory.Interfaces;
using FoundationaLLM.AgentFactory.Models.Orchestration;
using FoundationaLLM.Common.Interfaces;
using FoundationaLLM.Common.Models.Cache;

namespace FoundationaLLM.AgentFactory.Core.Agents
{
Expand All @@ -14,6 +17,8 @@ public class AgentBuilder
/// </summary>
/// <param name="userPrompt"></param>
/// <param name="sessionId"></param>
/// <param name="cacheService">The <see cref="ICacheService"/> used to cache agent-related artifacts.</param>
/// <param name="callContext">The call context of the request being handled.</param>
/// <param name="agentHubAPIService"></param>
/// <param name="orchestrationServices"></param>
/// <param name="promptHubAPIService"></param>
Expand All @@ -23,13 +28,22 @@ public class AgentBuilder
public static async Task<AgentBase> Build(
string userPrompt,
string sessionId,
ICacheService cacheService,
ICallContext callContext,
IAgentHubAPIService agentHubAPIService,
IEnumerable<ILLMOrchestrationService> orchestrationServices,
IPromptHubAPIService promptHubAPIService,
IDataSourceHubAPIService dataSourceHubAPIService)
{
var agentResponse = await agentHubAPIService.ResolveRequest(userPrompt, sessionId);
var agentInfo = agentResponse.Agent;
var agentResponse = callContext.AgentHint != null
? await cacheService.Get<AgentHubResponse>(
new CacheKey(callContext.AgentHint.Name!, "agent"),
async () => { return await agentHubAPIService.ResolveRequest(userPrompt, sessionId); },
false,
TimeSpan.FromHours(1))
: await agentHubAPIService.ResolveRequest(userPrompt, sessionId);

var agentInfo = agentResponse!.Agent;

// TODO: Extend the Agent Hub API service response to include the orchestrator
var orchestrationType = string.IsNullOrWhiteSpace(agentResponse.Agent!.Orchestrator)
Expand All @@ -43,7 +57,10 @@ public static async Task<AgentBase> Build(


AgentBase? agent = null;
agent = new DefaultAgent(agentInfo!, orchestrationService, promptHubAPIService, dataSourceHubAPIService);
agent = new DefaultAgent(
agentInfo!,
cacheService, callContext,
orchestrationService, promptHubAPIService, dataSourceHubAPIService);

await agent.Configure(userPrompt, sessionId);

Expand All @@ -57,7 +74,7 @@ public static async Task<AgentBase> Build(
/// <param name="orchestrationServices"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
static ILLMOrchestrationService SelectOrchestrationService(
private static ILLMOrchestrationService SelectOrchestrationService(
LLMOrchestrationService orchestrationType,
IEnumerable<ILLMOrchestrationService> orchestrationServices)
{
Expand Down
Loading

0 comments on commit e6bb7fe

Please sign in to comment.