Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge staging into main #169

Merged
merged 65 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4a4365e
fix: code syntax highlighting to support all other languages
krushnarout Oct 25, 2024
900ae4a
Merge pull request #133 from krushnarout/fix-syntax-support
bracesproul Oct 25, 2024
d519b00
feat: address PR feedback - use initChatModel and implement configura…
ahmad2b Oct 25, 2024
78c2a26
feat: add @langchain/community for fireworks llm
ahmad2b Oct 25, 2024
a3b3902
Merge branch 'main' of https://github.com/langchain-ai/open-canvas in…
bracesproul Oct 25, 2024
9ff9ae1
cr
bracesproul Oct 25, 2024
0208017
merge staging
bracesproul Oct 25, 2024
8e0488b
cr
bracesproul Oct 25, 2024
ccd9a51
cr
bracesproul Oct 25, 2024
318b00f
cr
bracesproul Oct 25, 2024
6f4014c
Merge pull request #136 from ahmad2b/ahmad2b/customizable-model-selec…
bracesproul Oct 25, 2024
e122e44
Add Gemini 1.5 Flash to model options
mjunaidca Oct 26, 2024
900a3a4
fix: Update support for anthropic everywhere
bracesproul Oct 27, 2024
fbd294c
cr
bracesproul Oct 27, 2024
4279021
cr
bracesproul Oct 27, 2024
9791b32
move to genai
bracesproul Oct 28, 2024
a306ac2
Merge pull request #142 from mjunaidca/mjunaidca/add-gemini-1.5-flash
bracesproul Oct 28, 2024
f829417
Merge branch 'staging' into brace/use-anthropic
bracesproul Oct 28, 2024
8c4de3d
bump deps
bracesproul Oct 28, 2024
f06653b
cr
bracesproul Oct 28, 2024
61516bc
Merge pull request #145 from langchain-ai/brace/use-anthropic
bracesproul Oct 28, 2024
134e430
fix: Customize model for all requests
bracesproul Oct 28, 2024
8fb8408
cr
bracesproul Oct 28, 2024
51b3514
feat: Update font to match LangSmith
bracesproul Oct 28, 2024
614ceb4
Merge branch 'main' of https://github.com/langchain-ai/open-canvas in…
bracesproul Oct 28, 2024
2807fff
Merge branch 'staging' of https://github.com/langchain-ai/open-canvas…
bracesproul Oct 28, 2024
df26000
add tighter text
bracesproul Oct 28, 2024
679ec69
cr
bracesproul Oct 28, 2024
d9e935a
Merge pull request #156 from langchain-ai/brace/update-font
bracesproul Oct 28, 2024
c18478d
merge staging
bracesproul Oct 28, 2024
a5e1765
cr
bracesproul Oct 28, 2024
c11e50d
Merge pull request #146 from langchain-ai/brace/fix-custom-model
bracesproul Oct 28, 2024
717dba7
chore: Cleanups
bracesproul Oct 29, 2024
354c235
cleanup prop passing
bracesproul Oct 29, 2024
ceec3bc
feat: add chat feedback with thumbs up/down buttons
ahmad2b Oct 29, 2024
24bd4a8
feat: Add chat feedback only on last AI message
ahmad2b Oct 29, 2024
8904702
move components
bracesproul Oct 29, 2024
7779dd9
feat: add raw markdown view for text
listlessbird Oct 29, 2024
dad45e4
cr
bracesproul Oct 29, 2024
5d443da
Merge pull request #159 from langchain-ai/brace/cleanup-jsx
bracesproul Oct 29, 2024
e8d8e40
merge staging
bracesproul Oct 29, 2024
fed56dd
format/lint
bracesproul Oct 29, 2024
e8796d8
cr
bracesproul Oct 29, 2024
68c6f4b
Merge pull request #161 from ahmad2b/ahmad2b/add-chat-feedback
bracesproul Oct 29, 2024
4d354da
merge staging
bracesproul Oct 29, 2024
37732eb
format
bracesproul Oct 29, 2024
9f5dc01
make editable
bracesproul Oct 30, 2024
2b04198
Merge pull request #162 from listlessbird/raw-md-text
bracesproul Oct 30, 2024
099b192
fix: Set new chat true before api call returns
bracesproul Oct 30, 2024
e6303d2
Merge pull request #163 from langchain-ai/brace/reset-before-api-call
bracesproul Oct 30, 2024
8a36f43
feat: add the subgraph for generating chat titles in the background
ahmad2b Oct 30, 2024
9f941e9
feat: Add models section in readme
bracesproul Oct 30, 2024
c89f8df
Merge pull request #166 from langchain-ai/brace/models-readme-section
bracesproul Oct 30, 2024
ef620c8
cr
bracesproul Oct 30, 2024
781ec9b
cr
bracesproul Oct 30, 2024
b62c8eb
cr
bracesproul Oct 30, 2024
7a1ecb9
merge staging
bracesproul Oct 30, 2024
ebd224c
cr
bracesproul Oct 30, 2024
b325a05
Merge pull request #165 from ahmad2b/ahmad2b/background-job-chat-titles
bracesproul Oct 30, 2024
da70508
chore: Drop Llama 405b from models
bracesproul Oct 30, 2024
69967a2
Merge pull request #167 from langchain-ai/brace/remove-405b
bracesproul Oct 30, 2024
2bd7d9c
feat: Add customize model alert
bracesproul Oct 30, 2024
dfe7cbb
fade out
bracesproul Oct 30, 2024
525fabe
cr
bracesproul Oct 30, 2024
d0d6346
Merge pull request #168 from langchain-ai/brace/customize-model-alert
bracesproul Oct 30, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

credentials.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@langchain/anthropic": "^0.3.6",
"@langchain/community": "^0.3.9",
"@langchain/core": "^0.3.14",
"@langchain/google-genai": "^0.1.1",
"@langchain/google-genai": "^0.1.2",
"@langchain/langgraph": "^0.2.18",
"@langchain/langgraph-sdk": "^0.0.17",
"@langchain/openai": "^0.3.11",
Expand Down
8 changes: 4 additions & 4 deletions src/agent/open-canvas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { generateArtifact } from "./nodes/generateArtifact";
import { rewriteArtifact } from "./nodes/rewriteArtifact";
import { rewriteArtifactTheme } from "./nodes/rewriteArtifactTheme";
import { updateArtifact } from "./nodes/updateArtifact";
import { respondToQuery } from "./nodes/respondToQuery";
import { replyToGeneralInput } from "./nodes/replyToGeneralInput";
import { rewriteCodeArtifactTheme } from "./nodes/rewriteCodeArtifactTheme";
import { reflectNode } from "./nodes/reflect";
import { customAction } from "./nodes/customAction";
Expand Down Expand Up @@ -34,7 +34,7 @@ const builder = new StateGraph(OpenCanvasGraphAnnotation)
.addNode("generatePath", generatePath)
.addEdge(START, "generatePath")
// Nodes
.addNode("respondToQuery", respondToQuery)
.addNode("replyToGeneralInput", replyToGeneralInput)
.addNode("rewriteArtifact", rewriteArtifact)
.addNode("rewriteArtifactTheme", rewriteArtifactTheme)
.addNode("rewriteCodeArtifactTheme", rewriteCodeArtifactTheme)
Expand All @@ -50,7 +50,7 @@ const builder = new StateGraph(OpenCanvasGraphAnnotation)
"updateArtifact",
"rewriteArtifactTheme",
"rewriteCodeArtifactTheme",
"respondToQuery",
"replyToGeneralInput",
"generateArtifact",
"rewriteArtifact",
"customAction",
Expand All @@ -65,7 +65,7 @@ const builder = new StateGraph(OpenCanvasGraphAnnotation)
.addEdge("rewriteCodeArtifactTheme", "generateFollowup")
.addEdge("customAction", "generateFollowup")
// End edges
.addEdge("respondToQuery", "cleanState")
.addEdge("replyToGeneralInput", "cleanState")
// Only reflect if an artifact was generated/updated.
.addEdge("generateFollowup", "reflect")
.addEdge("reflect", "cleanState")
Expand Down
2 changes: 1 addition & 1 deletion src/agent/open-canvas/nodes/generatePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const generatePath = async (
const modelWithTool = model.withStructuredOutput(
z.object({
route: z
.enum(["respondToQuery", artifactRoute])
.enum(["replyToGeneralInput", artifactRoute])
.describe("The route to take based on the user's query."),
}),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { OpenCanvasGraphAnnotation, OpenCanvasGraphReturnType } from "../state";
/**
* Generate responses to questions. Does not generate artifacts.
*/
export const respondToQuery = async (
export const replyToGeneralInput = async (
state: typeof OpenCanvasGraphAnnotation.State,
config: LangGraphRunnableConfig
): Promise<OpenCanvasGraphReturnType> => {
Expand Down
29 changes: 17 additions & 12 deletions src/agent/open-canvas/nodes/rewriteArtifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ export const rewriteArtifact = async (
.describe(
"The new title to give the artifact. ONLY update this if the user is making a request which changes the subject/topic of the artifact."
),
programmingLanguage: z
language: z
.enum(
PROGRAMMING_LANGUAGES.map((lang) => lang.language) as [
string,
...string[],
]
)
.optional()
.describe(
"The programming language of the code artifact. ONLY update this if the user is making a request which changes the programming language of the code artifact, or is asking for a code artifact to be generated."
"The language of the code artifact. This should be populated with the programming language if the user is requesting code to be written, or 'other', in all other cases."
),
});
const { modelName, modelProvider } =
getModelNameAndProviderFromConfig(config);
const model = await initChatModel(modelName, {
temperature: 0,
modelProvider,
});
const toolCallingModel = model
const toolCallingModel = (
await initChatModel(modelName, {
temperature: 0,
modelProvider,
})
)
.bindTools(
[
{
Expand All @@ -71,6 +71,15 @@ export const rewriteArtifact = async (
)
.withConfig({ runName: "optionally_update_artifact_meta" });

const smallModelWithConfig = (
await initChatModel(modelName, {
temperature: 0,
modelProvider,
})
).withConfig({
runName: "rewrite_artifact_model_call",
});

const store = ensureStoreInConfig(config);
const assistantId = config.configurable?.assistant_id;
if (!assistantId) {
Expand Down Expand Up @@ -136,10 +145,6 @@ export const rewriteArtifact = async (
: ""
);

const smallModelWithConfig = model.withConfig({
runName: "rewrite_artifact_model_call",
});

const newArtifactResponse = await smallModelWithConfig.invoke([
{ role: "system", content: formattedPrompt },
recentHumanMessage,
Expand Down
4 changes: 2 additions & 2 deletions src/agent/open-canvas/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ Rules and guidelines:
export const ROUTE_QUERY_OPTIONS_HAS_ARTIFACTS = `
- 'rewriteArtifact': The user has requested some sort of change, or revision to the artifact, or to write a completely new artifact independent of the current artifact. Use their recent message and the currently selected artifact (if any) to determine what to do. You should ONLY select this if the user has clearly requested a change to the artifact, otherwise you should lean towards either generating a new artifact or responding to their query.
It is very important you do not edit the artifact unless clearly requested by the user.
- 'respondToQuery': The user has asked a question, or has submitted a general message which requires a response, but does not require updating or generating an entirely new artifact.`;
- 'replyToGeneralInput': The user submitted a general input which does not require making an update, edit or generating a new artifact. This should ONLY be used if you are ABSOLUTELY sure the user does NOT want to make an edit, update or generate a new artifact.`;

export const ROUTE_QUERY_OPTIONS_NO_ARTIFACTS = `
- 'generateArtifact': The user has inputted a request which requires generating an artifact.
- 'respondToQuery': The user has asked a question, or has submitted a general message which requires a response, but does not require generating a artifact.`;
- 'replyToGeneralInput': The user submitted a general input which does not require making an update, edit or generating a new artifact. This should ONLY be used if you are ABSOLUTELY sure the user does NOT want to make an edit, update or generate a new artifact.`;

export const CURRENT_ARTIFACT_PROMPT = `This artifact is the one the user is currently viewing.
<artifact>
Expand Down
2 changes: 1 addition & 1 deletion src/components/artifacts/ArtifactRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export function ArtifactRenderer(props: ArtifactRendererProps) {
? getArtifactContent(props.artifact)
: undefined;

if (!props.artifact || (!currentArtifactContent && props.isStreaming)) {
if (!props.artifact && props.isStreaming) {
return <ArtifactLoading />;
}

Expand Down
18 changes: 11 additions & 7 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const LANGGRAPH_API_URL =
process.env.LANGGRAPH_API_URL ?? "http://localhost:52375";
process.env.LANGGRAPH_API_URL ?? "http://localhost:53529";
// v2 is tied to the 'open-canvas-prod' deployment.
export const ASSISTANT_ID_COOKIE = "oc_assistant_id_v2";
// export const ASSISTANT_ID_COOKIE = "oc_assistant_id";
Expand Down Expand Up @@ -32,23 +32,27 @@ export const ANTHROPIC_MODELS = [
name: "claude-3-haiku-20240307",
label: "Claude 3 Haiku",
},
// {
// name: "claude-3-5-sonnet-20240620",
// label: "Claude 3.5 Sonnet",
// },
];
export const FIREWORKS_MODELS = [
{
name: "accounts/fireworks/models/llama-v3p1-70b-instruct",
label: "Fireworks Llama 70B",
},
{
name: "accounts/fireworks/models/llama-v3p1-8b-instruct",
label: "Fireworks Llama 8B",
name: "accounts/fireworks/models/llama-v3p1-405b-instruct",
label: "Fireworks Llama 405B",
},
];

export const GEMINI_MODELS = [
{
name: "gemini-1.5-flash",
label: "Gemini 1.5 Flash",
},
// {
// name: "gemini-1.5-flash",
// label: "Gemini 1.5 Flash",
// },
];
export const DEFAULT_MODEL_NAME: ALL_MODEL_NAMES = "gpt-4o-mini";
export type OPENAI_MODEL_NAMES = (typeof OPENAI_MODELS)[number]["name"];
Expand Down
9 changes: 4 additions & 5 deletions src/hooks/use-graph/useGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export function useGraph(useGraphInput: UseGraphInput) {
if (chunk.data.event === "on_chat_model_stream") {
// These are generating new messages to insert to the chat window.
if (
["generateFollowup", "respondToQuery"].includes(
["generateFollowup", "replyToGeneralInput"].includes(
chunk.data.metadata.langgraph_node
)
) {
Expand Down Expand Up @@ -534,7 +534,6 @@ export function useGraph(useGraphInput: UseGraphInput) {
chunk.data.name === "rewrite_artifact_model_call" &&
rewriteArtifactMeta
) {
console.log("IN THIS NODE");
if (!artifact) {
toast({
title: "Error",
Expand All @@ -552,12 +551,12 @@ export function useGraph(useGraphInput: UseGraphInput) {
if (
!artifactLanguage &&
rewriteArtifactMeta.type === "code" &&
rewriteArtifactMeta.programmingLanguage
rewriteArtifactMeta.language
) {
// If the type is `code` we should have a programming language populated
// in the rewriteArtifactMeta and can use that.
artifactLanguage =
rewriteArtifactMeta.programmingLanguage as ProgrammingLanguageOptions;
rewriteArtifactMeta.language as ProgrammingLanguageOptions;
} else if (!artifactLanguage) {
artifactLanguage =
(prevCurrentContent?.title as ProgrammingLanguageOptions) ??
Expand Down Expand Up @@ -652,7 +651,7 @@ export function useGraph(useGraphInput: UseGraphInput) {
rewriteArtifactMeta: {
type: artifactType,
title: prevCurrentContent.title,
programmingLanguage: artifactLanguage,
language: artifactLanguage,
},
prevCurrentContent,
newArtifactIndex,
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,10 @@ export type RewriteArtifactMetaToolResponse =
| {
type: "text";
title?: string;
language: ProgrammingLanguageOptions;
}
| {
type: "code";
title: string;
programmingLanguage: string;
language: ProgrammingLanguageOptions;
};
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,10 @@
zod "^3.22.4"
zod-to-json-schema "^3.22.3"

"@langchain/google-genai@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@langchain/google-genai/-/google-genai-0.1.1.tgz#85528c64b518a285ec7d22a8793296f27cec27ff"
integrity sha512-uuZJXWXTTTx8FGmhr/utkpiKgOZU4EXvkPIq+opLhpzCN7hYQXXMAIykjZPhAyZjazga1jxH8YOiGonM/3jhDA==
"@langchain/google-genai@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@langchain/google-genai/-/google-genai-0.1.2.tgz#23387d7027b4a787b542fc5cfb7a2469e9f4c845"
integrity sha512-oePFjTurY4O2tJiU4cJ3Wu9L+JGVwYib2LovI+SxGJImVyVlQQ1HV2SVek03vqG4d0kiX0XLQTEC7mJ7EBySkg==
dependencies:
"@google/generative-ai" "^0.7.0"
zod-to-json-schema "^3.22.4"
Expand Down