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
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 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
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
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
function greet(name: string): string { | |
return "Hello, " + name; | |
} | |
console.log(greet("Alice")); // Output: Hello, Alice | |
console.log(greet(123)); // Error: Argument of type 'number' is not assignable to parameter of type 'string'. |
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
let user = { name: "Alice", age: 30 }; | |
function displayUser(user) { | |
console.log(user.name + " is " + user.age + " years old."); | |
} | |
displayUser(user); // Output: Alice is 30 years old. |
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
interface User { | |
name: string; | |
age: number; | |
} | |
let user: User = { name: "Alice", age: 30 }; | |
function displayUser(user: User): void { | |
console.log(user.name + " is " + user.age + " years old."); | |
} |
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
let message = 'Learning Assignment Statements'; | |
const appName = 'Angular Adventures'; | |
// message can change, but appName is constant. |
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
let count = 0; count += 5; | |
// count is now 5 |