Skip to content

Commit 9ff36ea

Browse files
committed
Simplify hosted handlers setup
Fix queue task scheduler Increase queue retry attempts from 10 to 20 Fix queue names Rename curl script Code docs
1 parent 0fc3fb7 commit 9ff36ea

22 files changed

Lines changed: 154 additions & 194 deletions

File tree

NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ as a web service.
6969
* `lib-python`: reusable libraries for python webservices and handlers.
7070
* `tools`: command line tools, e.g. scripts to start RabbitMQ locally.
7171
* `samples`: samples showing how to upload files, how to use encoder/retrieval, etc.
72-
* `upload-one-file.sh`: Bash command line tool to upload one document to the
72+
* `upload-file.sh`: Bash command line tool to upload one document to the
7373
memory web service.
7474
* `FileImportExamples`: C# examples showing how to upload multiple files to the
7575
memory web service, using different approaches:

SemanticMemory.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "clients", "clients", "{B0F7
1818
EndProject
1919
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "curl", "curl", "{7761EC04-9E17-44EE-A6D8-9FB97F14AF61}"
2020
ProjectSection(SolutionItems) = preProject
21-
clients\curl\upload-one-file.sh = clients\curl\upload-one-file.sh
21+
clients\curl\README.md = clients\curl\README.md
22+
clients\curl\upload-file.sh = clients\curl\upload-file.sh
2223
EndProjectSection
2324
EndProject
2425
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{6335B02C-9964-4B39-9795-C5F5F0392515}"

clients/curl/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Simple client for command line uploads to Semantic Memory.
2+
3+
Instructions:
4+
5+
```bash
6+
./upload-file.sh -h
7+
```
8+
9+
Example:
10+
11+
```bash
12+
./upload-file.sh -f test.pdf -s http://127.0.0.1:9001/upload -u curlUser -c curlDataCollection -i curlExample01
13+
```

clients/curl/test.pdf

232 KB
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Help for Bash script
1313
1414
Usage:
1515
16-
./upload-one-file.sh -f <file path> -u <id> -c <list> -i <id> -s <url>
16+
./upload-file.sh -f <file path> -u <id> -c <list> -i <id> -s <url>
1717
1818
-f file path Path to the document to upload.
1919
-u userId User ID.
@@ -25,7 +25,7 @@ Usage:
2525
2626
Example:
2727
28-
./upload-one-file.sh -f myFile.pdf -u me -c "notes meetings" -i "bash test" -s http://127.0.0.1:9001/upload
28+
./upload-file.sh -f myFile.pdf -u me -c "notes meetings" -i "bash test" -s http://127.0.0.1:9001/upload
2929
3030
3131
For more information visit https://github.com/microsoft/semantic-memory
@@ -123,7 +123,7 @@ for x in $COLLECTIONS; do
123123
done
124124

125125
# Send HTTP request using curl
126-
set -x
126+
#set -x
127127
curl -v \
128128
-F 'file1=@"'"${FILENAME}"'"' \
129129
-F 'user="'"${USER_ID}"'"' \

clients/dotnet/MemoryPipelineClient/MemoryPipelineClient.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System;
44
using System.Threading.Tasks;
55
using Microsoft.Extensions.DependencyInjection;
6-
using Microsoft.SemanticKernel.SemanticMemory.Core.Configuration;
6+
using Microsoft.SemanticKernel.SemanticMemory.Core.AppBuilders;
77
using Microsoft.SemanticKernel.SemanticMemory.Core.Handlers;
88
using Microsoft.SemanticKernel.SemanticMemory.Core.Pipeline;
99
using Microsoft.SemanticKernel.SemanticMemory.Core20;
@@ -47,7 +47,10 @@ private async Task ImportFilesInternalAsync(string[] files, ImportFileOptions op
4747
}
4848

4949
// TODO: .Then("index")
50-
pipeline.Then("extract").Then("partition").Build();
50+
pipeline
51+
.Then("extract")
52+
.Then("partition")
53+
.Build();
5154

5255
// Execute pipeline
5356
await orchestrator.RunPipelineAsync(pipeline).ConfigureAwait(false);

clients/samples/FileImportExamples/Example3_CustomInProcessPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Hosting;
5-
using Microsoft.SemanticKernel.SemanticMemory.Core.Configuration;
5+
using Microsoft.SemanticKernel.SemanticMemory.Core.AppBuilders;
66
using Microsoft.SemanticKernel.SemanticMemory.Core.ContentStorage;
77
using Microsoft.SemanticKernel.SemanticMemory.Core.Handlers;
88
using Microsoft.SemanticKernel.SemanticMemory.Core.Pipeline;

clients/samples/FileImportExamples/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
if (examplesToRun.Contains(3))
4848
{
4949
Console.WriteLine("============================");
50-
Console.WriteLine("Press Enter to continue...");
51-
Console.ReadLine();
5250
Example3_CustomInProcessPipeline.RunAsync().Wait();
5351
Console.WriteLine("============================");
5452
}

lib/dotnet/Core/Configuration/AppBuilder.cs renamed to lib/dotnet/Core/AppBuilders/AppBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
using System;
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.Hosting;
6+
using Microsoft.SemanticKernel.SemanticMemory.Core.Configuration;
67

7-
namespace Microsoft.SemanticKernel.SemanticMemory.Core.Configuration;
8+
namespace Microsoft.SemanticKernel.SemanticMemory.Core.AppBuilders;
89

910
public static class AppBuilder
1011
{

lib/dotnet/Core/DependencyInjection.cs renamed to lib/dotnet/Core/AppBuilders/DependencyInjection.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Microsoft.SemanticKernel.SemanticMemory.Core.Pipeline;
1010
using Microsoft.SemanticKernel.SemanticMemory.Core.Pipeline.Queue;
1111

12-
namespace Microsoft.SemanticKernel.SemanticMemory.Core;
12+
namespace Microsoft.SemanticKernel.SemanticMemory.Core.AppBuilders;
1313

1414
#pragma warning disable CA1724 // The name conflicts with MSExtensions
1515
public static class DependencyInjection
@@ -184,7 +184,13 @@ public static void UseDistributedPipeline(this IServiceCollection services, SKMe
184184
}
185185
}
186186

187-
public static void UseDefaultHandler<THandler>(this IServiceCollection services, string stepName) where THandler : class
187+
/// <summary>
188+
/// Register the handler as a DI service, passing the step name to ctor
189+
/// </summary>
190+
/// <param name="services">DI service collection</param>
191+
/// <param name="stepName">Pipeline step name</param>
192+
/// <typeparam name="THandler">Handler class</typeparam>
193+
public static void UseHandler<THandler>(this IServiceCollection services, string stepName) where THandler : class
188194
{
189195
services.AddTransient<THandler>(serviceProvider => ActivatorUtilities.CreateInstance<THandler>(serviceProvider, stepName));
190196
}

0 commit comments

Comments
 (0)