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
| function greet(name) { | |
| return "Hello, " + name; | |
| } | |
| console.log(greet(123)); // Output: Hello, 123 |
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
| 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) |
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
| class AmazonReviewQueryMatch | |
| { | |
| public AmazonReview Review { get; set; } | |
| public double Relatedness { get; set; } | |
| } | |
| async Task<AmazonReviewQueryMatch[]> Search(string query, int topN = 5) | |
| { | |
| float[] queryEmbeddings; | |
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
| 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); | |
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
| 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; } |
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
| 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) |
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
| /client1 | |
| Dockerfile | |
| client1 | |
| /client2 | |
| Dockerfile | |
| client2 | |
| /serviceA | |
| /serviceB | |
| /solution.sln |
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
| # 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 |
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
| 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) { |
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
| { | |
| "notes": [ | |
| { | |
| "note": "E", | |
| "octave": 4, | |
| "duration": 300 | |
| }, | |
| { | |
| "note": "D", | |
| "octave": 4, |