Skip to content

Instantly share code, notes, and snippets.

View dontpaniclabsgists's full-sized avatar

Don't Panic Labs dontpaniclabsgists

View GitHub Profile
import { tap, of, map, BehaviorSubject, Observable, filter, delay } from 'rxjs';
import { mergeAll } from 'rxjs/operators';
const queue$ = new BehaviorSubject<Observable<number> | undefined>(undefined);
queue$
.pipe(
filter((request) => request !== undefined),
map((request) => request!),
mergeAll(2)
class AmazonReviewQueryMatch
{
public AmazonReview Review { get; set; }
public double Relatedness { get; set; }
}
async Task<AmazonReviewQueryMatch[]> Search(string query, int topN = 5)
{
float[] queryEmbeddings;
const string model = "text-embedding-3-small";
const string apiKey = "<YOUR_API_KEY>";
using (var api = new OpenAIClient(apiKey))
{
foreach (var review in reviews)
{
var response = await api.EmbeddingsEndpoint
.CreateEmbeddingAsync(review.Combined, model, dimensions: 512);
class AmazonReview
{
public string Id { get; set; }
public string ProductId { get; set; }
public string ProfileName { get; set; }
public string HelpfulnessNumerator { get; set; }
public string HelpfulnessDenominator { get; set; }
public int Score { get; set; }
public int Time { get; set; }
public string Summary { get; set; }
private bool ValidateObject(object obj, string[] allowedNulls = null)
{
if (obj == null)
{
return false;
}
foreach (PropertyInfo property in obj.GetType().GetProperties())
{
if (property.GetIndexParameters().Length > 0)
/client1
Dockerfile
client1
/client2
Dockerfile
client2
/serviceA
/serviceB
/solution.sln
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
# Copy the client1 project files
COPY client1/. ./client1/
COPY serviceA/. ./serviceA/
COPY serviceB/. ./serviceB/
WORKDIR /src/client1
async function play_notes(notes) {
for (const note of notes) {
await play_note(note);
}
}
function play_note({ note, octave, duration }) {
return new Promise((resolve) => {
// Play the note for the duration
if (note != null && octave != null) {
{
"notes": [
{
"note": "E",
"octave": 4,
"duration": 300
},
{
"note": "D",
"octave": 4,
"function": {
"name": "play_notes",
"arguments": "{\n \"notes\": [\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"D\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"C\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"D\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"duration\": 300 },\n { \"note\": \"D\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"D\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"D\", \"octave\": 4, \"duration\": 300 },\n { \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"duration\": 300 },\n { \"note\": \"E\", \"octave\": 4, \"duration\": 300 },\n { \"note\": \"D\", \"oc