75 lines
2.9 KiB
PHP
75 lines
2.9 KiB
PHP
<?php require_once __DIR__."/LlamaCli.func.php";
|
|
|
|
// TEST 01: Simple query.
|
|
|
|
// $out = LlamaCli("What is the capital of France?"); print_r($out);
|
|
|
|
// TEST 02: Simple query with previous background conversation
|
|
|
|
// $out = LlamaCli("Portugal?","",["previousConversation"=>[["role"=>"user","content"=>"What is the capital of France?"],["role"=>"assistant","content"=>"Paris."]]]); print_r($out);
|
|
|
|
|
|
// TEST 03: Simple query with SYSTEM PRIMING message
|
|
|
|
//$summary = LlamaCli(file_get_contents("test_input_data.3.txt"),"You are an executive assistant that will summarize english text in 1 paragraph");
|
|
//$title = LlamaCli($summary[0],"You are an talented journalist that will produce a provocative headline title based on a summary of a text");
|
|
|
|
|
|
// TEST 04: RECURSIVE QUERY, to produce long-content from short-one. LONG-WRITING. ( GOAL: Learning from model deep knowledge )
|
|
|
|
// // -------- BOOK EXAMPLE ---------
|
|
//
|
|
// // 0. CATEGORY
|
|
// $category = "learning finnish";
|
|
// $expert = "teacher";
|
|
// $total_no_of_chapters = 3;
|
|
//
|
|
//
|
|
// // 1. TITLE
|
|
// $book_title = LlamaCli_raw("Write me a title for my new book about $category. Output title only, no options, no chat.","You are an expert $expert.");
|
|
//
|
|
//
|
|
// // 2. CHAPTER TITLES
|
|
// $sys_msg = "You are an expert $expert writing a book with the title $book_title with $total_no_of_chapters chapters";
|
|
// $chapters = []; $conv_hist = [];
|
|
//
|
|
// $msg = "Write me the title of my first chapter. Output title only, no options, no chat.";
|
|
// $conv_hist[] = ["role"=>"user","content"=>$msg];
|
|
// $conv_hist[] = ["role"=>"assistant","content"=>($chapters[] = LlamaCli_raw($msg,$sys_msg,["debug_level"=>0]))];
|
|
//
|
|
// for($no=1; $no < $total_no_of_chapters; $no++) {
|
|
// $msg = "Write me the title of chapter number $no.";
|
|
// $conv_hist[] = ["role"=>"user","content"=>$msg];
|
|
// $conv_hist[] = ["role"=>"assistant","content"=>($chapters[] = LlamaCli_raw($msg,$sys_msg,["previousConversation"=>$conv_hist, "debug_level"=>0]))];
|
|
//
|
|
// }
|
|
//
|
|
// // 3. CHAPTER CONTENTS
|
|
// $content = [];
|
|
// foreach($chapters as $chapter_title)
|
|
// $content[$chapter_title] = LlamaCli_raw(
|
|
// "Write 2 paragraphs for a chapter titled $chapter_title in a book called $book_title. Output content only, no chat.",
|
|
// "You are an expert $expert."
|
|
// );
|
|
//
|
|
// print_r([$book_title, $content]);
|
|
|
|
|
|
|
|
// TEST 05: CHAINED QUERY, to parse long-content and produce short one. SUMMARIZATION. ( GOAL: )
|
|
|
|
|
|
// $summaries = [];
|
|
// $content = file_get_contents("test_input_data.2.txt");
|
|
// $chunks = array_chunk(explode("\n",$content),80);
|
|
//
|
|
// foreach($chunks as $chunk) {
|
|
// $summaries[] = LlamaCli_raw(implode("\n",$chunk),"You are a legal executive assistant that will summarize a conversation in english between ex-husband and wife in 1 paragraph");
|
|
// }
|
|
// print_r($summaries);
|
|
|
|
|
|
// TEST 06: Resolve ACTIONS
|
|
|
|
echo LlamaCli_raw("translate this title to portuguese and finnish: @rss_reader https://feeds.bbci.co.uk/news/rss.xml cde def","");
|