Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions lemur-feedback/file.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;

public class LemurFetcher
{
// Function to make a POST request to LeMUR
public async Task<dynamic> PostLemur(string apiToken, string transcriptId)
{
// The URL of the AssemblyAI API endpoint
string url = "https://api.staging.assemblyai-labs.com/beta/generate/summary";

// Create a new dictionary with the audio URL
var data = new Dictionary<string, dynamic>()
{
{ "transcript_ids", new List<string>{transcriptId} },
{ "context", "this is a sales call" },
{ "answer_format", "short summary"}
};

// Create a new HttpClient to make the HTTP requests
using (var client = new HttpClient())
{
// Set the "authorization" header with your API token
client.DefaultRequestHeaders.Add("authorization", apiToken);

// Create a new JSON payload with the audio URL
var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");

// Send a POST request with the JSON payload to the API endpoint
HttpResponseMessage response = await client.PostAsync(url, content);

// Read the response content as a string
var responseContent = await response.Content.ReadAsStringAsync();

// Deserialize the response content into a dynamic object
var responseJson = JsonConvert.DeserializeObject<dynamic>(responseContent);

// Get the LeMUR response from the output JSON
string lemurResponse = responseJson.response;
return lemurResponse;
}
}
}

public class Program
{
public static void Main(string[] args)
{
string apiToken = "{your_api_token}";
string transcriptId = "{transcript_id}";

LemurFetcher lemurFetcher = new LemurFetcher();

try
{
// Fetch the LeMUR output using the PostLemur function
string lemurOutput = lemurFetcher.PostLemur(apiToken, transcriptId);

// Print the LeMUR output to the console
Console.WriteLine(lemurOutput);
}
catch (Exception ex)
{
// Print the error message if an exception is caught
Console.WriteLine($"Error: {ex.Message}");
}
}
}
50 changes: 50 additions & 0 deletions lemur-feedback/file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

// Function that sends a request to the LeMUR API
function lemur_post($api_token, $transcript_id) {
// Set the API endpoint URL
$url = "https://api.staging.assemblyai-labs.com/beta/generate/summary";

// Set the request headers for the API
$headers = [
"authorization: " . $api_token,
"content-type: application/json"
];

// Set the data to be sent in the API request
$data = [
"transcript_ids" => [$transcript_id],
"context" => "this is a sales call",
"answer_format" => "short summary"
];

// Initialize a cURL session for the API endpoint
$curl = curl_init($url);

// Set the options for the cURL session for the API request
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL session and decode the response
$response = json_decode(curl_exec($curl), true);

// Close the cURL session
curl_close($curl);

// Get the LeMUR output from the API response
$lemur_response = $response['response'];
}

try {
$api_token = "YOUR-API-TOKEN";
$transcript_id = "TRANSCRIPT-ID";

$lemur_output = lemur_post($api_token, $transcript_id);
echo $lemur_output;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}

?>
39 changes: 39 additions & 0 deletions lemur-feedback/file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import requests
import json
import sys

def post_lemur(api_token, transcript_id):
# Set the API endpoint for creating a new LeMUR response
url = "https://api.staging.assemblyai-labs.com/beta/generate/summary"

# Set the headers for the request, including the API token and content type
headers = {
"authorization": api_token,
"content-type": "application/json"
}

# Set the data for the request, including the ID of the transcript to be analyzed
data = {
"transcript_ids": [
transcript_id
],
"context": "this is a sales call",
"answer_format": "short summary"
}

# Send a POST request to the API to create a new transcript, passing in the headers and data
response = requests.post(url, json=data, headers=headers)

# Get the LeMUR response from the JSON data
lemur_response = response.json()['response']

return lemur_response

your_api_token = "{your_api_token}"
transcript_id = sys.argv[1]

# Get output from LeMUR
lemur_output = post_lemur(your_api_token, transcript_id)

# Print the summary
print(lemur_output)
52 changes: 52 additions & 0 deletions lemur-feedback/file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require "net/http"
require "json"

# Function that sends a request to the LeMUR API
def post_lemur(api_token, transcript_id)
# The URL for the AssemblyAI API
url = "https://api.staging.assemblyai-labs.com/beta/generate/summary"

headers = {
# The authorization header with your AssemblyAI API token
"authorization" => api_token,

# The content-type header for the request body
"content-type" => "application/json"
}

data = {
"transcript_ids" => [transcript_id],
"context" => "this is a sales call",
"answer_format" => "short summary"
}

# Parse the API endpoint URL into a URI object
uri = URI.parse(url)

# Create a new Net::HTTP object for making the API request
http = Net::HTTP.new(uri.host, uri.port)

# Use SSL for secure communication
http.use_ssl = true

# Create a new HTTP POST request with the API endpoint URL and headers
request = Net::HTTP::Post.new(uri.request_uri, headers)

# Set the request body to the data hash, converted to JSON format
request.body = data.to_json

# Send the API request and store the response object
response = http.request(request)

# Get the LeMUR response from the JSON
parsed_json = JSON.parse(response.body)
lemur_response = parsed_json["response"]
return lemur_response
end

# Replace {your_api_token} with your actual API token
api_token = "{your_api_token}"
transcript_id = "{transcript_id}"

lemur_output = post_lemur(api_token, transcript_id)
puts lemur_output
31 changes: 31 additions & 0 deletions lemur-feedback/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import axios from 'axios';

const API_TOKEN = 'your_api_token';
const TRANSCRIPT_ID = 'transcript_id';

// Function that sends a request to the Lemur API
async function lemurPost(api_token: string, transcriptId: string) {
const headers = {
authorization: api_token,
'content-type': 'application/json',
};

// Send a POST request to the LeMUR API with the transcript ID in the request body
const response = await axios.post('https://api.staging.assemblyai-labs.com/beta/generate/summary', {
"transcript_ids": [
transcriptId
],
"context": "this is a sales call",
"answer_format": "short summary"
}, { headers });

// Retrieve the LeMUR API response
return response.data["response"];
}

async function main() {
const lemurResponse = await lemurPost(API_TOKEN, TRANSCRIPT_ID);
console.log(lemurResponse);
}

main();
70 changes: 70 additions & 0 deletions lemur-qa/file.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;

public class LemurFetcher
{
// Function to make a POST request to LeMUR
public async Task<dynamic> PostLemur(string apiToken, string transcriptId)
{
// The URL of the AssemblyAI API endpoint
string url = "https://api.staging.assemblyai-labs.com/beta/generate/question-answer";

// Create a new dictionary with the LeMUR API parameters
var PostBodyJson = @"{""transcript_ids"": [" + @"], ""questions"": [{""question"": ""Is this caller a qualified buyer?"", ""answer_options"": [""Yes"", ""No""]}, {""question"": ""Classify the call into one of the following scenarios"", ""answer_options"": [""Follow-up"", ""2nd Call""], ""context"": ""Anytime it is clear that the caller is calling back a second time about the same topic""}, {""question"": ""What is the caller\'s mood?"", ""answer_format"": ""Short sentence""}]}";
var data = JsonSerializer.Deserialize<Dictionary<string, string>>(PostBodyJson);

// Create a new HttpClient to make the HTTP requests
using (var client = new HttpClient())
{
// Set the "authorization" header with your API token
client.DefaultRequestHeaders.Add("authorization", apiToken);

// Create a new JSON payload with the audio URL
var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");

// Send a POST request with the JSON payload to the API endpoint
HttpResponseMessage response = await client.PostAsync(url, content);

// Read the response content as a string
var responseContent = await response.Content.ReadAsStringAsync();

// Deserialize the response content into a dynamic object
var responseJson = JsonConvert.DeserializeObject<dynamic>(responseContent);

// Get the LeMUR response from the output JSON
string lemurResponse = responseJson.response;
return lemurResponse;
}
}
}

public class Program
{
public static void Main(string[] args)
{
string apiToken = "{your_api_token}";
string transcriptId = "{transcript_id}";

LemurFetcher lemurFetcher = new LemurFetcher();

try
{
// Fetch the LeMUR output using the PostLemur function
string lemurOutput = lemurFetcher.PostLemur(apiToken, transcriptId);

// Print the LeMUR output to the console
Console.WriteLine(lemurOutput);
}
catch (Exception ex)
{
// Print the error message if an exception is caught
Console.WriteLine($"Error: {ex.Message}");
}
}
}
69 changes: 69 additions & 0 deletions lemur-qa/file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

// Function that sends a request to the LeMUR API
function lemur_post($api_token, $transcript_id) {
// Set the API endpoint URL
$url = "https://api.staging.assemblyai-labs.com/beta/generate/question-answer";

// Set the request headers for the API
$headers = [
"authorization: " . $api_token,
"content-type: application/json"
];

// Set the data to be sent in the API request
$data = [
"transcript_ids" => [$transcript_id],
"questions" => [
[
"question" => "Is this caller a qualified buyer?",
"answer_options" => [
"Yes",
"No"
]
],
[
"question" => "Classify the call into one of the following scenarios",
"answer_options" => [
"Follow-up",
"2nd Call"
],
"context" => "Anytime it is clear that the caller is calling back a second time about the same topic"
],
[
"question" => "What is the caller's mood?",
"answer_format" => "Short sentence"
]
]
];

// Initialize a cURL session for the API endpoint
$curl = curl_init($url);

// Set the options for the cURL session for the API request
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL session and decode the response
$response = json_decode(curl_exec($curl), true);

// Close the cURL session
curl_close($curl);

// Get the LeMUR output from the API response
$lemur_response = $response['response'];
}

try {
$api_token = "YOUR-API-TOKEN";
$transcript_id = "TRANSCRIPT-ID";

$lemur_output = lemur_post($api_token, $transcript_id);
echo $lemur_output;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}

?>
Loading