mirror of
https://github.com/langchain-ai/content-writer.git
synced 2026-07-01 21:34:17 -04:00
Merge branch 'main' into brace/better-conditional-editing
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
"@assistant-ui/react-syntax-highlighter": "^0.0.11",
|
||||
"@langchain/anthropic": "^0.3.1",
|
||||
"@langchain/core": "^0.3.3",
|
||||
"@langchain/groq": "^0.1.2",
|
||||
"@langchain/langgraph": "^0.2.8",
|
||||
"@langchain/langgraph-sdk": "^0.0.10",
|
||||
"@radix-ui/react-avatar": "^1.1.0",
|
||||
|
||||
+17
-21
@@ -12,6 +12,7 @@ import { BaseMessage } from "@langchain/core/messages";
|
||||
import { RunnableConfig } from "@langchain/core/runnables";
|
||||
import { ChatAnthropic } from "@langchain/anthropic";
|
||||
import { DEFAULT_SYSTEM_RULES } from "../constants";
|
||||
import { ChatGroq } from "@langchain/groq";
|
||||
import { UserRules } from "@/hooks/useGraph";
|
||||
|
||||
const DEFAULT_SYSTEM_RULES_STRING = `- ${DEFAULT_SYSTEM_RULES.join("\n- ")}`;
|
||||
@@ -78,9 +79,9 @@ const callModel = async (
|
||||
state: typeof GraphAnnotation.State,
|
||||
config?: RunnableConfig
|
||||
) => {
|
||||
const model = new ChatAnthropic({
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
temperature: 0,
|
||||
const model = new ChatGroq({
|
||||
model: "llama-3.1-70b-versatile",
|
||||
temperature: 0.7,
|
||||
});
|
||||
|
||||
let styleRules: string | undefined;
|
||||
@@ -144,29 +145,24 @@ const generateInsights = async (
|
||||
state: typeof GraphAnnotation.State,
|
||||
config?: RunnableConfig
|
||||
) => {
|
||||
const systemPrompt = `This conversation contains back and fourth between an AI assistant, and a user who is using the assistant to generate text.
|
||||
const systemPrompt = `Your task is to create a list of rules to help the AI assistant generate better text in the future, based on the following conversation between a user and the assistant.
|
||||
|
||||
User messages which are prefixed with "REVISED MESSAGE" contain the entire revised text the user made to the assistant message directly before in the conversation.
|
||||
Revisions are made directly by users, so you should pay VERY close attention to every single change made, no matter how small. These should be heavily considered when generating rules.
|
||||
Focus especially on any messages prefixed with "REVISED MESSAGE", which contain the user's complete revision of the assistant's previous message. Pay very close attention to every change the user makes, no matter how small, and heavily consider them when generating rules.
|
||||
|
||||
Important aspects of revisions to consider:
|
||||
- Deletions: What did the user remove? Do you need a rule to avoid adding this in the future?
|
||||
- Tone: Did they change the overall tone? Do you need a rule to ensure this tone is maintained?
|
||||
- Structure: Did they change the structure of the text? This is important to remember, as it may be a common pattern.
|
||||
Key aspects to consider in the revisions:
|
||||
- Deletions: What did the user remove? Should you create a rule to avoid adding this in the future?
|
||||
- Tone: Did the user alter the overall tone? Should you establish a rule to maintain this tone?
|
||||
- Structure: Did the user modify the text's structure? This may indicate a common pattern to remember.
|
||||
|
||||
There also may be additional back and fourth between the user and the assistant.
|
||||
Divide the rules into two categories:
|
||||
1. Style guidelines: Focus on the style, tone, and structure of the text.
|
||||
2. Content guidelines: Focus on the content, context, and purpose of the text—business logic or domain-specific rules relevant across multiple content generations. Do not include rules overly specific to a single conversation.
|
||||
|
||||
Based on the conversation, and paying particular attention to any changes made in the "REVISED MESSAGE", your job is to create a list of rules to use in the future to help the AI assistant better generate text.
|
||||
In your response, include every rule you want the AI assistant to follow in the future, based on a combination of the current conversation and previous rules. You may modify previous rules if the new conversation provides helpful information, delete old rules if they seem irrelevant, or add new rules based on the conversation.
|
||||
|
||||
These rules should be split into two categories:
|
||||
1. Style guidelines: These rules should focus on the style, tone, and structure of the text.
|
||||
2. Content guidelines: These rules should focus on the content, context, and purpose of the text. Think of this as the business logic or domain-specific rules.
|
||||
Remember that some content guidelines may not have been mentioned in this conversation but are still important to include. Ensure you don't remove any context just because it wasn't mentioned; remove only if it's obviously no longer relevant.
|
||||
|
||||
In your response, include every single rule you want the AI assistant to follow in the future. You should list rules based on a combination of the existing conversation as well as previous rules.
|
||||
You can modify previous rules if you think the new conversation has helpful information, or you can delete old rules if they don't seem relevant, or you can add new rules based on the conversation.
|
||||
|
||||
Refrain from adding overly generic rules like "follow instructions". These generic rules are already outlined in the "system_rules" below.
|
||||
Instead, focus your attention on specific details, writing style, or other aspects of the conversation that you think are important for the AI to follow.
|
||||
Avoid adding overly generic rules like "follow instructions"; such rules are already covered in the <system_rules> below. Focus on specific details, writing style, or other aspects of the conversation that are important for the AI to follow.
|
||||
|
||||
The user has defined the following rules:
|
||||
|
||||
@@ -190,7 +186,7 @@ And here are the default system rules:
|
||||
{systemRules}
|
||||
</system_rules>
|
||||
|
||||
Respond with updated rules to keep in mind for future conversations. Try to keep the rules you list high signal-to-noise - don't include unnecessary ones, but make sure the ones you do add are descriptive. Combine ones that seem similar and/or contradictory`;
|
||||
Respond with updated rules to keep in mind for future conversations. Strive for a high signal-to-noise ratio: don't include unnecessary rules, but ensure the ones you add are descriptive. Combine similar or contradictory rules.`;
|
||||
|
||||
let styleRules = DEFAULT_RULES_STRING;
|
||||
let contentRules = DEFAULT_RULES_STRING;
|
||||
|
||||
+53
-1
@@ -233,6 +233,16 @@
|
||||
zod "^3.22.4"
|
||||
zod-to-json-schema "^3.22.3"
|
||||
|
||||
"@langchain/groq@^0.1.2":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@langchain/groq/-/groq-0.1.2.tgz#d546951022a9c52a1936c3e791850c431f614974"
|
||||
integrity sha512-bgQ9yGoNHOwG6LG2ngGvSNxF/1U1c1u3vKmFWmzecFIcBoQQOJY0jb0MrL3g1uTife0Sr3zxkWKXQg2aK/U4Sg==
|
||||
dependencies:
|
||||
"@langchain/openai" "~0.3.0"
|
||||
groq-sdk "^0.5.0"
|
||||
zod "^3.22.4"
|
||||
zod-to-json-schema "^3.22.5"
|
||||
|
||||
"@langchain/langgraph-checkpoint@~0.0.6":
|
||||
version "0.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-0.0.6.tgz#69f0c5c9aeefd48dcf0fa1ffa0744d8139a9f27d"
|
||||
@@ -260,6 +270,16 @@
|
||||
uuid "^10.0.0"
|
||||
zod "^3.23.8"
|
||||
|
||||
"@langchain/openai@~0.3.0":
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@langchain/openai/-/openai-0.3.0.tgz#89329ab9350187269a471dac2c2f4fca5f1fc5a3"
|
||||
integrity sha512-yXrz5Qn3t9nq3NQAH2l4zZOI4ev2CFdLC5kvmi5SdW4bggRuM40SXTUAY3VRld4I5eocYfk82VbrlA+6dvN5EA==
|
||||
dependencies:
|
||||
js-tiktoken "^1.0.12"
|
||||
openai "^4.57.3"
|
||||
zod "^3.22.4"
|
||||
zod-to-json-schema "^3.22.3"
|
||||
|
||||
"@next/env@14.2.7":
|
||||
version "14.2.7"
|
||||
resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.7.tgz#40fcd6ccdd53fd7e6788a0604f39032c84bea112"
|
||||
@@ -2287,6 +2307,20 @@ graphemer@^1.4.0:
|
||||
resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6"
|
||||
integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==
|
||||
|
||||
groq-sdk@^0.5.0:
|
||||
version "0.5.0"
|
||||
resolved "https://registry.yarnpkg.com/groq-sdk/-/groq-sdk-0.5.0.tgz#8eefea81c3709e815c96dffa941200e85a50cf19"
|
||||
integrity sha512-RVmhW7qZ+XZoy5fIuSdx/LGQJONpL8MHgZEW7dFwTdgkzStub2XQx6OKv28CHogijdwH41J+Npj/z2jBPu3vmw==
|
||||
dependencies:
|
||||
"@types/node" "^18.11.18"
|
||||
"@types/node-fetch" "^2.6.4"
|
||||
abort-controller "^3.0.0"
|
||||
agentkeepalive "^4.2.1"
|
||||
form-data-encoder "1.7.2"
|
||||
formdata-node "^4.3.2"
|
||||
node-fetch "^2.6.7"
|
||||
web-streams-polyfill "^3.2.1"
|
||||
|
||||
has-bigints@^1.0.1, has-bigints@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa"
|
||||
@@ -3692,6 +3726,19 @@ once@^1.3.0:
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
openai@^4.57.3:
|
||||
version "4.63.0"
|
||||
resolved "https://registry.yarnpkg.com/openai/-/openai-4.63.0.tgz#cabe7223788157c96c818317cc361386807157f7"
|
||||
integrity sha512-Y9V4KODbmrOpqiOmCDVnPfMxMqKLOx8Hwcdn/r8mePq4yv7FSXGnxCs8/jZKO7zCB/IVPWihpJXwJNAIOEiZ2g==
|
||||
dependencies:
|
||||
"@types/node" "^18.11.18"
|
||||
"@types/node-fetch" "^2.6.4"
|
||||
abort-controller "^3.0.0"
|
||||
agentkeepalive "^4.2.1"
|
||||
form-data-encoder "1.7.2"
|
||||
formdata-node "^4.3.2"
|
||||
node-fetch "^2.6.7"
|
||||
|
||||
optionator@^0.9.3:
|
||||
version "0.9.4"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734"
|
||||
@@ -4900,6 +4947,11 @@ web-streams-polyfill@4.0.0-beta.3:
|
||||
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz#2898486b74f5156095e473efe989dcf185047a38"
|
||||
integrity sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==
|
||||
|
||||
web-streams-polyfill@^3.2.1:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz#2073b91a2fdb1fbfbd401e7de0ac9f8214cecb4b"
|
||||
integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==
|
||||
|
||||
webidl-conversions@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
||||
@@ -5013,7 +5065,7 @@ yocto-queue@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
|
||||
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
|
||||
|
||||
zod-to-json-schema@^3.22.3, zod-to-json-schema@^3.22.4, zod-to-json-schema@^3.23.3:
|
||||
zod-to-json-schema@^3.22.3, zod-to-json-schema@^3.22.4, zod-to-json-schema@^3.22.5, zod-to-json-schema@^3.23.3:
|
||||
version "3.23.3"
|
||||
resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.23.3.tgz#56cf4e0bd5c4096ab46e63159e20998ec7b19c39"
|
||||
integrity sha512-TYWChTxKQbRJp5ST22o/Irt9KC5nj7CdBKYB/AosCRdj/wxEMvv4NNaj9XVUHDOIp53ZxArGhnw5HMZziPFjog==
|
||||
|
||||
Reference in New Issue
Block a user