Skip to content

Commit

Permalink
add more ui elements and save the tools in the assistant messages. Th…
Browse files Browse the repository at this point in the history
…is way later we can see the path the message went
  • Loading branch information
alnutile committed Jul 11, 2024
1 parent 59777f2 commit ad932a5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
10 changes: 3 additions & 7 deletions Modules/LlmDriver/app/Orchestrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace LlmLaraHub\LlmDriver;

use App\Domains\Chat\ToolsDto;
use App\Domains\Messages\RoleEnum;
use App\Models\Chat;
use App\Models\Filter;
Expand All @@ -23,7 +22,6 @@
class Orchestrate
{
use CreateReferencesTrait;

use ToolsHelper;

protected string $response = '';
Expand Down Expand Up @@ -64,7 +62,7 @@ public function handle(
'filter' => $filter,
]);

$message =$this->addToolsToMessage($message, $functionDto);
$message = $this->addToolsToMessage($message, $functionDto);

$toolClass = app()->make($tool);

Expand Down Expand Up @@ -118,13 +116,13 @@ public function handle(
'filter' => $filter,
]);

$message =$this->addToolsToMessage($message, $functionDto);
$message = $this->addToolsToMessage($message, $functionDto);

/** @var FunctionResponse $response */
$response = $functionClass->handle($message);

Log::info('[LaraChain] - Function Response', [
'function' => $functionName
'function' => $functionName,
]);

if ($response->save_to_message) {
Expand Down Expand Up @@ -218,8 +216,6 @@ protected function handleResponse(
}
}



protected function requiresFollowUp(array $messagesArray, Chat $chat): void
{
if ($this->requiresFollowup) {
Expand Down
2 changes: 0 additions & 2 deletions Modules/LlmDriver/app/ToolsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

trait ToolsHelper
{


protected function addToolsToMessage(Message $message, FunctionCallDto $functionDto): Message
{
$tools = $message->tools;
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Messages/SearchAndSummarizeChatRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function search(
'arguments' => json_encode([
'prompt' => $input,
]),
'function_name' => "search_and_summarize",
'function_name' => 'search_and_summarize',
'filter' => $filter,
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/OrchestrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function test_gets_summarize_function(): void

$this->assertCount(1, $message->tools->tools);

$message = Message::where('chat_id', $chat->id)->where("role", RoleEnum::Assistant)->first();
$message = Message::where('chat_id', $chat->id)->where('role', RoleEnum::Assistant)->first();

$this->assertNotNull($message?->id);

Expand Down
12 changes: 10 additions & 2 deletions tests/fixtures/after_mapping.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
[
{
"content": "how would I go about \"negotiating media buys\"",
"content": "test",
"role": "assistant"
},
{
"content": "test",
"role": "user"
},
{
"content": "**Role**\nA Summarization and Prompt Answering system that sticks to the context in this prompt.\n**Task**\nUsing the context of the prompt and the users query return a concise, clear, and accurate response.\n**Format**\nDeliver the response in a concise, clear Markdown format (Text). Use quotes as needed from the context.\n\n[DO NOT INCLUDE THE ABOVE IN THE RESPONSE]\n\n**The User's Query**:\n```how would I go about \"negotiating media buys\"```\n\n**Context from the database search of documents for Response**:\n```category: ABOUT THE AGENCY\noriginal_question: AGENCY HISTORY\nresponses: Firehouse celebrated its twentieth anniversary in 2017. Founded by Mark Hall, the agency focused on promotional and below the line work for the better part of its first decade. Beginning in 2016, Firehouse made a series of hires to enable the agency to solve bigger problems and handle larger client businesses. Today, we are the agency of record for most of our clients, many of whom have a national footprint. \n3: \n4: category: ABOUT THE AGENCY\noriginal_question: CAPABILITIES OVERVIEW\nresponses: We operate at the intersection of a consultancy and creative boutique. We believe getting to insights - a true understanding not just of the \"what's\" but the \"why's\" - is the genesis of all good ideas. Because of this, our core competencies are strategy, creative development, and media planning. All other capabilities including research, SEO\/SEM, social media, account and project management and analytics stem from those sources. We would partner with outside specialists (whom we are likely to have worked previously) se sources. We would partner with outside specialists (whom we are likely to have worked previously) to assist with Spanish language research, cultural understanding and copywriting. This is an approach we have employed successfully for Stripes Convenience Stores, Interstate Batteries and other clients. \n3: \n4: category: ABOUT THE AGENCY\noriginal_question: CAPABILITIES OVERVIEW\nresponses: We operate at the intersection of a consultancy and creative boutique. We believe getting to insights - a true understanding not just of the \"what's\" but the \"why's\" - is the genesis of all good ideas. Because of this, our core competencies are strategy, creative development, and media planning. All other capabilities including research, SEO\/SEM, social media, account and project management and analytics stem from those sources. We would partner with outside specialists (whom we are likely to have worked previously) se sources. We would partner with outside specialists (whom we are likely to have worked previously) to assist with Spanish language research, cultural understanding and copywriting. This is an approach we have employed successfully for Stripes Convenience Stores, Interstate Batteries and other clients. \n3: \n4: category: ABOUT THE AGENCY\noriginal_question: AGENCY DIFFERENTIATORS\n\nWHAT DO YOU HAVE, OR WHAT DO YOU DO, THAT YOUR COMPETITORS DONT?\nresponses: Our people. Our culture. And our clients.\nFirehouse has been built on the shoulders of a great team that works exceptionally well together. The credit for any success weve achieved belongs to them.\nOur culture makes Firehouse sticky. Its why we beat the industry averages for both employee and client retention. Its why people stay late to drink wine in the kitchen and clients schedule offsites at our place. Its also why our sense of shared values is s the kitchen and clients schedule offsites at our place. Its also why our sense of shared values is so strong.\nFinally, the relationships we have with our clients are built on trust and transparency. We still believe in the value of a handshake, keeping our word and, above all, continually asking ourselves, whats the right thing to do? not what is most expedient, politically savvy or lines our bank account. \nThe incredible results we get for our clients are never an accident. Theyre the product of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execu category: ABOUT THE AGENCY\noriginal_question: AGENCY DIFFERENTIATORS\n\nWHAT DO YOU HAVE, OR WHAT DO YOU DO, THAT YOUR COMPETITORS DONT?\nresponses: Our people. Our culture. And our clients.\nFirehouse has been built on the shoulders of a great team that works exceptionally well together. The credit for any success weve achieved belongs to them.\nOur culture makes Firehouse sticky. Its why we beat the industry averages for both employee and client retention. Its why people stay late to drink wine in the kitchen and clients schedule offsites at our place. Its also why our sense of shared values is s the kitchen and clients schedule offsites at our place. Its also why our sense of shared values is so strong.\nFinally, the relationships we have with our clients are built on trust and transparency. We still believe in the value of a handshake, keeping our word and, above all, continually asking ourselves, whats the right thing to do? not what is most expedient, politically savvy or lines our bank account. \nThe incredible results we get for our clients are never an accident. Theyre the product of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execu of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execution. \n3: Team Leadership\nAs your AOR, we see ourselves as the primary stewards of your brand and its adherence to a consistent brand strategy. We would guide your internal teams and other agency partners to common goals and shared expressions of the brand. \n\nAs AOR, we would also help to streamline communication, align marketing efforts based on an annual plan, and ensure consistency across all touchpoints. We would have regular, ongoing conversations with the other partners, keeping them infor the kitchen and clients schedule offsites at our place. Its also why our sense of shared values is so strong.\nFinally, the relationships we have with our clients are built on trust and transparency. We still believe in the value of a handshake, keeping our word and, above all, continually asking ourselves, whats the right thing to do? not what is most expedient, politically savvy or lines our bank account. \nThe incredible results we get for our clients are never an accident. Theyre the product of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execu of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execution. \n3: Team Leadership\nAs your AOR, we see ourselves as the primary stewards of your brand and its adherence to a consistent brand strategy. We would guide your internal teams and other agency partners to common goals and shared expressions of the brand. \n\nAs AOR, we would also help to streamline communication, align marketing efforts based on an annual plan, and ensure consistency across all touchpoints. We would have regular, ongoing conversations with the other partners, keeping them infor ouchpoints. We would have regular, ongoing conversations with the other partners, keeping them informed of plans or changes and linking arms to collaborate as needed. \n\nRight Size\nYour business would fit nicely in our portfolio of clients, being neither large enough to swamp the boat or small enough not to warrant our full attention. Weve always believed in scaling to meet client needs. Should your account require staff not currently in residence, we would grow to meet that demand. And, we stay close to a stable of good talent that makes that scaling efficient and effective. \n\nCapabilities\nWe of purposeful intention, relentless passion, sincere effort, intelligent thinking and skillful execution. \n3: Team Leadership\nAs your AOR, we see ourselves as the primary stewards of your brand and its adherence to a consistent brand strategy. We would guide your internal teams and other agency partners to common goals and shared expressions of the brand. \n\nAs AOR, we would also help to streamline communication, align marketing efforts based on an annual plan, and ensure consistency across all touchpoints. We would have regular, ongoing conversations with the other partners, keeping them infor ouchpoints. We would have regular, ongoing conversations with the other partners, keeping them informed of plans or changes and linking arms to collaborate as needed. \n\nRight Size\nYour business would fit nicely in our portfolio of clients, being neither large enough to swamp the boat or small enough not to warrant our full attention. Weve always believed in scaling to meet client needs. Should your account require staff not currently in residence, we would grow to meet that demand. And, we stay close to a stable of good talent that makes that scaling efficient and effective. \n\nCapabilities\nWe close to a stable of good talent that makes that scaling efficient and effective. \n\nCapabilities\nWe have all the capabilities you are seeking under one roof. And we believe that is more important today than ever. You cant afford for your marketing mix not to work in concert; message and medium need perfect orchestration. In fact, the work we were most awarded for this year all shared a common quality: an inseparable marriage of medium and message that achieved exponential effectiveness.\n\nAccountability\nAccountability is a big word for us. We believe we are only successful when our clients suc ouchpoints. We would have regular, ongoing conversations with the other partners, keeping them informed of plans or changes and linking arms to collaborate as needed. \n\nRight Size\nYour business would fit nicely in our portfolio of clients, being neither large enough to swamp the boat or small enough not to warrant our full attention. Weve always believed in scaling to meet client needs. Should your account require staff not currently in residence, we would grow to meet that demand. And, we stay close to a stable of good talent that makes that scaling efficient and effective. \n\nCapabilities\nWe close to a stable of good talent that makes that scaling efficient and effective. \n\nCapabilities\nWe have all the capabilities you are seeking under one roof. And we believe that is more important today than ever. You cant afford for your marketing mix not to work in concert; message and medium need perfect orchestration. In fact, the work we were most awarded for this year all shared a common quality: an inseparable marriage of medium and message that achieved exponential effectiveness.\n\nAccountability\nAccountability is a big word for us. We believe we are only successful when our clients suc tability\nAccountability is a big word for us. We believe we are only successful when our clients succeed. We are diligent about campaign reporting, optimization and continual improvement to ensure we hit your KPIs. We also believe that part of being accountable is having and expressing a POV on the right thing to do for your brand. Not what is expedient, politically opportunistic or financially advantageous to the agency.\n\nPassion\nWe do our best work for brands we believe in. Lennox Residential would be an ideal client for us because its a brand with great products and consumer goodwill. Youre```",
"content": "test should not be last",
"role": "assistant"
},
{
"role": "user",
"content": "Using the surrounding context to continue this response thread"
}
]
Loading

0 comments on commit ad932a5

Please sign in to comment.